From 5203081b68e3a8dc139d1807b2f8774e4a00a82a Mon Sep 17 00:00:00 2001 From: ludc <ludc@vci-tech.com> Date: 星期四, 16 一月 2025 11:11:59 +0800 Subject: [PATCH] 退出登录接口增加清除session、jwttoken等缓存信息 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java | 190 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 185 insertions(+), 5 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java index 323a196..22408a6 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java @@ -1,15 +1,31 @@ package com.vci.web.controller; +import com.vci.constant.FrameWorkLangCodeConstant; +import com.vci.dto.OsLifeCycleDTO; +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.web.pageModel.OsERVO; -import com.vci.web.pageModel.OsLifeCycleVO; +import com.vci.pagemodel.OsERVO; +import com.vci.pagemodel.OsLifeCycleVO; +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.service.OsLifeCycleServiceI; +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.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +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; /** * 鐢熷懡鍛ㄦ湡鐨勬帶鍒跺櫒 @@ -25,6 +41,11 @@ */ @Autowired private OsLifeCycleServiceI lifeCycleService; + + /** + * 鏃ュ織 + */ + private Logger logger = LoggerFactory.getLogger(getClass()); /** * 鐢熷懡鍛ㄦ湡鍒楄〃 @@ -45,4 +66,163 @@ public BaseResult<OsERVO> listLinesPic(String id){ return BaseResult.success(lifeCycleService.listLinesPic(id)); } + + /** + * 鏌ヨ搴旂敤鑼冨洿 + * @param lifeCycleName 鐗堟湰瑙勫垯鑻辨枃鍚嶇О + * @return + */ + @GetMapping("/getUsedLifeCycleList") + public BaseResult getUsedLifeCycleList(String lifeCycleName){ + try { + return BaseResult.dataList(lifeCycleService.getUsedLifeCycleList(lifeCycleName)); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鐗堟湰瑙勫垯搴旂敤鑼冨洿鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 娣诲姞鍗曟潯鐢熷懡鍛ㄦ湡 + * @param osLifeCycleVO + * @return 鍒楄〃鐨勫唴瀹� + */ + @PostMapping( "/addLifeCycle") + @VciBusinessLog(operateName = "娣诲姞鐢熷懡鍛ㄦ湡") + public BaseResult addLifeCycle(@RequestBody OsLifeCycleVO osLifeCycleVO) { + try { + return lifeCycleService.addLifeCycle(osLifeCycleVO) ? BaseResult.success("鐢熷懡鍛ㄦ湡娣诲姞鎴愬姛锛�"):BaseResult.fail("鐢熷懡鍛ㄦ湡娣诲姞澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "娣诲姞鐢熷懡鍛ㄦ湡鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 淇敼鍗曟潯鐢熷懡鍛ㄦ湡 + * @param osLifeCycleVO + * @return 鍒楄〃鐨勫唴瀹� + */ + @PutMapping( "/updateLifeCycle") + @VciBusinessLog(operateName = "淇敼鐢熷懡鍛ㄦ湡") + public BaseResult updateLifeCycle(@RequestBody OsLifeCycleVO osLifeCycleVO) { + try { + return lifeCycleService.updateLifeCycle(osLifeCycleVO) ? BaseResult.success("鐢熷懡鍛ㄦ湡淇敼鎴愬姛锛�"):BaseResult.fail("鐢熷懡鍛ㄦ湡淇敼澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "淇敼鐢熷懡鍛ㄦ湡鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 鍒犻櫎鐢熷懡鍛ㄦ湡 + * @param lifeCycleDTOS + * @return 鍒楄〃鐨勫唴瀹� + */ + @DeleteMapping( "/deleteLifeCycles") + @VciBusinessLog(operateName = "鍒犻櫎鐢熷懡鍛ㄦ湡") + public BaseResult deleteLifeCycles(@RequestBody List<OsLifeCycleDTO> lifeCycleDTOS) { + try { + return lifeCycleService.deleteLifeCycles(lifeCycleDTOS) ? BaseResult.success("鐢熷懡鍛ㄦ湡鍒犻櫎鎴愬姛锛�"):BaseResult.fail("鐢熷懡鍛ㄦ湡鍒犻櫎澶辫触锛�"); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "鍒犻櫎鐢熷懡鍛ㄦ湡鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + + /** + * 瀵煎嚭閫変腑鐨勭敓鍛藉懆鏈� + * @param exportFileName 瀵煎嚭鐨勬枃浠跺悕 + * @param lcNames 闇�瑕佸鍑虹殑鐢熷懡鍛ㄦ湡鑻辨枃鍚嶇О + * @param response + */ + @GetMapping( "/exportLifeCycles") + @VciBusinessLog(operateName = "瀵煎嚭鐢熷懡鍛ㄦ湡") + public void exportLifeCycles(String exportFileName,String lcNames, HttpServletResponse response){ + try { + String excelPath = lifeCycleService.exportLifeCycles(exportFileName,lcNames,false); + 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( "/downloadLifeCycleTemplate") + @VciBusinessLog(operateName = "涓嬭浇鐢熷懡鍛ㄦ湡瀵煎叆妯℃澘") + public void downloadLifeCycleTemplate(String exportFileName, HttpServletResponse response){ + try { + String excelPath = lifeCycleService.downloadLifeCycleTemplate(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 + */ + @PostMapping("/importLifeCycles") + @VciBusinessLog(operateName = "瀵煎叆鐢熷懡鍛ㄦ湡") + public BaseResult importLifeCycles(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 lifeCycleService.importLifeCycles(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(); + } + } + + /** + * 鏌ヨ鎵�鏈夎穬杩佷簨浠秌ey + * @return + */ + @GetMapping("/getLCEventKeys") + public BaseResult getLCEventKeys(){ + try { + return BaseResult.dataList(lifeCycleService.getLCEventKeys()); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "璺冭縼浜嬩欢鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + } -- Gitblit v1.9.3