| | |
| | | package com.vci.web.controller; |
| | | |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.frameworkcore.compatibility.ISmFunctionQueryService; |
| | | import com.vci.frameworkcore.compatibility.SmHMSysModConfigServiceI; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.framework.data.FuncOperationInfo; |
| | | import com.vci.corba.framework.data.OnlinUserInfo; |
| | | import com.vci.corba.framework.data.OperateInfo; |
| | | import com.vci.dto.RoleInfoDTO; |
| | | import com.vci.dto.RoleRightParamDTO; |
| | | import com.vci.dto.RoleRightParamDTOS; |
| | | import com.vci.web.service.ISmFunctionQueryService; |
| | | import com.vci.web.service.SmHMSysModConfigServiceI; |
| | | import com.vci.pagemodel.AppConfigDetailInfoVO; |
| | | import com.vci.pagemodel.ExpExcelConditionVO; |
| | | import com.vci.pagemodel.MenuVO; |
| | | import com.vci.starter.web.annotation.controller.VciUnCheckRight; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.util.ControllerUtil; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.starter.web.util.Lcm.Func; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 首页系统模块配置控制器 |
| | |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/hmSysModConfigController") |
| | | @VciUnCheckRight |
| | | public class HMSysModConfigController { |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取当前模块下的子模块 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getSysModelAuthTreeMenuByPID") |
| | | public BaseResult<List<MenuVO>> getSysModelAuthTreeMenuByPID() { |
| | | try { |
| | | return BaseResult.dataList(functionQueryService.getSysModelAuthTreeMenuByPID(false)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "查询子模块时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取所授权的模块权限 |
| | | * @param roleId 角色 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getSysModelAuth") |
| | | public BaseResult<List<String>> getSysModelAuth(String roleId) { |
| | | try { |
| | | return BaseResult.dataList(functionQueryService.getSysModelAuth(roleId)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "查询子模块时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 角色列表 |
| | | * @param roleName 搜索的角色 |
| | | * @return 角色列表 |
| | | */ |
| | | @GetMapping("/getRoleList") |
| | | public BaseResult<List<RoleInfoDTO>> getRoleList(String roleName) { |
| | | try { |
| | | return BaseResult.dataList(functionQueryService.getRoleList(roleName)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "查询时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 保存授权的模块 |
| | | * @param roleDto 用户选择授权模块信息 |
| | | * @return 授权结果 |
| | | * @throws PLException |
| | | */ |
| | | @PostMapping("/saveRoleRight") |
| | | public BaseResult saveRoleRight(@RequestBody RoleRightParamDTOS roleDto) { |
| | | try { |
| | | |
| | | ArrayList<RoleRightParamDTO> roleRightDTOS = roleDto.getRoleData(); |
| | | String roleId = roleDto.getRoleId(); |
| | | if(StringUtils.isBlank(roleId)){ |
| | | return BaseResult.fail("请选择角色!"); |
| | | } |
| | | return functionQueryService.saveRoleRight(roleRightDTOS, roleId); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "保存模块时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加模块 |
| | | * @param menuVO |
| | | * @return |
| | |
| | | @PostMapping("/addModel") |
| | | public BaseResult addModel(@RequestBody MenuVO menuVO) { |
| | | try { |
| | | return BaseResult.success(hmSysModConfigService.addModule(menuVO),"模块增加成功"); |
| | | return BaseResult.success(hmSysModConfigService.addModule(menuVO),"模块增加成功!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "增加模块时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除模块下关联的操作类型 |
| | | * @param funcOperationInfo |
| | | * @return |
| | | */ |
| | | @DeleteMapping("/delFuncOperation") |
| | | public BaseResult delFuncOperation(@RequestBody FuncOperationInfo funcOperationInfo) { |
| | | try { |
| | | return BaseResult.success(hmSysModConfigService.delFuncOperation(funcOperationInfo),"模块下操作类型删除成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "模块下操作类型删除时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 管理功能模块、业务功能模块下的叶子节点—修改操作别名接口 |
| | | * @param menuVO |
| | | * @return |
| | |
| | | return BaseResult.success(hmSysModConfigService.updateAlias(menuVO),"操作别名修改成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "操作别名修改时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | String errorMsg = "操作类型别名修改时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加操作类型与模块的关联关系 |
| | | * @param funcOperationInfoList |
| | | * @return |
| | | */ |
| | | @PostMapping("/addFuncOperationType") |
| | | public BaseResult addFuncOperationType(@RequestBody List<FuncOperationInfo> funcOperationInfoList) { |
| | | try { |
| | | return BaseResult.success(hmSysModConfigService.addFuncOperationType(funcOperationInfoList),"为当前模块添加操作类型成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "为当前模块添加操作类型时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 添加操作类型 |
| | | * @param menuVOList |
| | | * @param operateInfo |
| | | * @return |
| | | */ |
| | | @PostMapping("/addOperationType") |
| | | public BaseResult addOperationType(@RequestBody List<MenuVO> menuVOList) { |
| | | public BaseResult addOperationType(@RequestBody OperateInfo operateInfo) { |
| | | try { |
| | | return BaseResult.success(hmSysModConfigService.addOperationType(menuVOList),"操作类型添加成功"); |
| | | return BaseResult.success(hmSysModConfigService.addOperationType(operateInfo),"添加操作类型成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "删除模块时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | String errorMsg = "添加操作类型时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改操作类型 |
| | | * @param operateInfo |
| | | * @return |
| | | */ |
| | | @PutMapping("/updateOperationType") |
| | | public BaseResult updateOperationType(@RequestBody OperateInfo operateInfo) { |
| | | try { |
| | | return BaseResult.success(hmSysModConfigService.updateOperationType(operateInfo),"修改操作类型成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "修改操作类型时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除操作类型 |
| | | * @param operateInfo |
| | | * @return |
| | | */ |
| | | @DeleteMapping("/delOperationType") |
| | | public BaseResult delOperationType(@RequestBody OperateInfo operateInfo) { |
| | | try { |
| | | return BaseResult.success(hmSysModConfigService.delOperationType(operateInfo),"删除操作类型成功"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "删除操作类型时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | |
| | | * 导入模块 |
| | | * @return |
| | | */ |
| | | @GetMapping("/importModule") |
| | | @PostMapping("/importModule") |
| | | public BaseResult importModule(@RequestParam("files") List<MultipartFile> files) { |
| | | LinkedList<File> fileList = new LinkedList<>(); |
| | | try { |
| | |
| | | file.transferTo(file1); |
| | | fileList.add(file1); |
| | | } |
| | | if(Func.isEmpty(fileList)){ |
| | | if(Func.isNotEmpty(fileList)){ |
| | | return hmSysModConfigService.importModule(fileList); |
| | | } else { |
| | | return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"}); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | *查询系统配置树 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getAppConfigCategoryInfo") |
| | | public BaseResult getAppConfigCategoryInfo() { |
| | | try { |
| | | return BaseResult.dataList(hmSysModConfigService.getAppConfigCategoryInfo()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "查询系统配置列表时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | *根据分类ID返回全部的 AppConfigDetail 对象 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getAppConfigDetailsByID") |
| | | public BaseResult getAppConfigDetailsByID(String clsId) { |
| | | try { |
| | | return BaseResult.dataList(hmSysModConfigService.getAppConfigDetailsByID(clsId)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "查询配置项列表时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 添加操作类型 |
| | | * @param appConfigDetailInfoVO |
| | | * @return |
| | | */ |
| | | @PostMapping("/addAppConf") |
| | | public BaseResult addAppConf(@RequestBody AppConfigDetailInfoVO appConfigDetailInfoVO) { |
| | | try { |
| | | boolean res = hmSysModConfigService.addAppConf(appConfigDetailInfoVO.getAppConfigDetailInfo(), appConfigDetailInfoVO.isConfCategorys()); |
| | | return res ? BaseResult.success("添加操作类型成功"):BaseResult.fail("添加操作类型失败!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "添加操作类型时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改操作类型 |
| | | * @param appConfigDetailInfoVO |
| | | * @return |
| | | */ |
| | | @PutMapping("/updateAppConf") |
| | | public BaseResult updateAppConf(@RequestBody AppConfigDetailInfoVO appConfigDetailInfoVO) { |
| | | try { |
| | | boolean res = hmSysModConfigService.updateAppConf(appConfigDetailInfoVO.getAppConfigDetailInfo(),appConfigDetailInfoVO.isConfCategorys()); |
| | | return res ? BaseResult.success("修改操作类型成功"):BaseResult.fail("修改操作类型失败!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "修改操作类型时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除操作类型 |
| | | * @param ids |
| | | * @param isConfCategorys |
| | | * @return |
| | | */ |
| | | @DeleteMapping("/delAppConf") |
| | | public BaseResult delAppConf(String[] ids,boolean isConfCategorys) { |
| | | try { |
| | | return hmSysModConfigService.delAppConf(ids,isConfCategorys) ? BaseResult.success("删除操作类型成功"):BaseResult.fail("删除操作类型失败!"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | String errorMsg = "删除操作类型时出现错误,原因:"+ VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导出系统配置(配置项分类或配置项) |
| | | * @return |
| | | */ |
| | | @PostMapping("/exportSysConf") |
| | | public void exportSysConf(@RequestBody ExpExcelConditionVO expExcelConditionVO, HttpServletResponse response) { |
| | | try { |
| | | String excelPath = hmSysModConfigService.exportSysConf(expExcelConditionVO,response); |
| | | ControllerUtil.writeFileToResponse(response,excelPath); |
| | | } catch (Exception e) { |
| | | String msg = "导出系统配置时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | try { |
| | | //出错时 |
| | | e.printStackTrace(); |
| | | ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null); |
| | | } catch (IOException ioException) { |
| | | ioException.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取当前用户在线人数 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getOnlineUsersNum") |
| | | public BaseResult getOnlineUsersNum() { |
| | | try { |
| | | long onlineUsersNum = hmSysModConfigService.getOnlineUsersNum(); |
| | | return BaseResult.success(onlineUsersNum); |
| | | } catch (Exception e) { |
| | | String errorMsg = "获取当前用户在线人数时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取当前用户在线人数 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getOnlinUsers") |
| | | public BaseResult<OnlinUserInfo> getOnlinUsers(){ |
| | | try { |
| | | BaseResult baseResult = BaseResult.success(); |
| | | List<OnlinUserInfo> onlineUserList = hmSysModConfigService.getOnlinUsers(); |
| | | baseResult.setData(onlineUserList); |
| | | return baseResult; |
| | | } catch (Exception e) { |
| | | String errorMsg = "获取当前在线用户时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); |
| | | logger.error(errorMsg); |
| | | throw new VciBaseException(errorMsg); |
| | | } |
| | | } |
| | | } |