package com.yeshi.fanli.service.impl.config;
|
|
import java.io.Serializable;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
import javax.transaction.Transactional;
|
|
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.stereotype.Service;
|
|
import com.yeshi.fanli.dao.config.JumpDetailDao;
|
import com.yeshi.fanli.entity.common.JumpDetail;
|
import com.yeshi.fanli.exception.NotExistObjectException;
|
import com.yeshi.fanli.service.inter.config.JumpDetailService;
|
import com.yeshi.fanli.service.inter.goods.RecommendBannerService;
|
import com.yeshi.fanli.service.inter.goods.RecommendSpecialService;
|
import com.yeshi.fanli.util.Constant;
|
|
@Service
|
public class JumpDetailServiceImpl implements JumpDetailService {
|
|
@Resource
|
private JumpDetailDao jumpDetailDao;
|
|
@Resource
|
private RecommendBannerService recommendBannerService;
|
|
@Resource
|
private RecommendSpecialService recommendSpecialService;
|
|
public List<JumpDetail> getJumpDetailList(int index, String key) {
|
|
int start = index * Constant.PAGE_SIZE;
|
|
return jumpDetailDao.list("from JumpDetail j where j.name like ? ", start, Constant.PAGE_SIZE,
|
new Serializable[] { "%" + key + "%" });
|
}
|
|
public int getCount(String key) {
|
Long lcount = jumpDetailDao.getCount("select count(j.id) from JumpDetail j where j.name like ? ",
|
new Serializable[] { "%" + key + "%" });
|
return lcount.intValue();
|
}
|
|
public void addJumpDetail(JumpDetail jd) {
|
jumpDetailDao.create(jd);
|
}
|
|
public void updateJumpDetail(JumpDetail jd) throws NotExistObjectException {
|
JumpDetail find = jumpDetailDao.find(JumpDetail.class, jd.getId());
|
if (find == null) {
|
throw new NotExistObjectException("不存在该对象");
|
}
|
jumpDetailDao.update(jd);
|
}
|
|
public JumpDetail getJumpDetail(long id) {
|
return jumpDetailDao.find(JumpDetail.class, id);
|
}
|
|
@Transactional
|
public void deleteJumpDetail(long id) {
|
recommendBannerService.updateBannerJumpDetail(id);
|
recommendSpecialService.updateSpecialJumpDetail(id);
|
jumpDetailDao.delete(new JumpDetail(id));
|
}
|
|
public List<JumpDetail> getJumpDetailAllList() {
|
return jumpDetailDao.list("from JumpDetail");
|
}
|
|
public JumpDetail getlastJumpDetail() {
|
|
List<JumpDetail> list = jumpDetailDao.list("from JumpDetail jp order by jp.id desc ", 0, 1, null);
|
if (list.size() > 0) {
|
return list.get(0);
|
}
|
return null;
|
}
|
|
@Cacheable(value = "configCache", key = "'getlastJumpDetailCache'")
|
@Override
|
public JumpDetail getlastJumpDetailCache() {
|
return getlastJumpDetail();
|
}
|
|
}
|