| | |
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SwiperPictureMapper;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.exception.NotExistObjectException;
|
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | @Service
|
| | | public class SwiperPictureServiceImpl implements SwiperPictureService {
|
| | |
|
| | | @Resource
|
| | | private SwiperPictureMapper swiperPictureMapper;
|
| | | |
| | | @Resource
|
| | | private SystemConfigService systemConfigService;
|
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) throws SwiperPictureException{
|
| | |
| | | return swiperPictureMapper.countQueryByBannerID(bannerId);
|
| | | }
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public void save(SwiperPicture record) throws SwiperPictureException{
|
| | | |
| | | if (record == null) {
|
| | | throw new SwiperPictureException(1, "参数不能为空");
|
| | | }
|
| | | |
| | | Long bannerId = record.getBannerId();
|
| | | if (bannerId == null) {
|
| | | throw new SwiperPictureException(1, "标识管理ID不能为空");
|
| | | }
|
| | | |
| | | String params = record.getParams();
|
| | | if (!StringUtil.isNullOrEmpty(params)) {
|
| | | try {
|
| | | String jumpValue = systemConfigService.get("jump");
|
| | | if (StringUtil.isNullOrEmpty(jumpValue)) {
|
| | | jumpValue = "{\"url\":\"#\"}";
|
| | | }
|
| | | params = jumpValue.replace("#", params);
|
| | | |
| | | } catch (NotExistObjectException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | Long id = record.getId();
|
| | | |
| | | if (id == null) {
|
| | | // 新增
|
| | | |
| | | int maxOrder = swiperPictureMapper.getMaxOrderByBannerID(bannerId);
|
| | | record.setOrder(maxOrder + 1);
|
| | | // 默认停用
|
| | | record.setState(1);
|
| | | // 默认非系统控制
|
| | | record.setAutoControl(1);
|
| | | // 默认非登陆
|
| | | record.setJumpNeedLogin(false);
|
| | | record.setCreatetime(new Date());
|
| | | record.setUpdatetime(new Date());
|
| | | |
| | | swiperPictureMapper.insert(record);
|
| | | } else {
|
| | | // 修改
|
| | | SwiperPicture resultObj = swiperPictureMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | throw new SwiperPictureException(1, "参数不能为空");
|
| | | }
|
| | | |
| | | record.setOrder(resultObj.getOrder());
|
| | | record.setCreatetime(resultObj.getCreatetime());
|
| | | record.setUpdatetime(new Date());
|
| | | swiperPictureMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException{
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerCard-'+#card")
|
| | | public List<SwiperPicture> getByBannerCard(String card) throws SwiperPictureException {
|
| | | return swiperPictureMapper.getByBannerCard(card);
|
| | | }
|