From 34c25ddf37a3eb8da9efb04efedad089f13efe83 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期三, 24 七月 2024 18:20:27 +0800 Subject: [PATCH] 部门导入调整,按照部门名称/实现层级关系。枚举导入功能接口上传,属性池添加新增、查询、修改、导出、查看应用范围等接口。业务类型、链接类型、枚举类型增加等接口属性是否产生数据检查、根据属性名修改业务类型和连接类型中对应属性方法,以及属性池中需要的一些下拉查询接口。 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java | 154 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 148 insertions(+), 6 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java index 5a65bfe..a8fb24f 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsAttributeController.java @@ -1,13 +1,25 @@ package com.vci.web.controller; +import com.vci.dto.OsAttributeDTO; +import com.vci.starter.web.annotation.controller.VciUnCheckRight; +import com.vci.starter.web.annotation.log.VciBusinessLog; import com.vci.starter.web.pagemodel.BaseQueryObject; -import com.vci.starter.web.pagemodel.DataGrid; +import com.vci.starter.web.pagemodel.BaseResult; import com.vci.pagemodel.OsAttributeVO; +import com.vci.starter.web.util.ControllerUtil; +import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.service.OsAttributeServiceI; +import com.vci.web.util.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.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Date; +import java.util.List; /** * 灞炴�ф帶鍒跺櫒 @@ -25,12 +37,142 @@ private OsAttributeServiceI attributeService; /** + * 鏃ュ織 + */ + private Logger logger = LoggerFactory.getLogger(getClass()); + + /** * 灞炴�у垪琛� * @param baseQueryObject 鏌ヨ瀵硅薄 * @return 灞炴�х殑鏄剧ず瀵硅薄 */ @GetMapping("/gridAttribute") - public DataGrid<OsAttributeVO> gridAttribute(BaseQueryObject baseQueryObject){ - return attributeService.gridAttribute(baseQueryObject); + @VciUnCheckRight + public BaseResult<OsAttributeVO> gridAttribute(BaseQueryObject baseQueryObject){ + try { + return BaseResult.dataGrid(attributeService.gridAttribute(baseQueryObject)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "灞炴�х鐞嗗垪琛ㄦ煡璇㈡椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } } + + /** + * 鏍规嵁澶氫釜灞炴�у悕绉版煡璇㈠睘鎬� + * @param attrNames + * @return + */ + @GetMapping("/getByAttributeNames") + public BaseResult getByAttributeNames(String[] attrNames){ + try { + return BaseResult.dataList(attributeService.getByAttributeNames(attrNames)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "灞炴�у悕鏌ヨ灞炴�ф椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 娣诲姞鍗曟潯灞炴�у埌灞炴�ф睜 + * @param osAttributeDTO + * @return 鍒楄〃鐨勫唴瀹� + */ + @PostMapping( "/addAttribute") + @VciBusinessLog(operateName = "娣诲姞灞炴��") + @VciUnCheckRight + public BaseResult addAttribute(@RequestBody OsAttributeDTO osAttributeDTO) { + try { + return attributeService.addAttribute(osAttributeDTO) ? BaseResult.success("灞炴�ф坊鍔犳垚鍔燂紒"):BaseResult.fail("灞炴�ф坊鍔犲け璐ワ紒"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "澧炲姞灞炴�у瀷鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 淇敼鍗曟潯灞炴�� + * @param osAttributeDTO + * @return 鍒楄〃鐨勫唴瀹� + */ + @PutMapping( "/updateAttribute") + @VciBusinessLog(operateName = "淇敼灞炴��") + public BaseResult updateAttribute(@RequestBody OsAttributeDTO osAttributeDTO) { + try { + return attributeService.updateAttribute(osAttributeDTO) ? BaseResult.success("灞炴�т慨鏀规垚鍔燂紒"):BaseResult.fail("灞炴�т慨鏀瑰け璐ワ紒"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "淇敼灞炴�ф椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎灞炴�� + * @param osAttributeDTOS + * @return 鍒楄〃鐨勫唴瀹� + */ + @DeleteMapping( "/deleteAttributes") + @VciBusinessLog(operateName = "鍒犻櫎灞炴��") + public BaseResult deleteAttributes(@RequestBody List<OsAttributeDTO> osAttributeDTOS) { + try { + return attributeService.deleteAttributes(osAttributeDTOS) ? BaseResult.success("灞炴�у垹闄ゆ垚鍔燂紒"):BaseResult.fail("灞炴�у垹闄ゅけ璐ワ紒"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎灞炴�ф椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鏌ョ湅灞炴�х殑浣跨敤鑼冨洿 + * @param attributeName 灞炴�у悕绉� + * @return map瀵硅薄 + */ + @GetMapping( "/getUsedAttributeList") + @VciBusinessLog(operateName = "鏌ョ湅灞炴�х殑浣跨敤鑼冨洿") + public BaseResult getUsedAttributeList(String attributeName) { + try { + return BaseResult.dataList(attributeService.getUsedAttributeList(attributeName)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鑾峰彇灞炴�х殑浣跨敤鑼冨洿鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 瀵煎嚭閫変腑鐨勫睘鎬� + * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕 + * @param attrNames 闇�瑕佸鍑虹殑灞炴�ц嫳鏂囧悕绉� + * @param response + */ + @GetMapping( "/exportAttributes") + @VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷") + @VciUnCheckRight + public void exportAttributes(String exportFileName,String attrNames, HttpServletResponse response){ + try { + String excelPath = attributeService.exportAttributes(exportFileName,attrNames); + 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(); + } + } + } + + } -- Gitblit v1.9.3