更新删除类型接口的参数

This commit is contained in:
panshuling321 2022-03-04 10:15:17 +08:00
parent 412bc9660e
commit 67466d5ba0
4 changed files with 24 additions and 7 deletions

View File

@ -94,9 +94,9 @@ public class WorkTypeController extends BaseController {
@DeleteMapping("/detail")
@DeleteMapping("/{typeId}")
@Log(title = "工单类型-删除工单类型", businessType = BusinessType.DELETE)
public R deleteTypeInfo(@RequestParam Integer typeId){
public R deleteTypeInfo(@PathVariable("typeId") Integer typeId){
return R.ok(typeService.deleteTypeInfo(typeId));
}

View File

@ -28,17 +28,17 @@ public class XhpcWorkTypeDictDomain implements Serializable {
/**
* 状态0-禁用1-启用
*/
private Integer status;
private Integer status = 1;
/**
* 删除标识0-正常2-已删除
*/
private Integer delFlag;
private Integer delFlag = 0;
/**
* 排序
*/
private Integer sort;
private Integer sort = 0;
/**
* 租户ID

View File

@ -8,6 +8,7 @@ import com.xhpc.workorder.service.WorkTypeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -77,8 +78,13 @@ public class WorkTypeServiceImpl implements WorkTypeService {
if(StringUtils.isEmpty(domain.getName())){
throw new CustomException("名称不能为空");
}
if(domain.getWorkTypeId().equals(domain.getParentTypeId())){
throw new CustomException("自身不能成为自身的子集");
}
XhpcWorkTypeDictDomain exitsDomain = typeDictMapper.selectByName(domain.getName());
if(exitsDomain != null) {
if(exitsDomain != null && !exitsDomain.getWorkTypeId().equals(domain.getWorkTypeId())) {
throw new CustomException("名称不能重复");
}
return typeDictMapper.updateByPrimaryKeySelective(domain) > 0;
@ -87,6 +93,14 @@ public class WorkTypeServiceImpl implements WorkTypeService {
@Override
public Boolean deleteTypeInfo(Integer typeId){
Map<String, Object> params = new HashMap<>();
params.put("parentTypeId", typeId);
List<Map<String, Object>> typeList = typeDictMapper.selectMapListByParentParams(params);
if(typeList.size() > 0){
throw new CustomException("存在类型子集,请先移除下级问题类型");
}
return typeDictMapper.deleteByPrimaryKeyLogic(typeId) > 0;
}
}

View File

@ -42,7 +42,9 @@
<select id="selectMapListByParentParams" resultType="map">
select
work_type_id as 'id',
name as 'name'
name as 'name',
sort as 'sort',
parent_type_id as 'parentId'
from xhpc_work_type_dict
where del_flag = 0 and status = 1
<if test="params.tenantId !=null and params.tenantId!=''">
@ -56,6 +58,7 @@
and (parent_type_id is null or parent_type_id='')
</otherwise>
</choose>
order by sort desc, work_type_id asc
</select>