package org.jeecg.modules.dnc.controller;
|
|
import cn.hutool.core.util.StrUtil;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.shiro.SecurityUtils;
|
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.modules.dnc.entity.ProductInfo;
|
import org.jeecg.modules.dnc.response.CommonCode;
|
import org.jeecg.modules.dnc.response.CommonGenericTree;
|
import org.jeecg.modules.dnc.response.QueryListResponseResult;
|
import org.jeecg.modules.dnc.response.ResponseResult;
|
import org.jeecg.modules.dnc.service.IProductInfoService;
|
import org.jeecg.modules.dnc.ucenter.Department;
|
import org.jeecg.modules.dnc.ucenter.UserDepartExt;
|
import org.jeecg.modules.dnc.utils.ValidateUtil;
|
import org.jeecg.modules.system.entity.MdcProduction;
|
import org.jeecg.modules.system.entity.SysUser;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.Collections;
|
import java.util.List;
|
@Slf4j
|
@Api(tags = "产品表")
|
@RestController
|
@RequestMapping("/nc/product")
|
public class ProductInfoController extends JeecgController<ProductInfo, IProductInfoService> {
|
|
@Autowired
|
private IProductInfoService productInfoService;
|
|
@AutoLog(value = "产品表-新增产品信息")
|
@ApiOperation(value = "产品表-新增产品信息", notes = "产品表-新增产品信息")
|
@PostMapping("/add")
|
public ResponseResult addProductInfo(@RequestBody ProductInfo productInfo) {
|
boolean b = productInfoService.addProductInfo(productInfo);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "产品表-编辑产品信息")
|
@ApiOperation(value = "产品表-编辑产品信息", notes = "产品表-编辑产品信息")
|
@PutMapping("/edit/{id}")
|
public ResponseResult editProductInfo(@PathVariable("id") String id,@RequestBody ProductInfo productInfo) {
|
boolean b = productInfoService.editProductInfo(id, productInfo);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "产品表-获取产品结构树接口")
|
@ApiOperation(value = "产品表-获取产品结构树接口", notes = "产品表-获取产品结构树接口")
|
@GetMapping("/load/tree")
|
public QueryListResponseResult<CommonGenericTree> loadProductTree() {
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
String userId = user.getId();
|
if(!ValidateUtil.validateString(userId))
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
|
List<CommonGenericTree> list = productInfoService.loadProductTree(userId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "产品表-获取产品树的第一级和第二级")
|
@ApiOperation(value = "产品表-获取产品树的第一级和第二级", notes = "产品表-获取产品树的第一级和第二级")
|
@GetMapping("/load/tree/base")
|
public QueryListResponseResult<CommonGenericTree> loadBaseTree() {
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
String userId = user.getId();
|
if(!ValidateUtil.validateString(userId))
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
|
List<CommonGenericTree> list = productInfoService.loadBaseTree(userId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "产品表-加载产品树子节点数据")
|
@ApiOperation(value = "产品表-加载产品树子节点数据", notes = "产品表-加载产品树子节点数据")
|
@GetMapping("/load/tree/child/{nodeType}/{paramId}")
|
public QueryListResponseResult<CommonGenericTree> loadTree(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) {
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
String userId = user.getId();
|
if(!ValidateUtil.validateString(userId))
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
|
List<CommonGenericTree> list = productInfoService.loadTree(userId, nodeType, paramId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
|
@AutoLog(value = "产品表-删除产品")
|
@ApiOperation(value = "产品表-删除产品", notes = "产品表-删除产品")
|
@DeleteMapping("/delete")
|
public ResponseResult deleteProductInfo(@RequestParam("id") String id) {
|
boolean b = productInfoService.deleteProductInfo(id);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "产品表-检查产品树节点的查看权限")
|
@ApiOperation(value = "产品表-检查产品树节点的查看权限", notes = "产品表-检查产品树节点的查看权限")
|
@GetMapping("/check/{nodeType}/{paramId}")
|
public ResponseResult checkProductPerm(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) {
|
boolean b = productInfoService.checkProductPerm(nodeType, paramId);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.UNAUTHORISE);
|
}
|
|
@AutoLog(value = "产品表-获取已分配的用户")
|
@ApiOperation(value = "产品表-获取已分配的用户", notes = "产品表-获取已分配的用户")
|
@GetMapping("/get/perm/user/{nodeType}/{paramId}")
|
public QueryListResponseResult<UserDepartExt> getUserPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) {
|
List<UserDepartExt> list = productInfoService.getUserPermsList(nodeType, paramId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "产品表-获取未分配的用户")
|
@ApiOperation(value = "产品表-获取未分配的用户", notes = "产品表-获取未分配的用户")
|
@GetMapping("/get/non/perm/user/{nodeType}/{paramId}")
|
public QueryListResponseResult<SysUser> getUserNonPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) {
|
List<SysUser> list = productInfoService.getUserNonPermsList(nodeType, paramId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "产品表-获取已分配的部门")
|
@ApiOperation(value = "产品表-获取已分配的部门", notes = "产品表-获取已分配的部门")
|
@GetMapping("/get/perm/depart/{nodeType}/{paramId}")
|
public QueryListResponseResult<MdcProduction> getDepartPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) {
|
List<MdcProduction> list = productInfoService.getDepartPermsList(nodeType, paramId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "产品表-获取未分配的部门")
|
@ApiOperation(value = "产品表-获取未分配的部门", notes = "产品表-获取未分配的部门")
|
@GetMapping("/get/non/perm/depart/{nodeType}/{paramId}")
|
public QueryListResponseResult<MdcProduction> getDepartNonPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) {
|
List<MdcProduction> list = productInfoService.getDepartNonPermsList(nodeType, paramId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult(CommonCode.SUCCESS, list);
|
}
|
|
/**
|
* 指派产品树节点的用户权限
|
* @param nodeType 1 产品 2 部件 3 零件
|
* @param paramId 产品树节点id
|
* @param userIds 添加用户ids
|
* @param relativeFlag 1 是 2 否
|
* @return
|
*/
|
@AutoLog(value = "产品表-指派产品树节点的用户权限")
|
@ApiOperation(value = "产品表-指派产品树节点的用户权限", notes = "产品表-指派产品树节点的用户权限")
|
@PostMapping("/assign/add/user/{nodeType}/{paramId}/{relativeFlag}")
|
public ResponseResult assignAddUser(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) {
|
boolean b = productInfoService.assignAddUser(nodeType, paramId, relativeFlag, userIds);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
/**
|
* 移除产品树节点的用户权限
|
* @param nodeType 1 产品 2 部件 3 零件
|
* @param paramId 产品树节点id
|
* @param userIds 移除用户ids
|
* @param relativeFlag 1 是 2 否
|
* @return
|
*/
|
@AutoLog(value = "产品表-移除产品树节点的用户权限")
|
@ApiOperation(value = "产品表-移除产品树节点的用户权限", notes = "产品表-移除产品树节点的用户权限")
|
@PostMapping("/assign/remove/user/{nodeType}/{paramId}/{relativeFlag}")
|
public ResponseResult assignRemoveUser(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) {
|
boolean b = productInfoService.assignRemoveUser(nodeType, paramId, relativeFlag, userIds);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
/**
|
* 指派产品树节点的部门权限
|
* @param nodeType 1 产品 2 部件 3 零件
|
* @param paramId 产品树节点id
|
* @param departmentIds 添加部门ids
|
* @param relativeFlag 1 是 2 否
|
* @return
|
*/
|
@AutoLog(value = "产品表-指派产品树节点的部门权限")
|
@ApiOperation(value = "产品表-指派产品树节点的部门权限", notes = "产品表-指派产品树节点的部门权限")
|
@PostMapping("/assign/add/department/{nodeType}/{paramId}/{relativeFlag}")
|
public ResponseResult assignAddDepartment(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) {
|
boolean b = productInfoService.assignAddDepartment(nodeType, paramId, relativeFlag, departmentIds);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
/**
|
* 移除产品树节点的部门权限
|
* @param nodeType 1 产品 2 部件 3 零件
|
* @param paramId 产品树节点id
|
* @param departmentIds 移除部门ids
|
* @param relativeFlag 1 是 2 否
|
* @return
|
*/
|
@AutoLog(value = "产品表-移除产品树节点的部门权限")
|
@ApiOperation(value = "产品表-移除产品树节点的部门权限", notes = "产品表-移除产品树节点的部门权限")
|
@PostMapping("/assign/remove/department/{nodeType}/{paramId}/{relativeFlag}")
|
public ResponseResult assignRemoveDepartment(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) {
|
boolean b = productInfoService.assignRemoveDepartment(nodeType, paramId, relativeFlag, departmentIds);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
/**
|
* 搜索接口
|
* @param queryParam
|
* @return
|
*/
|
@AutoLog(value = "产品表-搜索接口")
|
@ApiOperation(value = "产品表-搜索接口", notes = "产品表-搜索接口")
|
@GetMapping("/search")
|
public QueryListResponseResult<CommonGenericTree> searchProductTree(String queryParam) {
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
String userId = user.getId();
|
if(!ValidateUtil.validateString(userId))
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
|
List<CommonGenericTree> list = productInfoService.searchProductTree(userId, queryParam);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
/**
|
* 产品结构树-通过类型就行删除
|
* @param id
|
* @param type
|
* @return
|
*/
|
@AutoLog(value = "产品结构树-通过类型就行删除")
|
@ApiOperation(value = "产品结构树-通过类型就行删除", notes = "产品结构树-通过类型就行删除")
|
@DeleteMapping("/delete/{id}/{type}")
|
public Result<?> deleteProductTreeByType(@PathVariable("id") String id, @PathVariable("type") Integer type) {
|
boolean b =productInfoService.deleteProductTree(id, type);
|
if (b){
|
return Result.ok("删除成功!");
|
}
|
return Result.error("删除失败!");
|
}
|
}
|