From 889842eb8b64a0b72c449ce23ff21e4e8c935cae Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期五, 26 七月 2024 16:06:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 103 insertions(+), 8 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java index e8beb3e..a8048f4 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebEnumController.java @@ -1,22 +1,35 @@ package com.vci.web.controller; +import com.vci.constant.FrameWorkLangCodeConstant; import com.vci.dto.OsEnumDTO; import com.vci.starter.web.annotation.controller.VciUnCheckRight; import com.vci.starter.web.annotation.log.VciBusinessLog; +import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.pagemodel.KeyValue; import com.vci.pagemodel.OsEnumItemVO; import com.vci.pagemodel.OsEnumVO; +import com.vci.starter.web.util.ControllerUtil; +import com.vci.starter.web.util.LangBaseUtil; +import com.vci.starter.web.util.LocalFileUtil; import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.service.OsEnumServiceI; +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.*; +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.List; +import java.util.Map; /** @@ -46,7 +59,6 @@ * @return 鏋氫妇鐨勪笅鎷夊�� */ @VciBusinessLog(notStore=true,operateName="鑾峰彇鏋氫妇") - @VciUnCheckRight @GetMapping("/getEnum") public BaseResult<List<KeyValue>> getEnum(String comboxKey){ return BaseResult.success(enumService.getEnum(comboxKey)); @@ -87,13 +99,30 @@ } /** + * 鏍规嵁鏋氫妇绫诲瀷鑾峰彇鏋氫妇 + * @param enumType 鏌ヨ鏉′欢name + * @return 鍒楄〃鐨勫唴瀹� + */ + @GetMapping( "/getEnumMapByType") + @VciBusinessLog(operateName = "鏋氫妇鍒楄〃") + public BaseResult getEnumMapByType(String enumType) { + try { + return BaseResult.dataList(enumService.getEnumMapByType(enumType)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鏋氫妇绠$悊鍒楄〃鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** * 鏋氫妇鍒楄〃 * @param enumName 鏌ヨ鏉′欢name * @return 鍒楄〃鐨勫唴瀹� */ @GetMapping( "/getEnumTypeList") @VciBusinessLog(operateName = "鏋氫妇鍒楄〃") - @VciUnCheckRight public BaseResult<List<OsEnumVO>> getEnumTypeList(String enumName) { try { return BaseResult.dataList(enumService.getEnumTypeList(enumName)); @@ -112,7 +141,6 @@ */ @PostMapping( "/addEnumType") @VciBusinessLog(operateName = "娣诲姞鏋氫妇") - @VciUnCheckRight public BaseResult addEnumType(@RequestBody OsEnumDTO osEnumDTO) { try { return enumService.addEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷娣诲姞鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷娣诲姞澶辫触锛�"); @@ -131,7 +159,6 @@ */ @PutMapping( "/updateEnumType") @VciBusinessLog(operateName = "淇敼鏋氫妇") - @VciUnCheckRight public BaseResult updateEnumType(@RequestBody OsEnumDTO osEnumDTO) { try { return enumService.updateEnumType(osEnumDTO) ? BaseResult.success("鏋氫妇绫诲瀷淇敼鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷淇敼澶辫触锛�"); @@ -150,7 +177,6 @@ */ @DeleteMapping( "/deleteEnumTypes") @VciBusinessLog(operateName = "鍒犻櫎鏋氫妇") - @VciUnCheckRight public BaseResult deleteEnumTypes(@RequestBody List<OsEnumDTO> osEnumDTOS) { try { return enumService.deleteEnumTypes(osEnumDTOS) ? BaseResult.success("鏋氫妇绫诲瀷鍒犻櫎鎴愬姛锛�"):BaseResult.fail("鏋氫妇绫诲瀷鍒犻櫎澶辫触锛�"); @@ -164,12 +190,11 @@ /** * 鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥� - * @param enumName - * @return 鍒楄〃鐨勫唴瀹� + * @param enumName 鏋氫妇鍚嶇О + * @return map瀵硅薄 */ @GetMapping( "/getUsedEnumList") @VciBusinessLog(operateName = "鏌ョ湅鏋氫妇鐨勪娇鐢ㄨ寖鍥�") - @VciUnCheckRight public BaseResult getUsedEnumList(String enumName) { try { return BaseResult.dataList(enumService.getUsedEnumList(enumName)); @@ -181,4 +206,74 @@ } } + /** + * 瀵煎嚭閫変腑鐨勬灇涓剧被鍨� + * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕 + * @param enumNames 闇�瑕佸鍑虹殑鏋氫妇鍚嶇О + * @param response + */ + @GetMapping( "/exportEnumTypes") + @VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷") + public void exportEnumTypes(String exportFileName,String enumNames, HttpServletResponse response){ + try { + String excelPath = enumService.exportEnumTypes(exportFileName,enumNames); + 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(); + } + } + } + + /** + * 涓嬭浇瀵煎叆妯℃澘 + * @param exportFileName + * @param response + */ + @GetMapping( "/downloadEnumTemplate") + @VciBusinessLog(operateName = "瀵煎嚭鏋氫妇绫诲瀷") + public void downloadEnumTemplate(String exportFileName, HttpServletResponse response){ + try { + String excelPath = enumService.downloadEnumTemplate(exportFileName); + 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(); + } + } + } + + /** + * 瀵煎叆鏋氫妇 + * @param file + * @return + */ + @RequestMapping(value = "/importEnumTypes",method = RequestMethod.POST) + public BaseResult importEnumTypes(MultipartFile file){ + String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename()); + File file1 = new File(excelFileName); + try { + file.transferTo(new File(excelFileName)); + if (file != null) { + return enumService.importEnumTypes(file1); + } else { + return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"}); + } + }catch (Throwable e) { + throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); + }finally { + file1.delete(); + } + } + } -- Gitblit v1.9.3