| | |
| | | package com.yeshi.fanli.service.impl.config;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.goods.HotSearchMapper;
|
| | | import com.yeshi.fanli.entity.bus.search.HotSearch;
|
| | | import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.HotSearchService;
|
| | | import com.yeshi.fanli.service.inter.config.SuperHotSearchService;
|
| | |
|
| | | @Service
|
| | | public class HotSearchServiceImpl implements HotSearchService {
|
| | | |
| | | @Resource
|
| | | private HotSearchMapper hotSearchMapper;
|
| | | |
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | | |
| | | @Resource
|
| | | private SuperHotSearchService superHotSearchService;
|
| | | |
| | |
|
| | | public void addHotSearch(HotSearch hotSearch) {
|
| | | hotSearch.setCreatetime(java.lang.System.currentTimeMillis());
|
| | | hotSearchMapper.insert(hotSearch);
|
| | | }
|
| | |
|
| | | public void deleteHotSearch(long[] hsids) {
|
| | | for (long hsid : hsids) {
|
| | | |
| | | // superHotSearchService.deleteSuper(id, systemId) |
| | | |
| | | hotSearchMapper.deleteByPrimaryKey(hsid);
|
| | | }
|
| | | }
|
| | |
|
| | | public void updateHotSearch(HotSearch hotSearch) {
|
| | | HotSearch updateSearch = new HotSearch(hotSearch.getId());
|
| | | updateSearch.setName(hotSearch.getName());
|
| | | updateSearch.setOrderby(hotSearch.getOrderby());
|
| | | updateSearch.setUseType(hotSearch.getUseType());
|
| | | hotSearchMapper.updateByPrimaryKeySelective(updateSearch);
|
| | | }
|
| | |
|
| | |
|
| | | |
| | | @Override
|
| | | public List<HotSearch> listQuery(int start, int count, String key, Long systemId, Integer useType) throws Exception {
|
| | | |
| | | List<HotSearch> listObj = hotSearchMapper.listQuery(start, count, key, systemId, useType);
|
| | |
|
| | | if (listObj == null || listObj.size() == 0) {
|
| | | return null;
|
| | | }
|
| | | |
| | | List<Long> listId = new ArrayList<>();
|
| | | for (HotSearch hotSearch : listObj) {
|
| | | listId.add(hotSearch.getId());
|
| | | }
|
| | | |
| | | |
| | | List<BusinessSystem> systemList = businessSystemService.getBusinessSystems();
|
| | | |
| | | List<SuperHotSearch> listSuper = superHotSearchService.listSuperHotSearch(listId);
|
| | | |
| | | if (listSuper == null || listSuper.size() == 0) {
|
| | | for (HotSearch hotSearch : listObj) {
|
| | | hotSearch.setSystemList(systemList);
|
| | | }
|
| | | } else {
|
| | | for (HotSearch hotSearch : listObj) {
|
| | | Long id = hotSearch.getId();
|
| | | List<BusinessSystem> newList = new ArrayList<BusinessSystem>();
|
| | | |
| | | // 是否有关联系统选项
|
| | | for (BusinessSystem dsystem : systemList) {
|
| | | BusinessSystem newsystem = new BusinessSystem();
|
| | |
|
| | | try {
|
| | | PropertyUtils.copyProperties(newsystem, dsystem);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (listSuper != null && listSuper.size() > 0) {
|
| | |
|
| | | Long superSystemId = newsystem.getId();
|
| | |
|
| | | for (SuperHotSearch superHotSearch : listSuper) {
|
| | | HotSearch search = superHotSearch.getHotSearch();
|
| | | BusinessSystem system = superHotSearch.getSystem();
|
| | |
|
| | | // 当前专题 、当前系统
|
| | | if (search != null && system != null && id == search.getId() && superSystemId == system.getId()) {
|
| | | newsystem.setCheck(1);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (newsystem.getCheck() != 1) {
|
| | | newsystem.setCheck(0);
|
| | | }
|
| | | newList.add(newsystem);
|
| | | }
|
| | | hotSearch.setSystemList(newList);
|
| | | }
|
| | | }
|
| | |
|
| | | return listObj;
|
| | | }
|
| | | |
| | | @Override
|
| | | public int countList(String key, Long systemId, Integer useType) {
|
| | | return hotSearchMapper.countQuery(key, systemId, useType);
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.config; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import org.apache.commons.beanutils.PropertyUtils; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.goods.HotSearchMapper; |
| | | import com.yeshi.fanli.entity.bus.search.HotSearch; |
| | | import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch; |
| | | import com.yeshi.fanli.entity.system.BusinessSystem; |
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService; |
| | | import com.yeshi.fanli.service.inter.config.HotSearchService; |
| | | import com.yeshi.fanli.service.inter.config.SuperHotSearchService; |
| | | |
| | | @Service |
| | | public class HotSearchServiceImpl implements HotSearchService { |
| | | |
| | | @Resource |
| | | private HotSearchMapper hotSearchMapper; |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | @Resource |
| | | private SuperHotSearchService superHotSearchService; |
| | | |
| | | |
| | | public void addHotSearch(HotSearch hotSearch) { |
| | | hotSearch.setCreatetime(java.lang.System.currentTimeMillis()); |
| | | hotSearchMapper.insert(hotSearch); |
| | | } |
| | | |
| | | public void deleteHotSearch(Long[] hsids) { |
| | | for (Long hsid : hsids) { |
| | | |
| | | // superHotSearchService.deleteSuper(id, systemId) |
| | | |
| | | hotSearchMapper.deleteByPrimaryKey(hsid); |
| | | } |
| | | } |
| | | |
| | | public void updateHotSearch(HotSearch hotSearch) { |
| | | HotSearch updateSearch = new HotSearch(hotSearch.getId()); |
| | | updateSearch.setName(hotSearch.getName()); |
| | | updateSearch.setOrderby(hotSearch.getOrderby()); |
| | | updateSearch.setUseType(hotSearch.getUseType()); |
| | | hotSearchMapper.updateByPrimaryKeySelective(updateSearch); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<HotSearch> listQuery(int start, int count, String key, Long systemId, Integer useType, SystemEnum system) throws Exception { |
| | | |
| | | List<HotSearch> listObj = hotSearchMapper.listQuery(start, count, key, systemId, useType,system); |
| | | |
| | | if (listObj == null || listObj.size() == 0) { |
| | | return null; |
| | | } |
| | | |
| | | List<Long> listId = new ArrayList<>(); |
| | | for (HotSearch hotSearch : listObj) { |
| | | listId.add(hotSearch.getId()); |
| | | } |
| | | |
| | | |
| | | List<BusinessSystem> systemList = businessSystemService.getBusinessSystems(); |
| | | |
| | | List<SuperHotSearch> listSuper = superHotSearchService.listSuperHotSearch(listId); |
| | | |
| | | if (listSuper == null || listSuper.size() == 0) { |
| | | for (HotSearch hotSearch : listObj) { |
| | | hotSearch.setSystemList(systemList); |
| | | } |
| | | } else { |
| | | for (HotSearch hotSearch : listObj) { |
| | | Long id = hotSearch.getId(); |
| | | List<BusinessSystem> newList = new ArrayList<BusinessSystem>(); |
| | | |
| | | // 是否有关联系统选项 |
| | | for (BusinessSystem dsystem : systemList) { |
| | | BusinessSystem newsystem = new BusinessSystem(); |
| | | |
| | | try { |
| | | PropertyUtils.copyProperties(newsystem, dsystem); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (listSuper != null && listSuper.size() > 0) { |
| | | |
| | | Long superSystemId = newsystem.getId(); |
| | | |
| | | for (SuperHotSearch superHotSearch : listSuper) { |
| | | HotSearch search = superHotSearch.getHotSearch(); |
| | | BusinessSystem s = superHotSearch.getSystem(); |
| | | |
| | | // 当前专题 、当前系统 |
| | | if (search != null && system != null && id == search.getId() && superSystemId == s.getId()) { |
| | | newsystem.setCheck(1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (newsystem.getCheck() != 1) { |
| | | newsystem.setCheck(0); |
| | | } |
| | | newList.add(newsystem); |
| | | } |
| | | hotSearch.setSystemList(newList); |
| | | } |
| | | } |
| | | |
| | | return listObj; |
| | | } |
| | | |
| | | @Override |
| | | public int countList(String key, Long systemId, Integer useType, SystemEnum system) { |
| | | return hotSearchMapper.countQuery(key, systemId, useType,system); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Cacheable(value = "crgCache", key = "'getHotSearchCache-' + #useType+'-'+#system") |
| | | public List<HotSearch> getHotSearchCache(Integer useType, SystemEnum system) { |
| | | return hotSearchMapper.getHotSearchList(useType,system); |
| | | } |
| | | |
| | | |
| | | |
| | | } |