| | |
| | | package com.yeshi.fanli.service.impl.homemodule;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.AdActivityVersionControlMapper;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
|
| | |
|
| | | @Service
|
| | | public class AdActivityVersionControlServiceImpl implements AdActivityVersionControlService {
|
| | |
|
| | | @Resource
|
| | | private AdActivityVersionControlMapper adActivityVersionControlMapper;
|
| | |
|
| | | @Override
|
| | | public void addVersionControl(AdActivityVersionControl control) throws Exception {
|
| | | if (control == null || control.getSourceId() == null || control.getType() == null
|
| | | || control.getVersion() == null)
|
| | | throw new Exception("数据不完整");
|
| | |
|
| | | AdActivityVersionControl oldControl = adActivityVersionControlMapper.selectBySourceIdAndTypeAndVersion(
|
| | | control.getSourceId(), control.getType(), control.getVersion().getId());
|
| | | if (oldControl != null)
|
| | | throw new Exception("不能重复添加");
|
| | |
|
| | | if (control.getCreateTime() == null)
|
| | | control.setCreateTime(new Date());
|
| | | adActivityVersionControlMapper.insertSelective(control);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteByPrimaryKey(Long id) {
|
| | | adActivityVersionControlMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<AdActivityVersionControl> listByTypeAndSourceId(AdActivityType type, Long sourceId) {
|
| | | if (type == null || sourceId == null)
|
| | | return null;
|
| | | return adActivityVersionControlMapper.listByTypeAndSourceId(type, sourceId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, Long appVersionId) {
|
| | | if (sourceIdList == null || sourceIdList.size() == 0)
|
| | | return null;
|
| | |
|
| | | if (type == null || appVersionId == null)
|
| | | return null;
|
| | |
|
| | | List<AdActivityVersionControl> list = adActivityVersionControlMapper.listByVersionAndSourceId(sourceIdList,
|
| | | type, appVersionId);
|
| | | List<Long> resultList = new ArrayList<>();
|
| | | if (list != null)
|
| | | for (AdActivityVersionControl control : list)
|
| | | if(control!=null&&control.getSourceId()!=null)
|
| | | resultList.add(control.getSourceId());
|
| | |
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.homemodule; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.homemodule.AdActivityVersionControlMapper; |
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl; |
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType; |
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService; |
| | | |
| | | @Service |
| | | public class AdActivityVersionControlServiceImpl implements AdActivityVersionControlService { |
| | | |
| | | @Resource |
| | | private AdActivityVersionControlMapper adActivityVersionControlMapper; |
| | | |
| | | @Override |
| | | public void addVersionControl(AdActivityVersionControl control) throws Exception { |
| | | if (control == null || control.getSourceId() == null || control.getType() == null |
| | | || control.getVersion() == null) |
| | | throw new Exception("数据不完整"); |
| | | |
| | | AdActivityVersionControl oldControl = adActivityVersionControlMapper.selectBySourceIdAndTypeAndVersion( |
| | | control.getSourceId(), control.getType(), control.getVersion().getId()); |
| | | if (oldControl != null) |
| | | throw new Exception("不能重复添加"); |
| | | |
| | | if (control.getCreateTime() == null) |
| | | control.setCreateTime(new Date()); |
| | | adActivityVersionControlMapper.insertSelective(control); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByPrimaryKey(Long id) { |
| | | adActivityVersionControlMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<AdActivityVersionControl> listByTypeAndSourceId(AdActivityType type, Long sourceId) { |
| | | if (type == null || sourceId == null) |
| | | return null; |
| | | return adActivityVersionControlMapper.listByTypeAndSourceId(type, sourceId); |
| | | } |
| | | |
| | | @Override |
| | | public Set<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList) { |
| | | if (sourceIdList == null || sourceIdList.size() == 0) |
| | | return null; |
| | | |
| | | if (type == null || versionIdList == null) |
| | | return null; |
| | | |
| | | List<AdActivityVersionControl> list = adActivityVersionControlMapper.listByVersionAndSourceId(sourceIdList, |
| | | type, versionIdList); |
| | | Set<Long> resultList = new HashSet<>(); |
| | | if (list != null) |
| | | for (AdActivityVersionControl control : list) |
| | | if (control != null && control.getSourceId() != null) |
| | | resultList.add(control.getSourceId()); |
| | | |
| | | return resultList; |
| | | } |
| | | |
| | | @Override |
| | | public void deleteBySourceAndVersion(Long sourceId, AdActivityType type, Long version) { |
| | | AdActivityVersionControl control = adActivityVersionControlMapper.selectBySourceIdAndTypeAndVersion(sourceId, |
| | | type, version); |
| | | if (control != null) |
| | | deleteByPrimaryKey(control.getId()); |
| | | } |
| | | |
| | | } |