微调
This commit is contained in:
@@ -2,6 +2,9 @@ package com.njcn.gather.source.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -9,5 +12,12 @@ import com.njcn.gather.source.pojo.po.PqSource;
|
||||
*/
|
||||
public interface PqSourceMapper extends MPJBaseMapper<PqSource> {
|
||||
|
||||
/**
|
||||
* 根据ids获取绑定的计划数量
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
Integer getCountBoundByIds(@Param("ids") List<String> ids);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,16 @@
|
||||
<mapper namespace="com.njcn.gather.source.mapper.PqSourceMapper">
|
||||
|
||||
|
||||
<select id="getCountBoundByIds" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) FROM ad_plan_source
|
||||
<if test="ids!= null and ids.size() > 0">
|
||||
<where>
|
||||
and Source_Id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.source.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-10
|
||||
*/
|
||||
@Getter
|
||||
public enum SourceResponseEnum {
|
||||
SOURCE_BOUND_NOT_DELETE("A030001", "源已被计划所绑定,无法删除!");
|
||||
|
||||
private String code;
|
||||
private String message;
|
||||
|
||||
SourceResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.source.mapper.PqSourceMapper;
|
||||
import com.njcn.gather.source.pojo.enums.SourceResponseEnum;
|
||||
import com.njcn.gather.source.pojo.param.PqSourceParam;
|
||||
import com.njcn.gather.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.source.pojo.po.SourceInitialize;
|
||||
@@ -85,6 +86,10 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean deletePqSource(List<String> ids) {
|
||||
Integer count = this.baseMapper.getCountBoundByIds(ids);
|
||||
if(count > 0){
|
||||
throw new BusinessException(SourceResponseEnum.SOURCE_BOUND_NOT_DELETE);
|
||||
}
|
||||
return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user