| | |
| | | package com.vci.frameworkcore.controller; |
| | | |
| | | import com.vci.frameworkcore.compatibility.OrgDeptQueryServiceI; |
| | | import com.vci.frameworkcore.model.dto.OrgDepartmentDTO; |
| | | import com.vci.frameworkcore.pagemodel.OrgDepartmentVO; |
| | | import com.vci.starter.web.annotation.controller.VciUnCheckRight; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.*; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.util.Func; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | private OrgDeptQueryServiceI deptQueryService; |
| | | |
| | | /** |
| | | * 部门的树形参照 |
| | | * 部门的树形参照,部门管理也用的这个查询接口 |
| | | * @param treeQueryObject 树形数据的查询对象,包括查询条件,上级主键,是否多选等,(extandParamsMap中添加"showAllDepartmentNode"为"true"时,并且parentOid为空,返回结果中会包含“所有部门”这个节点) |
| | | * @return 部门的树形参照,已经转换了上下级关系 |
| | | * @throws VciBaseException 查询出错的时候会抛出异常,如果是老的项目里不抛出异常 |
| | | */ |
| | | @RequestMapping(value = "/refTree",method = RequestMethod.GET) |
| | | //@VciUnCheckRight |
| | | public BaseResult<Tree> refTree(TreeQueryObject treeQueryObject) throws VciBaseException{ |
| | | List<Tree> deptTreeList = deptQueryService.refTreeDept(treeQueryObject); |
| | | return BaseResult.tree(deptTreeList); |
| | | //老的项目依然是添加try catch,方法里不抛出异常 |
| | | //BaseResult.fail("这里返回前端的错误信息"); |
| | | try { |
| | | List<Tree> deptTreeList = deptQueryService.refTreeDept(treeQueryObject); |
| | | return BaseResult.tree(deptTreeList); |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | log.error("部门树查询时出现错误,原因:" + exceptionMessage); |
| | | return BaseResult.fail("部门树查询时出现错误,原因:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 部门查询,带分页 |
| | | * 部门列表查询,带分页 |
| | | * @param queryObject |
| | | * @return |
| | | * @return 返回的list不是tree结构的 |
| | | */ |
| | | @RequestMapping(value = "/refDataGrid",method = RequestMethod.GET) |
| | | public BaseResult<OrgDepartmentVO> refDataGrid(BaseQueryObject queryObject){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保存部门角色关联信息,带查重功能 |
| | | * 保存部门用户关联信息,平台自带查重功能 |
| | | * @param userOIds 用户id |
| | | * @param deptId 部门oid |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/saveUsersDepts",method = RequestMethod.POST) |
| | | public BaseResult saveUsersDepts(String[] userOIds, String deptId){ |
| | | //不能同时为空 |
| | | if(Func.isEmpty(userOIds) && Func.isBlank(deptId)){ |
| | | return BaseResult.fail("角色主键和部门主键,参数不能同时为空!"); |
| | | } |
| | | try { |
| | | return deptQueryService.saveUsersDept(userOIds,deptId) ? BaseResult.success("角色分配成功!"):BaseResult.fail("角色分配失败!"); |
| | | return deptQueryService.saveUsersDept(userOIds,deptId) ? BaseResult.success("部门分配成功!"):BaseResult.fail("部门分配失败!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | log.error("根据用户主键获取,关联的角色时出现错误,原因:" + exceptionMessage); |
| | | return BaseResult.fail("根据用户主键获取,关联的角色时出现错误,原因:" + exceptionMessage); |
| | | log.error("关联的部门时出现错误,原因:" + exceptionMessage); |
| | | return BaseResult.fail("关联的部门时出现错误,原因:" + exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增单条部门 |
| | | * @param orgDepartmentDTO |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/addDept",method = RequestMethod.POST) |
| | | @VciUnCheckRight |
| | | public BaseResult addDept(@RequestBody OrgDepartmentDTO orgDepartmentDTO){ |
| | | try { |
| | | return deptQueryService.addDept(orgDepartmentDTO) ? BaseResult.success("部门添加成功!"):BaseResult.fail("部门添加失败!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | log.error("添加部门时出现错误,原因:" + exceptionMessage); |
| | | return BaseResult.fail("添加部门时出现错误,原因:" + exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改部门信息 |
| | | * @param orgDepartmentDTO |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/updateDept",method = RequestMethod.PUT) |
| | | @VciUnCheckRight |
| | | public BaseResult updateRole(@RequestBody OrgDepartmentDTO orgDepartmentDTO){ |
| | | try { |
| | | return deptQueryService.updateDept(orgDepartmentDTO) ? BaseResult.success("部门修改成功!"):BaseResult.fail("部门修改失败!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | log.error("修改部门时出现错误,原因:" + exceptionMessage); |
| | | return BaseResult.fail("修改部门时出现错误,原因:" + exceptionMessage); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除部门 |
| | | * @param ids 要删除的部门主键 |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/deleteDept",method = RequestMethod.DELETE) |
| | | @VciUnCheckRight |
| | | public BaseResult deleteDept(String[] ids){ |
| | | try { |
| | | return deptQueryService.deleteDept(ids) ? BaseResult.success("删除部门成功!"):BaseResult.fail("删除部门失败!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String exceptionMessage = VciBaseUtil.getExceptionMessage(e); |
| | | log.error("添加部门时出现错误,原因:" + exceptionMessage); |
| | | return BaseResult.fail("添加部门时出现错误,原因:" + exceptionMessage); |
| | | } |
| | | } |
| | | |