Commit 65afa85c authored by 高滢's avatar 高滢

样品有相关任务禁止删除

parent dace5792
......@@ -22,4 +22,6 @@ public interface TaskSampleRelationMapper extends BaseMapper<TaskSampleRelation>
/**
* 根据样品id查询*/
List<SampleTaskVo> selectTaskBysampleId(@Param("idList") List<Long> idList);
public int selectTaskSumBySampleId(@Param("sampleId") Long sampleId);
}
......@@ -3,7 +3,9 @@ package com.ruoyi.web;
import java.util.List;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.domain.Sample;
import com.ruoyi.mapper.TaskSampleRelationMapper;
import com.ruoyi.service.SampleManagementService;
import com.ruoyi.web.request.SampleManagementGetInfoRequest;
import com.ruoyi.web.request.SampleManagementRequest;
......@@ -35,6 +37,9 @@ public class SampleManagementController extends BaseController
@Autowired
private SampleManagementService sampleManagementService;
@Autowired
private TaskSampleRelationMapper taskSampleRelationMapper;
/**
* 查询样品管理列表
*/
......@@ -99,6 +104,10 @@ public class SampleManagementController extends BaseController
@PostMapping ("/del")
public AjaxResult remove(@Validated @RequestBody SampleManagementGetInfoRequest request)
{
int num = taskSampleRelationMapper.selectTaskSumBySampleId(request.getId());
if(num>0){
throw new ServiceException("已有相关任务,不允许删除");
}
return toAjax(sampleManagementService.removeById(request.getId()));
}
......
......@@ -39,4 +39,12 @@
#{id}
</foreach>
</select>
<select id="selectTaskSumBySampleId">
select
count(task_id)
FROM
t_task_sample_relation
where sample_id = #{sampleId}
</select>
</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