bug--dto重命名以及部门判断

This commit is contained in:
taochengbo
2020-05-17 15:55:14 +08:00
parent c823316b56
commit 1a503373e6
21 changed files with 121 additions and 106 deletions

View File

@ -18,6 +18,7 @@ import co.yixiang.modules.system.service.DeptService;
import co.yixiang.modules.system.service.dto.DeptDto;
import co.yixiang.modules.system.service.dto.DeptQueryCriteria;
import co.yixiang.utils.ThrowableUtil;
import co.yixiang.utils.ValidationUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -91,6 +92,13 @@ public class DeptController {
@PutMapping
@PreAuthorize("@el.check('admin','dept:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody Dept resources){
if(resources.getId().equals(resources.getPid())) {
throw new BadRequestException("上级不能为自己");
}
Dept dept = deptService.getOne(new QueryWrapper<Dept>().lambda()
.eq(Dept::getId,resources.getId()));
ValidationUtil.isNull( dept.getId(),"Dept","id",resources.getId());
resources.setId(dept.getId());
deptService.saveOrUpdate(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}