From e430bfca38cdae9dd230f951e108a75caebccb61 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 24 四月 2024 10:56:47 +0800
Subject: [PATCH] 完善代码
---
/dev/null | 14 -------
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/log/LogCtrl.java | 7 +--
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogSv.java | 28 --------------
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/Log.java | 2
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java | 6 +-
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java | 16 ++++----
pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java | 12 +++---
pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java | 8 ++--
8 files changed, 25 insertions(+), 68 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationDescription.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/Log.java
similarity index 86%
rename from pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationDescription.java
rename to pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/Log.java
index 58c9bcd..ef10f65 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationDescription.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/Log.java
@@ -7,6 +7,6 @@
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
-public @interface OperationDescription {
+public @interface Log {
String value();
}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationLogAspect.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
similarity index 95%
rename from pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationLogAspect.java
rename to pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
index 919556a..0902667 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/OperationLogAspect.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogAspect.java
@@ -27,7 +27,7 @@
@Aspect
@Component
-public class OperationLogAspect {
+public class LogAspect {
@Value("${pms.sso.curUserUrl}")
public String SsoCurUserUrl ;
@@ -43,11 +43,11 @@
this.restTemplate = restTemplate ;
}
- @AfterReturning(pointcut = "@annotation(com.dy.pmsGlobal.aop.OperationDescription)", returning = "result")
+ @AfterReturning(pointcut = "@annotation(com.dy.pmsGlobal.aop.Log)", returning = "result")
public void logAfterReturning(JoinPoint joinPoint, Object result) {
// 鑾峰彇鏂规硶鐨勪腑鏂囨弿杩�
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
- OperationDescription operationDescription = methodSignature.getMethod().getAnnotation(OperationDescription.class);
+ Log operationDescription = methodSignature.getMethod().getAnnotation(Log.class);
String operationName = operationDescription.value();
//缁撴灉
BaseResponse response = (BaseResponse)result;
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogSv.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogSv.java
index 838e72b..f31954b 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogSv.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/LogSv.java
@@ -26,32 +26,4 @@
dao.insert(log);
}
- /**
- * 寰楀埌鏃ュ織
- *
- * @param id 鏃ュ織ID
- * @return 瀹炰綋
- */
- public BaLog selectById(Long id) {
- return dao.selectByPrimaryKey(id);
- }
-
-
- /**
- * 鑾峰彇鏃ュ織鍒楄〃
- */
- public QueryResultVo<List<BaLog>> selectSome(QueryVo queryVo) {
- Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
-
- //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
- Long itemTotal = dao.selectSomeCount(params);
-
- QueryResultVo<List<BaLog>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr) ;
- //璁$畻鍒嗛〉绛変俊鎭�
- rsVo.calculateAndSet(itemTotal, params);
-
- //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
- rsVo.obj = this.dao.selectSome(params) ;
- return rsVo ;
- }
}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/QueryVo.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/QueryVo.java
deleted file mode 100644
index ee07597..0000000
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/aop/QueryVo.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.dy.pmsGlobal.aop;
-
-import com.dy.common.webUtil.QueryConditionVo;
-import lombok.*;
-
-@Data
-@EqualsAndHashCode(callSuper = false)
-@ToString(callSuper = true)
-@NoArgsConstructor
-@AllArgsConstructor
-@Builder
-public class QueryVo extends QueryConditionVo {
- public String name;
-}
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/log/LogCtrl.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/log/LogCtrl.java
index a64949a..e0be1b7 100644
--- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/log/LogCtrl.java
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/log/LogCtrl.java
@@ -5,8 +5,7 @@
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pmsGlobal.aop.LogSv;
-import com.dy.pmsGlobal.aop.OperationDescription;
-import com.dy.pmsGlobal.aop.QueryVo;
+import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +31,7 @@
*/
@GetMapping(path = "one")
@SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("鏌ヨ鍗曟潯鏃ュ織")
+ @Log("鏌ヨ鍗曟潯鏃ュ織")
public BaseResponse<BaLog> one(String id){
try {
return BaseResponseUtils.buildSuccess(sv.selectById(Long.parseLong(id)));
@@ -48,7 +47,7 @@
*/
@PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
@SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("鍒嗛〉鏌ヨ鏃ュ織")
+ @Log("鍒嗛〉鏌ヨ鏃ュ織")
public BaseResponse<QueryResultVo<List<BaLog>>> some(@RequestBody QueryVo vo){
try {
QueryResultVo<List<BaLog>> res = sv.selectSome(vo);
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java
index 0b31b90..cb14cc5 100644
--- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/role/RoleCtrl.java
@@ -5,7 +5,7 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
-import com.dy.pmsGlobal.aop.OperationDescription;
+import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaRole;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
@@ -37,7 +37,7 @@
*/
@PostMapping(path="save")
@SsoPowerAop(power = "10100011")
- @OperationDescription("淇濆瓨瑙掕壊淇℃伅")
+ @Log("淇濆瓨瑙掕壊淇℃伅")
public BaseResponse<BaRole> save(@RequestBody @Valid BaRole role,BindingResult bindingResult){
try {
role.setDeleted(false);
@@ -58,7 +58,7 @@
*/
@PostMapping(path="update")
@SsoPowerAop(power = "10100011")
- @OperationDescription("鏇存柊瑙掕壊淇℃伅")
+ @Log("鏇存柊瑙掕壊淇℃伅")
public BaseResponse<BaRole> update(@RequestBody @Valid BaRole role,BindingResult bindingResult){
try {
return BaseResponseUtils.buildSuccess(roleSv.update(role));
@@ -76,7 +76,7 @@
*/
@PostMapping(path="delete")
@SsoPowerAop(power = "10100011")
- @OperationDescription("鍒犻櫎瑙掕壊淇℃伅")
+ @Log("鍒犻櫎瑙掕壊淇℃伅")
public BaseResponse<BaRole> delete(String id,BindingResult bindingResult){
try {
return BaseResponseUtils.buildSuccess(roleSv.delete(Long.parseLong(id)));
@@ -93,7 +93,7 @@
*/
@GetMapping(path="one")
@SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("鏍规嵁ID鏌ヨ瑙掕壊淇℃伅")
+ @Log("鏍规嵁ID鏌ヨ瑙掕壊淇℃伅")
public BaseResponse<BaRole> one(String id){
try{
BaRole role=roleSv.selectById(id);
@@ -111,7 +111,7 @@
*/
@PostMapping(path="some")
@SsoPowerAop(power = "10100010")
- @OperationDescription("鍒嗛〉鏌ヨ瑙掕壊淇℃伅")
+ @Log("鍒嗛〉鏌ヨ瑙掕壊淇℃伅")
public BaseResponse<QueryResultVo<List<BaRole>>> some(@RequestBody QueryVo vo){
try {
QueryResultVo<List<BaRole>> list = roleSv.selectSome(vo) ;
diff --git a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
index 603ad0d..5cc283c 100644
--- a/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
+++ b/pms-parent/pms-web-base/src/main/java/com/dy/pmsBase/user/UserCtrl.java
@@ -6,7 +6,7 @@
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
-import com.dy.pmsGlobal.aop.OperationDescription;
+import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.dy.pmsGlobal.util.Constant;
import com.mysql.cj.util.StringUtils;
@@ -45,7 +45,7 @@
* @return 榛樿瀵嗙爜
*/
@GetMapping(path = "defaultPassword")
- @OperationDescription("瀹㈡埛绔姹傚緱鍒伴粯璁ゅ瘑鐮�")
+ @Log("瀹㈡埛绔姹傚緱鍒伴粯璁ゅ瘑鐮�")
public BaseResponse<String> defaultPassword(){
if(defaultTrueRandomFalsePassword){
return BaseResponseUtils.buildSuccess(defaultPassword) ;
@@ -62,7 +62,7 @@
@PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
@SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("鍒嗛〉鏌ヨ鐢ㄦ埛")
+ @Log("鍒嗛〉鏌ヨ鐢ㄦ埛")
public BaseResponse<QueryResultVo<List<BaUser>>> some(@RequestBody QueryVo vo) {
try {
QueryResultVo<List<BaUser>> res = this.sv.selectSome(vo);
@@ -81,7 +81,7 @@
@GetMapping(path = "one")
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
@SsoPowerAop(power = "10100010") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("鏌ヨ鍗曚釜鐢ㄦ埛")
+ @Log("鏌ヨ鍗曚釜鐢ㄦ埛")
public BaseResponse<BaUser> one(String id) {
try {
return BaseResponseUtils.buildSuccess(this.sv.selectById(Long.parseLong(id)));
@@ -100,7 +100,7 @@
@PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
@SsoPowerAop(power = "10100011") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("淇濆瓨鐢ㄦ埛淇℃伅")
+ @Log("淇濆瓨鐢ㄦ埛淇℃伅")
public BaseResponse<Boolean> save(@RequestBody @Valid BaUser po, BindingResult bindingResult) {
if (bindingResult != null && bindingResult.hasErrors()) {
return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
@@ -141,7 +141,7 @@
@PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
@SsoPowerAop(power = "10100011") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("鏇存柊鐢ㄦ埛淇℃伅")
+ @Log("鏇存柊鐢ㄦ埛淇℃伅")
public BaseResponse<Boolean> update(@RequestBody @Validated BaUser po, BindingResult bindingResult) {
int count;
try {
@@ -174,7 +174,7 @@
//@GetMapping(path = "changePassword", consumes = MediaType.TEXT_PLAIN_VALUE)
@GetMapping(path = "changePassword")
@SsoAop()
- @OperationDescription("淇敼瀵嗙爜")
+ @Log("淇敼瀵嗙爜")
public BaseResponse<Boolean> changePassword(String id, String oldPassword, String newPassword) {
int count;
try {
@@ -227,7 +227,7 @@
@PostMapping(path = "resetPassword", consumes = MediaType.APPLICATION_JSON_VALUE)
//@SsoAop() //鍙湁鐧诲綍楠岃瘉锛屾病鏈夋潈闄愰獙璇�
@SsoPowerAop(power = "10100011") //鐧诲綍涓庢潈闄愬悓鏃堕獙璇�
- @OperationDescription("閲嶇疆瀵嗙爜")
+ @Log("閲嶇疆瀵嗙爜")
public BaseResponse<Boolean> resetPassword(@RequestBody @Validated ResetPasswordVo vo, BindingResult bindingResult) {
int count;
try {
diff --git a/pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java b/pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
index 2e9b29c..8d16790 100644
--- a/pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
+++ b/pms-parent/pms-web-sso/src/main/java/com/dy/sso/busi/SsoCtrl.java
@@ -4,7 +4,7 @@
import com.dy.common.util.MD5;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
-import com.dy.pmsGlobal.aop.OperationDescription;
+import com.dy.pmsGlobal.aop.Log;
import com.dy.pmsGlobal.pojoBa.BaUser;
import com.mysql.cj.util.StringUtils;
import jakarta.servlet.http.HttpServletRequest;
@@ -46,7 +46,7 @@
* @return 鐧诲綍鐢ㄦ埛鍊煎璞�
*/
@PostMapping(path = "login", consumes = MediaType.APPLICATION_JSON_VALUE)//鍓嶇鎻愪氦json鏁版嵁
- @OperationDescription("鐢ㄦ埛鐧诲綍(json)")
+ @Log("鐢ㄦ埛鐧诲綍(json)")
public BaseResponse<UserVo> login(@RequestBody @Valid LoginVo vo, BindingResult bindingResult) {
try {
if(bindingResult != null && bindingResult.hasErrors()){
@@ -65,7 +65,7 @@
* @return 鐧诲綍鐢ㄦ埛鍊煎璞�
*/
@PostMapping(path = "loginForm", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)//鍓嶇鎻愪氦form琛ㄥ崟鏁版嵁
- @OperationDescription("鐢ㄦ埛鐧诲綍(form)")
+ @Log("鐢ㄦ埛鐧诲綍(form)")
public BaseResponse<UserVo> loginForm(@RequestBody @Valid LoginVo vo, BindingResult bindingResult){
try{
if(bindingResult != null && bindingResult.hasErrors()){
@@ -85,7 +85,7 @@
* @return 姝e父閫�鍑虹櫥褰曡繑鍥瀟rue锛屽惁鍒欒繑鍥瀎alse
*/
@GetMapping(path = "logout")
- @OperationDescription("閫�鍑虹櫥褰�")
+ @Log("閫�鍑虹櫥褰�")
public BaseResponse<Boolean> logout(HttpServletRequest hr){
try{
String token = hr.getHeader("token") ;
--
Gitblit v1.8.0