|
@@ -7,11 +7,13 @@ import com.cdf.common.ResultCode;
|
|
|
import com.cdf.common.ResultData;
|
|
|
import com.cdf.entity.Dept;
|
|
|
import com.cdf.entity.Menu;
|
|
|
+import com.cdf.entity.Shop;
|
|
|
import com.cdf.entity.User;
|
|
|
import com.cdf.exception.BusinessException;
|
|
|
import com.cdf.response.DeptVo;
|
|
|
import com.cdf.response.MenuVo;
|
|
|
import com.cdf.service.IDeptService;
|
|
|
+import com.cdf.service.IShopService;
|
|
|
import com.cdf.service.IUserService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -33,6 +35,8 @@ public class SysDeptController {
|
|
|
private IDeptService deptService;
|
|
|
@Autowired
|
|
|
private IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private IShopService shopService;
|
|
|
|
|
|
@PostMapping("/saveOrUpdate")
|
|
|
@SysLog(logType = "组织架构",value = "新增或修改")
|
|
@@ -60,7 +64,13 @@ public class SysDeptController {
|
|
|
queryWrapper.eq(User::getDeptId,dept.getId());
|
|
|
long count = userService.count(queryWrapper);
|
|
|
if(count > 0){
|
|
|
- throw new BusinessException(ResultCode.NOT_DELETE_DEPT);
|
|
|
+ throw new BusinessException(ResultCode.NOT_DELETE_DEPT_USER);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<Shop> shopWrapper = new LambdaQueryWrapper<>();
|
|
|
+ shopWrapper.eq(Shop::getDeptId,dept.getId());
|
|
|
+ long shopCount = shopService.count(shopWrapper);
|
|
|
+ if(shopCount > 0){
|
|
|
+ throw new BusinessException(ResultCode.NOT_DELETE_DEPT_SHOP);
|
|
|
}
|
|
|
deptService.removeById(dept.getId());
|
|
|
return ResultData.ok();
|