| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | 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.SuperRecommendSpecialDao;
|
| | | import com.yeshi.fanli.entity.bus.recommend.RecommendSpecial;
|
| | | import com.yeshi.fanli.dao.mybatis.goods.SuperRecommendSpecialMapper;
|
| | | import com.yeshi.fanli.entity.bus.su.recommend.SuperRecommendSpecial;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.SuperRecommendSpecialService;
|
| | |
|
| | | @Service
|
| | | public class SuperRecommendSpecialServiceImpl implements
|
| | | SuperRecommendSpecialService {
|
| | | public class SuperRecommendSpecialServiceImpl implements SuperRecommendSpecialService {
|
| | |
|
| | | @Resource
|
| | | private SuperRecommendSpecialDao superRecommendSpecialDao;
|
| | | |
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | | private SuperRecommendSpecialMapper superRecommendSpecialMapper;
|
| | |
|
| | | @Cacheable(value="specialCache",key="#root.methodName+#id")
|
| | | public List<SuperRecommendSpecial> getSuperRecommendSpecialBySystemId(
|
| | | long id) {
|
| | | |
| | | return superRecommendSpecialDao.list("from SuperRecommendSpecial srs where srs.system.id=? order by srs.recommendSpecial.orderby ", new Serializable[]{id});
|
| | | }
|
| | |
|
| | | public List<SuperRecommendSpecial> getSuperRecommendSpecials(
|
| | | List<Long> rsIdList) {
|
| | |
|
| | | if (rsIdList.size() == 0) {
|
| | | return new ArrayList<SuperRecommendSpecial>();
|
| | | }
|
| | | StringBuffer sb = new StringBuffer(" from SuperRecommendSpecial srs ");
|
| | | Serializable[] serArr = new Serializable[rsIdList.size()];
|
| | | for (int i = 0; i < rsIdList.size(); i++) {
|
| | | if (i == 0) {
|
| | | sb.append(" where srs.recommendSpecial.id=? ");
|
| | | } else {
|
| | | sb.append(" or srs.recommendSpecial.id=? ");
|
| | | }
|
| | | serArr[i] = rsIdList.get(i);
|
| | | }
|
| | | sb.append(" order by srs.recommendSpecial.orderby ");
|
| | | String hql = sb.toString();
|
| | |
|
| | | return superRecommendSpecialDao.list(hql, serArr);
|
| | |
|
| | | |
| | | }
|
| | |
|
| | | public Integer deleteSuperRecommendSpecial(final long rsid, final String platform,
|
| | | final String packageName) {
|
| | | return (Integer) superRecommendSpecialDao.excute(new HibernateCallback<Integer>() {
|
| | |
|
| | | public Integer doInHibernate(Session session)
|
| | | throws HibernateException {
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform, packageName);
|
| | | Transaction transaction = session.beginTransaction();
|
| | | Query query = session.createQuery("delete SuperRecommendSpecial srb "
|
| | | + " where srb.recommendSpecial.id=? and srb.system.id=?");
|
| | | query.setLong(0, rsid);
|
| | | query.setLong(1, system.getId());
|
| | | int i = query.executeUpdate();
|
| | | transaction.commit();
|
| | | return i ;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public void addSuperRecommendSpecial(long rsid, String platform,
|
| | | String packageName) {
|
| | |
|
| | | BusinessSystem system = businessSystemService.getBusinessSystem(platform,packageName);
|
| | | SuperRecommendSpecial superRecommendSpecial = new SuperRecommendSpecial();
|
| | | RecommendSpecial recommendSpecial = new RecommendSpecial();
|
| | | recommendSpecial.setId(rsid);
|
| | | superRecommendSpecial.setRecommendSpecial(recommendSpecial);
|
| | | superRecommendSpecial.setSystem(system);
|
| | | superRecommendSpecialDao.create(superRecommendSpecial);
|
| | | |
| | | }
|
| | |
|
| | | public void deleteSuperRecommendSpecials(final long[] rsids) {
|
| | | superRecommendSpecialDao.excute(new HibernateCallback() {
|
| | |
|
| | | public Object doInHibernate(Session session) throws HibernateException {
|
| | | |
| | | StringBuffer sb = new StringBuffer("delete from SuperRecommendSpecial s ");
|
| | | for (int i = 0; i < rsids.length; i++) {
|
| | | if(i==0){
|
| | | sb.append(" where s.recommendSpecial.id=? ");
|
| | | }else{
|
| | | sb.append(" or s.recommendSpecial.id=?");
|
| | | }
|
| | | }
|
| | | Query query = session.createQuery(sb.toString());
|
| | | for (int i = 0; i < rsids.length; i++) {
|
| | | query.setLong(i, rsids[i]);
|
| | | }
|
| | | int ii = query.executeUpdate();
|
| | | java.lang.System.out.println(ii);
|
| | | return null;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public List<SuperRecommendSpecial> getSuperRecommendSpecialBySystemId(
|
| | | long id, int start, int count) {
|
| | | |
| | | return superRecommendSpecialDao.list("from SuperRecommendSpecial srs where srs.system.id=? order by srs.recommendSpecial.orderby ",start,count,new Serializable[]{id});
|
| | | |
| | | }
|
| | |
|
| | | public List<SuperRecommendSpecial> getSuperRecommendSpecialBySystemId(
|
| | | long id, int start, int count, String key) {
|
| | | return superRecommendSpecialDao.list("from SuperRecommendSpecial srs where srs.system.id=? and srs.recommendSpecial.name like ? order by srs.recommendSpecial.orderby ",start,count,new Serializable[]{id, key});
|
| | | |
| | | public List<SuperRecommendSpecial> getSuperRecommendSpecialBySystemId(long systemId) {
|
| | | return superRecommendSpecialMapper.listBySystemId(systemId);
|
| | | }
|
| | |
|
| | | }
|