Commit 291245f3 by zhangkb

修改删除指标评分逻辑,关联了指标的评分无法删除

parent d8829128
...@@ -74,8 +74,8 @@ public class IndScorecardCtrl { ...@@ -74,8 +74,8 @@ public class IndScorecardCtrl {
@ApiOperation(value = "删除", notes = "删除") @ApiOperation(value = "删除", notes = "删除")
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
public void delete(@RequestBody List<Integer> ids) { public String delete(@RequestBody List<Integer> ids) {
indScorecardService.delete(ids); return indScorecardService.delete(ids);
} }
@ApiOperation(value = "获取所有评分卡", notes = "获取所有评分卡") @ApiOperation(value = "获取所有评分卡", notes = "获取所有评分卡")
......
...@@ -20,4 +20,6 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{ ...@@ -20,4 +20,6 @@ public interface DriveIndDefMapper extends BaseMapper<DriveIndDef>{
public String getMaxIndId(@Param("code")String code,@Param("length")int length); public String getMaxIndId(@Param("code")String code,@Param("length")int length);
public List<DriveIndDef> getByIdList(@Param("ids")List<String> ids); public List<DriveIndDef> getByIdList(@Param("ids")List<String> ids);
public List<DriveIndDef> getByScorecardId(@Param("scorecardId")Integer scorecardId);
} }
...@@ -218,4 +218,9 @@ public class DriveIndDefService { ...@@ -218,4 +218,9 @@ public class DriveIndDefService {
} }
return maxId; return maxId;
} }
//根据指标评分规则id获取考核指标
public List<DriveIndDef> getByScorecardId(Integer scorecardId){
return driveIndDefMapper.getByScorecardId(scorecardId);
}
} }
...@@ -71,10 +71,23 @@ public class IndScorecardService { ...@@ -71,10 +71,23 @@ public class IndScorecardService {
return indScorecard.getId(); return indScorecard.getId();
} }
public void delete(List<Integer> ids) { public String delete(List<Integer> ids) {
StringBuilder message = new StringBuilder("");
for(Integer id : ids) { for(Integer id : ids) {
indScorecardMapper.deleteByPrimaryKey(id); if(!driveIndDefService.getByScorecardId(id).isEmpty()) {
IndScorecard scorecard = this.findById(id);
if(scorecard!=null) {
message.append("'").append(scorecard.getCardName())
.append("'").append("关联了考核指标,无法删除;");
}
}else {
indScorecardMapper.deleteByPrimaryKey(id);
}
}
if(StringUtils.isBlank(message.toString())) {
message.append("删除成功");
} }
return message.toString();
} }
public List<IndScorecard> getAll(){ public List<IndScorecard> getAll(){
......
...@@ -49,4 +49,10 @@ ...@@ -49,4 +49,10 @@
#{id} #{id}
</foreach> </foreach>
</select> </select>
<select id="getByScorecardId" parameterType="java.lang.Integer" resultType="com.keymobile.indicators.model.entity.indicators.DriveIndDef">
select *
from drive_ind_def
where ind_cal_score_rule=#{scorecardId}
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment