From c6b718c3cadf5e5fff4c2a47fd1247842439f8c7 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 15 四月 2020 10:45:18 +0800
Subject: [PATCH] 团队消息
---
fanli/src/main/java/com/yeshi/fanli/service/impl/config/SuperHotSearchSerivceImpl.java | 138 ++++++---------------------------------------
1 files changed, 20 insertions(+), 118 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SuperHotSearchSerivceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SuperHotSearchSerivceImpl.java
index 0201047..aaaa99b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SuperHotSearchSerivceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/config/SuperHotSearchSerivceImpl.java
@@ -1,165 +1,67 @@
package com.yeshi.fanli.service.impl.config;
-import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
import org.springframework.cache.annotation.Cacheable;
-import org.springframework.orm.hibernate4.HibernateCallback;
import org.springframework.stereotype.Service;
-import com.yeshi.fanli.dao.goods.SuperHotSearchDao;
+import com.yeshi.fanli.dao.mybatis.goods.SuperHotSearchMapper;
import com.yeshi.fanli.entity.bus.search.HotSearch;
import com.yeshi.fanli.entity.bus.su.search.SuperHotSearch;
-import com.yeshi.fanli.entity.system.System;
+import com.yeshi.fanli.entity.system.BusinessSystem;
+import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.config.SuperHotSearchService;
-import com.yeshi.fanli.service.inter.config.SystemService;
-import com.yeshi.fanli.util.StringUtil;
@Service
public class SuperHotSearchSerivceImpl implements SuperHotSearchService {
@Resource
- private SuperHotSearchDao superHotSearchDao;
+ private SuperHotSearchMapper superHotSearchMapper;
@Resource
- private SystemService systemService;
+ private BusinessSystemService businessSystemService;
- public List<SuperHotSearch> getSuperHotSearchBySystemId(long id) {
-
- return superHotSearchDao.list("from SuperHotSearch shs where shs.system.id=? order by hotSearch.orderby desc",
- new Serializable[] { id });
+ public List<SuperHotSearch> getSuperHotSearchBySystemId(long id, Integer useType) {
+ return superHotSearchMapper.listBySystemId(id, useType);
}
- public List<SuperHotSearch> getSuperHotSearchsByHotSearchs(List<Long> hsIdList) {
- if (hsIdList.size() == 0) {
- return new ArrayList<SuperHotSearch>();
- }
- StringBuffer sb = new StringBuffer(" from SuperHotSearch shs ");
- Serializable[] serArr = new Serializable[hsIdList.size()];
- for (int i = 0; i < hsIdList.size(); i++) {
- if (i == 0) {
- sb.append(" where shs.hotSearch.id=? ");
- } else {
- sb.append(" or shs.hotSearch.id=? ");
- }
- serArr[i] = hsIdList.get(i);
- }
- String hql = sb.toString();
-
- return superHotSearchDao.list(hql, serArr);
-
- }
-
- public List<SuperHotSearch> getSuperHotSearchBySystemId(long id, int strat, int count) {
- return superHotSearchDao.list("from SuperHotSearch shs where shs.system.id=?", strat, count,
- new Serializable[] { id });
-
- }
-
- public List<SuperHotSearch> getSuperHotSearchBySystemId(long id, int strat, int count, String key) {
- return superHotSearchDao.list("from SuperHotSearch srs where srs.system.id=? and srs.hotSearch.name like ?",
- strat, count, new Serializable[] { id, key });
-
- }
@Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
public List<SuperHotSearch> listSuperHotSearch(List<Long> list) {
-
- List<SuperHotSearch> listObj = (List<SuperHotSearch>) superHotSearchDao.excute(new HibernateCallback<List<SuperHotSearch>>() {
- public List<SuperHotSearch> doInHibernate(Session session) throws HibernateException {
- Query query = session.createQuery("from SuperHotSearch srs where srs.hotSearch.id in (:array)");
- query.setParameterList("array",list);
- return query.list();
- }
- });
-
- return listObj;
+ if (list == null || list.size() == 0) {
+ return null;
+ }
+ return superHotSearchMapper.listByHotSearchListID(list);
}
-
- public Integer deleteSuperHotSearch(final long hsid, final String platform, final String packageName) {
- return (Integer) superHotSearchDao.excute(new HibernateCallback<Integer>() {
- public Integer doInHibernate(Session session) throws HibernateException {
- System system = systemService.getSystem(platform, packageName);
- Transaction transaction = session.beginTransaction();
- Query query = session
- .createQuery("delete SuperHotSearch shs " + " where shs.hotSearch.id=? and shs.system.id=?");
- query.setLong(0, hsid);
- query.setLong(1, system.getId());
- int i = query.executeUpdate();
- transaction.commit();
- return i;
- }
- });
- }
-
- public void addSuperHotSearch(long hsid, String platform, String packageName) {
- System system = systemService.getSystem(platform, packageName);
- SuperHotSearch superHotSearch = new SuperHotSearch();
- HotSearch hotSearch = new HotSearch();
- hotSearch.setId(hsid);
- superHotSearch.setHotSearch(hotSearch);
- superHotSearch.setSystem(system);
- superHotSearchDao.create(superHotSearch);
- }
-
- @Cacheable(value = "crgCache", key = "'getSuperHotSearchBySystemIdCache'+#id")
@Override
- public List<SuperHotSearch> getSuperHotSearchBySystemIdCache(long id) {
- return getSuperHotSearchBySystemId(id);
+ @Cacheable(value = "crgCache", key = "'getSuperHotSearchBySystemIdCache-'+#id+'-'+#useType")
+ public List<SuperHotSearch> getSuperHotSearchBySystemIdCache(long id, Integer useType) {
+ return getSuperHotSearchBySystemId(id, useType);
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public List<SuperHotSearch> getHotSearchSystem(Long id, Long systemId) {
-
- List<SuperHotSearch> listObj = (List<SuperHotSearch>) superHotSearchDao.excute(new HibernateCallback<List<SuperHotSearch>>() {
- public List<SuperHotSearch> doInHibernate(Session session) throws HibernateException {
-
- Query query = session.createQuery("from SuperHotSearch shs " + " where shs.hotSearch.id=? and shs.system.id=?");
- query.setLong(0, id);
- query.setLong(1,systemId);
-
- return query.list();
- }
- });
-
- return listObj;
+ return superHotSearchMapper.listBySystemIdAndHotSearchId(id, systemId);
}
@Override
- public Integer deleteSuper(Long id, Long systemId) {
- return (Integer) superHotSearchDao.excute(new HibernateCallback<Integer>() {
- public Integer doInHibernate(Session session) throws HibernateException {
- Transaction transaction = session.beginTransaction();
- Query query = session
- .createQuery("delete SuperHotSearch shs " + " where shs.hotSearch.id=? and shs.system.id=?");
- query.setLong(0, id);
- query.setLong(1, systemId);
- int i = query.executeUpdate();
- transaction.commit();
- return i;
- }
- });
+ public void deleteSuper(Long id, Long systemId) {
+ superHotSearchMapper.deleteBySystemIdAndHotSearchId(id,systemId);
}
@Override
- public void addSuper(Long id, System system) {
+ public void addSuper(Long id, BusinessSystem system) {
SuperHotSearch superHotSearch = new SuperHotSearch();
HotSearch hotSearch = new HotSearch();
hotSearch.setId(id);
superHotSearch.setHotSearch(hotSearch);
superHotSearch.setSystem(system);
- superHotSearchDao.create(superHotSearch);
+ superHotSearchMapper.insert(superHotSearch);
}
+
}
--
Gitblit v1.8.0