1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package com.caimei.www.service.impl;
- import com.caimei.www.mapper.BaseDao;
- import com.caimei.www.pojo.base.*;
- import com.caimei.www.service.BaseService;
- import com.caimei.www.utils.ImageUtil;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.cache.annotation.Cacheable;
- import org.springframework.stereotype.Service;
- import org.springframework.util.CollectionUtils;
- import org.springframework.util.StringUtils;
- import javax.annotation.Resource;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * Description
- *
- * @author : Charles
- * @date : 2020/6/16
- */
- @Service
- public class BaseServiceImpl implements BaseService {
- @Resource
- private BaseDao baseDao;
- @Value("${caimei.wwwDomain}")
- private String domain;
- /**
- * 获取搜索热门关键字
- */
- @Override
- @Cacheable(value = "getSearchHotWord", key="'www'", unless="#result == null")
- public List<String> getSearchHotWord() {
- List<String> hotSearch = baseDao.getSearchKeyword();
- if (!CollectionUtils.isEmpty(hotSearch) && hotSearch.size() > 8) {
- return hotSearch.parallelStream()
- .filter(str -> !StringUtils.isEmpty(str)).limit(8)
- .collect(Collectors.toList());
- } else {
- return hotSearch;
- }
- }
- /**
- * 获取头部菜单
- */
- @Override
- @Cacheable(value = "getNavMenu", key="'www'", unless="#result == null")
- public List<TopMenu> getNavMenu() {
- List<TopMenu> menuList = baseDao.getTopMenus();
- menuList.forEach(item -> {
- List<SubMenu> subList = baseDao.getSubMenus(item.getId());
- if (subList.size() > 0) {
- // 设置老图片路径
- subList.forEach(sub -> {
- sub.setImage(ImageUtil.getImageURL("", sub.getImage(), 0, domain));
- });
- }
- item.setSubMenus(subList);
- });
- return menuList;
- }
- /**
- * 底部帮助页
- */
- @Override
- @Cacheable(value = "getHelpPages", key="'www'", unless="#result == null")
- public List<BaseLink> getHelpPages() {
- List<BaseLink> typeList = baseDao.getHelpPageTypes();
- typeList.forEach(item -> {
- List<BaseLink> pageList = baseDao.getHelpPagesByType(item.getId());
- item.setLinkList(pageList);
- });
- return typeList;
- }
- /**
- * 友情链接
- */
- @Override
- @Cacheable(value = "getFriendLinks", key="'www'", unless="#result == null")
- public List<BaseLink> getFriendLinks() {
- return baseDao.getFriendLinks();
- }
- }
|