From 32eb942e25aa366563b7f40b05a382c0c462213c Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 22 七月 2025 10:29:38 +0800 Subject: [PATCH] 修改切面日志功能 --- se-system/src/main/java/com/terra/system/controller/sys/ResController.java | 391 +++++++++++++++++++++++++++---------------------------- 1 files changed, 194 insertions(+), 197 deletions(-) diff --git a/se-system/src/main/java/com/terra/system/controller/sys/ResController.java b/se-system/src/main/java/com/terra/system/controller/sys/ResController.java index 27c4e63..0b8c193 100644 --- a/se-system/src/main/java/com/terra/system/controller/sys/ResController.java +++ b/se-system/src/main/java/com/terra/system/controller/sys/ResController.java @@ -1,20 +1,22 @@ package com.terra.system.controller.sys; -import com.terra.system.annotation.SysLog; -import com.terra.system.controller.all.BaseController; -import com.terra.system.entity.all.ResponseMsg; +import com.terra.common.annotation.SysLog; +import com.terra.common.controller.all.BaseController; +import com.terra.common.entity.all.ResponseMsg; import com.terra.system.entity.sys.ResEntity; import com.terra.system.entity.sys.UserEntity; +import com.terra.common.helper.StringHelper; import com.terra.system.service.all.PermsService; import com.terra.system.service.all.UploadAttachService; -import com.terra.system.service.data.DownloadService; import com.terra.system.service.sys.ResService; import com.terra.system.service.sys.TokenService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import javax.annotation.Resource; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.bind.annotation.*; @@ -27,7 +29,7 @@ * @author SWS * @date 2022-09.28 */ -@Api(tags = "杩愮淮绠$悊\\璧勬簮绠$悊") +@Tag(name = "杩愮淮绠$悊\\璧勬簮绠$悊") @RestController @RequestMapping("/res") public class ResController extends BaseController { @@ -41,70 +43,35 @@ PermsService permsService; @Resource - DownloadService downloadService; - - @Resource UploadAttachService uploadAttachService; private final static String TAB_NAME = "lf.sys_res"; @SysLog() - @ApiOperation(value = "鏌ヨ璁板綍鏁�") - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", required = false, example = "sys_res") - }) - @GetMapping({"/selectCount"}) - public ResponseMsg<Integer> selectCount(String name) { - try { - int count = resService.selectCount(name); - - return success(count); - } catch (Exception ex) { - return fail(ex, -1); - } - } - - @SysLog() - @ApiOperation(value = "鍒嗛〉鏌ヨ") - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", example = "sys_res"), - @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), - @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") - }) - @GetMapping(value = "/selectByPage") - public ResponseMsg<List<ResEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex) { - try { - if (pageSize < 1 || pageIndex < 1) { - return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null); - } - - List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1)); - - return success(rs); - } catch (Exception ex) { - return fail(ex, null); - } - } - - @SysLog() - @ApiOperation(value = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") - @ApiImplicitParams({ - @ApiImplicitParam(name = "name", value = "鍚嶇О", dataType = "String", paramType = "query", example = "sys_res"), - @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), - @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") + @Operation(summary = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") + @Parameters({ + @Parameter(name = "name", description = "鍚嶇О", in = ParameterIn.QUERY, example = ""), + @Parameter(name = "status", description = "鐘舵��", in = ParameterIn.QUERY, example = ""), + @Parameter(name = "category", description = "鏈嶅姟绫诲埆", in = ParameterIn.QUERY, example = ""), + @Parameter(name = "type", description = "鏈嶅姟绫诲瀷", in = ParameterIn.QUERY, example = ""), + @Parameter(name = "data", description = "鏁版嵁绫诲瀷", in = ParameterIn.QUERY, example = ""), + @Parameter(name = "pageSize", description = "姣忛〉鏉℃暟", in = ParameterIn.QUERY, example = "10"), + @Parameter(name = "pageIndex", description = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", in = ParameterIn.QUERY, example = "1") }) @GetMapping(value = "/selectByPageAndCount") - public ResponseMsg<List<ResEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) { + public ResponseMsg<List<ResEntity>> selectByPageAndCount(String name, Integer status, Integer category, Integer type, Integer data, Integer pageSize, Integer pageIndex) { try { if (pageSize < 1 || pageIndex < 1) { return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null); } - int count = resService.selectCount(name); + int count = resService.selectCount(name, status, category, type, data); if (count == 0) { return success(0, null); } - List<ResEntity> rs = resService.selectByPage(name, pageSize, pageSize * (pageIndex - 1)); + + List<ResEntity> rs = resService.selectByPage(name, status, category, type, data, pageSize, pageSize * (pageIndex - 1)); + return success(count, rs); } catch (Exception ex) { return fail(ex, null); @@ -112,11 +79,11 @@ } @SysLog() - @ApiOperation(value = "鏍规嵁瑙掕壊鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") - @ApiImplicitParams({ - @ApiImplicitParam(name = "roleid", value = "瑙掕壊ID", dataType = "Integer", paramType = "query", example = "1"), - @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), - @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") + @Operation(summary = "鏍规嵁瑙掕壊鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") + @Parameters({ + @Parameter(name = "roleid", description = "瑙掕壊ID", in = ParameterIn.QUERY, example = "1"), + @Parameter(name = "pageSize", description = "姣忛〉鏉℃暟", in = ParameterIn.QUERY, example = "10"), + @Parameter(name = "pageIndex", description = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", in = ParameterIn.QUERY, example = "1") }) @GetMapping(value = "/selectByPageForRole") public ResponseMsg<List<ResEntity>> selectByPageForRole(Integer roleid, Integer pageSize, Integer pageIndex) { @@ -139,134 +106,11 @@ } @SysLog() - @ApiOperation(value = "鎻掑叆涓�鏉�") - @ApiImplicitParams({ - @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "com.terra.system.entity.sys.ResEntity", paramType = "body", example = "") - }) - @PostMapping(value = "/insertRes", produces = "application/json; charset=UTF-8") - public ResponseMsg<Integer> insertRes(@RequestBody ResEntity entity, HttpServletRequest req) { + @Operation(summary = "鏌ヨ鎵�鏈�") + @GetMapping(value = "/selectAll") + public ResponseMsg<List<ResEntity>> selectAll() { try { - UserEntity ue = tokenService.getCurrentUser(req); - if (ue != null) { - entity.setCreateUser(ue.getId()); - } - - permsService.clearPermsCache(); - int count = resService.insertRes(entity); - - return success(count); - } catch (Exception ex) { - return fail(ex, -1); - } - } - - @SysLog() - @ApiOperation(value = "鎻掑叆澶氭潯") - @ApiImplicitParams({ - @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "List<ResEntity>", paramType = "body", example = "") - }) - @PostMapping(value = "/insertRess", produces = "application/json; charset=UTF-8") - public ResponseMsg<Integer> insertRess(@RequestBody List<ResEntity> list, HttpServletRequest req) { - try { - UserEntity ue = tokenService.getCurrentUser(req); - if (ue != null) { - for (ResEntity entity : list) { - entity.setCreateUser(ue.getId()); - } - } - - permsService.clearPermsCache(); - int count = resService.insertRess(list); - - return success(count); - } catch (Exception ex) { - return fail(ex, -1); - } - } - - @SysLog() - @ApiOperation(value = "鍒犻櫎涓�鏉�") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") - }) - @GetMapping(value = "/deleteRes") - public ResponseMsg<Integer> deleteRes(int id) { - try { - permsService.clearPermsCache(); - int count = resService.deleteRes(id); - - return success(count); - } catch (Exception ex) { - return fail(ex, -1); - } - } - - @SysLog() - @ApiOperation(value = "鍒犻櫎澶氭潯") - @ApiImplicitParams({ - @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "List<Integer>", paramType = "query", example = "1,2") - }) - @GetMapping(value = "/deleteRess") - public ResponseMsg<Integer> deleteRess(@RequestParam List<Integer> ids) { - try { - if (ids == null || ids.isEmpty()) { - return fail("id鏁扮粍涓嶈兘涓虹┖", -1); - } - - permsService.clearPermsCache(); - int count = resService.deleteRess(ids); - - return success(count); - } catch (Exception ex) { - return fail(ex, -1); - } - } - - @SysLog() - @ApiOperation(value = "鏇存柊涓�鏉�") - @ApiImplicitParams({ - @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "ResEntity", paramType = "body", example = "") - }) - @ResponseBody - @PostMapping(value = "/updateRes", produces = "application/json; charset=UTF-8") - public ResponseMsg<Integer> updateRes(@RequestBody ResEntity entity, HttpServletRequest req) { - try { - UserEntity ue = tokenService.getCurrentUser(req); - if (ue != null) { - entity.setUpdateUser(ue.getId()); - } - - permsService.clearPermsCache(); - int count = resService.updateRes(entity); - - return success(count); - } catch (Exception ex) { - return fail(ex, -1); - } - } - - @SysLog() - @ApiOperation(value = "鏍规嵁ID鏌ヨ") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") - }) - @GetMapping(value = "/selectRes") - public ResponseMsg<ResEntity> selectRes(int id) { - try { - ResEntity resEntity = resService.selectRes(id); - - return success(resEntity); - } catch (Exception ex) { - return fail(ex, null); - } - } - - @SysLog() - @ApiOperation(value = "鏌ヨ鎵�鏈�") - @GetMapping(value = "/selectResAll") - public ResponseMsg<List<ResEntity>> selectResAll() { - try { - List<ResEntity> list = resService.selectResAll(); + List<ResEntity> list = resService.selectAll(); return success(list); } catch (Exception ex) { @@ -275,7 +119,160 @@ } @SysLog() - @ApiOperation(value = "涓婁紶鏂囦欢") + @Operation(summary = "鏍规嵁ID鏌ヨ") + @Parameters({ + @Parameter(name = "id", description = "ID", in = ParameterIn.QUERY, example = "1") + }) + @GetMapping(value = "/selectById") + public ResponseMsg<ResEntity> selectById(int id) { + try { + ResEntity entity = resService.selectById(id); + + return success(entity); + } catch (Exception ex) { + return fail(ex, null); + } + } + + @SysLog() + @Operation(summary = "鎻掑叆涓�鏉�") + @Parameters({ + @Parameter(name = "entity", description = "瀹炰綋绫�") + }) + @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> insert(@RequestBody ResEntity entity, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + entity.setCreateUser(ue.getId()); + entity.setDepid(ue.getDepcode()); + } + + permsService.clearPermsCache(); + int count = resService.insert(entity); + + return success(count); + } catch (Exception ex) { + return fail(ex, -1); + } + } + + @SysLog() + @Operation(summary = "鎻掑叆澶氭潯") + @Parameters({ + @Parameter(name = "list", description = "瀹炰綋绫婚泦鍚�") + }) + @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> inserts(@RequestBody List<ResEntity> list, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + for (ResEntity entity : list) { + entity.setCreateUser(ue.getId()); + entity.setDepid(ue.getDepcode()); + } + } + + permsService.clearPermsCache(); + int count = resService.inserts(list); + + return success(count); + } catch (Exception ex) { + return fail(ex, -1); + } + } + + @SysLog() + @Operation(summary = "鍒犻櫎涓�鏉�") + @Parameters({ + @Parameter(name = "id", description = "ID", in = ParameterIn.QUERY, example = "1") + }) + @GetMapping(value = "/delete") + public ResponseMsg<Integer> delete(int id) { + try { + permsService.clearPermsCache(); + int count = resService.delete(id); + + return success(count); + } catch (Exception ex) { + return fail(ex, -1); + } + } + + @SysLog() + @Operation(summary = "鍒犻櫎澶氭潯") + @Parameters({ + @Parameter(name = "ids", description = "ID鏁扮粍", in = ParameterIn.QUERY, example = "1,2") + }) + @GetMapping(value = "/deletes") + public ResponseMsg<Integer> deletes(@RequestParam List<Integer> ids) { + try { + if (ids == null || ids.isEmpty()) { + return fail("id鏁扮粍涓嶈兘涓虹┖", -1); + } + + permsService.clearPermsCache(); + String strs = StringHelper.join(ids, ","); + int count = resService.deletes(strs); + + return success(count); + } catch (Exception ex) { + return fail(ex, -1); + } + } + + @SysLog() + @Operation(summary = "鏇存柊涓�鏉�") + @Parameters({ + @Parameter(name = "entity", description = "瀹炰綋绫�") + }) + @ResponseBody + @PostMapping(value = "/update", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> update(@RequestBody ResEntity entity, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + entity.setUpdateUser(ue.getId()); + entity.setDepid(ue.getDepcode()); + } + + permsService.clearPermsCache(); + int count = resService.update(entity); + + return success(count); + } catch (Exception ex) { + return fail(ex, -1); + } + } + + @SysLog() + @Operation(summary = "鏇存柊澶氭潯") + @Parameters({ + @Parameter(name = "list", description = "瀹炰綋绫婚泦鍚�") + }) + @ResponseBody + @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8") + public ResponseMsg<Integer> updates(@RequestBody List<ResEntity> list, HttpServletRequest req) { + try { + UserEntity ue = tokenService.getCurrentUser(req); + if (ue != null) { + for (ResEntity entity : list) { + entity.setUpdateUser(ue.getId()); + entity.setDepid(ue.getDepcode()); + } + } + + permsService.clearPermsCache(); + int count = resService.updates(list); + + return success(count); + } catch (Exception ex) { + return fail(ex, -1); + } + } + + @SysLog() + @Operation(summary = "涓婁紶鏂囦欢") @ResponseBody @PostMapping(value = "/upload") public ResponseMsg<String> upload(@RequestParam("file") MultipartFile file, HttpServletRequest req) { @@ -285,9 +282,9 @@ } @SysLog() - @ApiOperation(value = "涓嬭浇鏂囦欢") - @ApiImplicitParams({ - @ApiImplicitParam(name = "guid", value = "闄勪欢Guid", dataType = "String", paramType = "body") + @Operation(summary = "涓嬭浇鏂囦欢") + @Parameters({ + @Parameter(name = "guid", description = "闄勪欢Guid") }) @GetMapping(value = "/download") public void download(String guid, HttpServletResponse res) { @@ -295,9 +292,9 @@ } @SysLog() - @ApiOperation(value = "鏌ョ湅鏂囦欢") - @ApiImplicitParams({ - @ApiImplicitParam(name = "guid", value = "闄勪欢Guid", dataType = "String", paramType = "body") + @Operation(summary = "鏌ョ湅鏂囦欢") + @Parameters({ + @Parameter(name = "guid", description = "闄勪欢Guid") }) @GetMapping(value = "/downloadForView") public void downloadForView(String guid, HttpServletResponse res) { -- Gitblit v1.9.3