|
|
|
package com.glxp.api.controller.auth;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
|
import com.glxp.api.annotation.Log;
|
|
|
|
import com.glxp.api.constant.BusinessType;
|
|
|
|
import com.glxp.api.entity.auth.DeptEntity;
|
|
|
|
import com.glxp.api.entity.auth.DeptUserEntity;
|
|
|
|
import com.glxp.api.entity.inout.IoOrderEntity;
|
|
|
|
import com.glxp.api.req.auth.FilterDeptUserReqeust;
|
|
|
|
import com.glxp.api.req.auth.FilterInvWarehouseRequest;
|
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
|
import com.glxp.api.res.auth.DeptUserResponse;
|
|
|
|
import com.glxp.api.service.auth.DeptService;
|
|
|
|
import com.glxp.api.service.auth.DeptUserService;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
|
import com.glxp.api.service.auth.WarehouseUserService;
|
|
|
|
import com.glxp.api.service.inout.IoOrderService;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
public class DeptUserController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
DeptUserService deptUserService;
|
|
|
|
@Resource
|
|
|
|
DeptService deptService;
|
|
|
|
@Resource
|
|
|
|
IoOrderService ioOrderService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
WarehouseUserService warehouseUserService;
|
|
|
|
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@GetMapping("udi/auth/dept/user/filter")
|
|
|
|
public BaseResponse filterList(FilterDeptUserReqeust filterDeptUserReqeust) {
|
|
|
|
//获取部门id
|
|
|
|
Long idByCode = deptService.getIdByCode(filterDeptUserReqeust.getDeptId());
|
|
|
|
DeptEntity deptEntity = deptService.selectById(idByCode + "");
|
|
|
|
if (deptEntity.getLevel() == 1) {
|
|
|
|
filterDeptUserReqeust.setDeptId(null);
|
|
|
|
} else {
|
|
|
|
filterDeptUserReqeust.setDeptId(idByCode);
|
|
|
|
}
|
|
|
|
List<DeptUserResponse> deptEntityList = deptUserService.selectJoinDeptUser(filterDeptUserReqeust);
|
|
|
|
PageInfo<DeptUserResponse> pageInfo = new PageInfo<>(deptEntityList);
|
|
|
|
PageSimpleResponse<DeptUserResponse> deptEntityPageSimpleResponse = new PageSimpleResponse<>();
|
|
|
|
deptEntityPageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
|
deptEntityPageSimpleResponse.setList(deptEntityList);
|
|
|
|
return ResultVOUtils.success(deptEntityPageSimpleResponse);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@PostMapping("udi/auth/dept/user/delete")
|
|
|
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
|
|
|
public BaseResponse delete(@RequestBody DeptUserEntity deptUserEntity) {
|
|
|
|
// 判断此用户是否创建单据
|
|
|
|
List<IoOrderEntity> ioOrderEntities = ioOrderService.selectList(deptUserEntity.getUserId());
|
|
|
|
if( ioOrderEntities != null && ioOrderEntities.size() != 0 ){
|
|
|
|
return ResultVOUtils.error(500,"该用户已创建单据,不能移除!");
|
|
|
|
}
|
|
|
|
//判断此用户是否与仓库有关联
|
|
|
|
List<String> listWareHouse = warehouseUserService.selectCodeByUser(deptUserEntity.getUserId() + "");
|
|
|
|
if( listWareHouse != null && listWareHouse.size() != 0){
|
|
|
|
return ResultVOUtils.error(500,"该用户已绑定仓库,不能移除!");
|
|
|
|
}
|
|
|
|
|
|
|
|
//判断此用户是否与除一级部门 还绑定其他部门
|
|
|
|
FilterDeptUserReqeust filterDeptUserReqeust = new FilterDeptUserReqeust();
|
|
|
|
filterDeptUserReqeust.setUserId(deptUserEntity.getUserId());
|
|
|
|
List<DeptUserEntity> deptUserEntities = deptUserService.selectDeptUser(filterDeptUserReqeust);
|
|
|
|
if( deptUserEntities != null && deptUserEntities.size()>1){
|
|
|
|
return ResultVOUtils.error(500,"该用户已绑定多个部门,不能移除!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean b = deptUserService.delete(deptUserEntity.getDeptId(), deptUserEntity.getUserId());
|
|
|
|
if (b)
|
|
|
|
return ResultVOUtils.success("移除成功!");
|
|
|
|
return ResultVOUtils.error(500, "移除失败!");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|