| | |
| | | package com.yeshi.fanli.service.impl.homemodule;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SpecialLabelMapMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SpecialLabelMapper;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SpecialLabel;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SpecialLabelMap;
|
| | | import com.yeshi.fanli.exception.homemodule.SpecialLabelException;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialLabelService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | | public class SpecialLabelImpl implements SpecialLabelService {
|
| | |
|
| | | @Resource
|
| | | private SpecialLabelMapper specialLabelMapper;
|
| | | |
| | | @Resource
|
| | | private SpecialLabelMapMapper specialLabelMapMapper;
|
| | | |
| | | |
| | | @Override
|
| | | public void save(SpecialLabel record) throws SpecialLabelException{
|
| | | String name = record.getName();
|
| | | if (StringUtil.isNullOrEmpty(name))
|
| | | throw new SpecialLabelException(1, "名称不能为空");
|
| | | |
| | | String bgColor = record.getBgColor();
|
| | | if (StringUtil.isNullOrEmpty(bgColor))
|
| | | throw new SpecialLabelException(1, "背景色不能为空");
|
| | | |
| | | if (record.getState() == null)
|
| | | record.setState(0);
|
| | | |
| | | record.setUpdateTime(new Date());
|
| | | |
| | | Long id = record.getId();
|
| | | if (id == null) {
|
| | | record.setCreateTime(new Date());
|
| | | specialLabelMapper.insert(record);
|
| | | } else {
|
| | | SpecialLabel resultObj = specialLabelMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null)
|
| | | throw new SpecialLabelException(1, "操作内容已不存在");
|
| | |
|
| | | record.setCreateTime(resultObj.getCreateTime());
|
| | | specialLabelMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKeyBatch(List<Long> list){
|
| | | return specialLabelMapper.deleteByPrimaryKeyBatch(list);
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | @Override
|
| | | public List<SpecialLabel> listQuery(long start, int count, String key, Integer state) {
|
| | | return specialLabelMapper.listQuery(start, count, key, state);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public long countQuery(String key, Integer state) {
|
| | | return specialLabelMapper.countQuery(key, state);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SpecialLabel> getLabelsBySpecialId(Long specialId) {
|
| | | return specialLabelMapper.getLabelsBySpecialId(specialId);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor= Exception.class)
|
| | | public void stickLabelOnSpecial(List<Long> idList, List<Long> labIdList) {
|
| | | if (idList == null || idList.isEmpty())
|
| | | return;
|
| | | |
| | | // 清空标签
|
| | | specialLabelMapMapper.deleteBySpecialIds(idList);
|
| | | |
| | | if (labIdList == null || labIdList.isEmpty()) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 新增标签
|
| | | Date date = new Date();
|
| | | for (Long id:idList) {
|
| | | for (Long labid:labIdList) {
|
| | | SpecialLabelMap objectMap = new SpecialLabelMap();
|
| | | objectMap.setLabId(labid);
|
| | | objectMap.setSpid(id);
|
| | | objectMap.setCreateTime(date);
|
| | | specialLabelMapMapper.insertSelective(objectMap);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | package com.yeshi.fanli.service.impl.homemodule; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SpecialLabelMapMapper; |
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SpecialLabelMapper; |
| | | import com.yeshi.fanli.entity.bus.homemodule.SpecialLabel; |
| | | import com.yeshi.fanli.entity.bus.homemodule.SpecialLabelMap; |
| | | import com.yeshi.fanli.exception.homemodule.SpecialLabelException; |
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialLabelService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | @Service |
| | | public class SpecialLabelImpl implements SpecialLabelService { |
| | | |
| | | @Resource |
| | | private SpecialLabelMapper specialLabelMapper; |
| | | |
| | | @Resource |
| | | private SpecialLabelMapMapper specialLabelMapMapper; |
| | | |
| | | |
| | | @Override |
| | | public void save(SpecialLabel record) throws SpecialLabelException{ |
| | | String name = record.getName(); |
| | | if (StringUtil.isNullOrEmpty(name)) |
| | | throw new SpecialLabelException(1, "名称不能为空"); |
| | | |
| | | String bgColor = record.getBgColor(); |
| | | if (StringUtil.isNullOrEmpty(bgColor)) |
| | | throw new SpecialLabelException(1, "背景色不能为空"); |
| | | |
| | | if (record.getState() == null) |
| | | record.setState(0); |
| | | |
| | | record.setUpdateTime(new Date()); |
| | | |
| | | Long id = record.getId(); |
| | | if (id == null) { |
| | | record.setCreateTime(new Date()); |
| | | specialLabelMapper.insert(record); |
| | | } else { |
| | | SpecialLabel resultObj = specialLabelMapper.selectByPrimaryKey(id); |
| | | if (resultObj == null) |
| | | throw new SpecialLabelException(1, "操作内容已不存在"); |
| | | |
| | | record.setCreateTime(resultObj.getCreateTime()); |
| | | specialLabelMapper.updateByPrimaryKey(record); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void switchState(Long id) throws SpecialLabelException { |
| | | if (id == null) { |
| | | throw new SpecialLabelException(1, "请传递正确参数"); |
| | | } |
| | | |
| | | SpecialLabel resultObj = specialLabelMapper.selectByPrimaryKey(id); |
| | | if (resultObj == null) { |
| | | throw new SpecialLabelException(1, "此内容已不存在"); |
| | | } |
| | | |
| | | Integer state = resultObj.getState(); |
| | | if (state == null || state == 0) { |
| | | state = 1; |
| | | } else { |
| | | state = 0; |
| | | } |
| | | |
| | | SpecialLabel updateObj = new SpecialLabel(); |
| | | updateObj.setId(id); |
| | | updateObj.setState(state); |
| | | specialLabelMapper.updateByPrimaryKeySelective(updateObj); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int deleteByPrimaryKeyBatch(List<Long> list){ |
| | | return specialLabelMapper.deleteByPrimaryKeyBatch(list); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<SpecialLabel> listQuery(long start, int count, String key, Integer state) { |
| | | return specialLabelMapper.listQuery(start, count, key, state); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long countQuery(String key, Integer state) { |
| | | return specialLabelMapper.countQuery(key, state); |
| | | } |
| | | |
| | | @Override |
| | | public List<SpecialLabel> getLabelsBySpecialId(Long specialId) { |
| | | return specialLabelMapper.getLabelsBySpecialId(specialId); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor= Exception.class) |
| | | public void stickLabelOnSpecial(List<Long> idList, List<Long> labIdList) { |
| | | if (idList == null || idList.isEmpty()) |
| | | return; |
| | | |
| | | // 清空标签 |
| | | specialLabelMapMapper.deleteBySpecialIds(idList); |
| | | |
| | | if (labIdList == null || labIdList.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | // 新增标签 |
| | | Date date = new Date(); |
| | | for (Long id:idList) { |
| | | for (Long labid:labIdList) { |
| | | SpecialLabelMap objectMap = new SpecialLabelMap(); |
| | | objectMap.setLabId(labid); |
| | | objectMap.setSpid(id); |
| | | objectMap.setCreateTime(date); |
| | | specialLabelMapMapper.insertSelective(objectMap); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |