From 5e9857ee99eb411e3cdc94bd59c77ea0c7741675 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Wed, 23 Apr 2025 16:25:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=B8=B4=E6=97=B6=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E7=99=BB=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/readme.md | 8 + ...troller.java => SystemUserController.java} | 17 +- .../systemuser/SystemUserRouteController.java | 23 +- .../auth/LoginTemporaryAuthFilter.java | 2 +- .../auth/LoginWxOauth2AuthProvider.java | 2 +- .../temporary/LoginTemporaryService.java | 6 +- src/main/resources/application-dev.yml | 7 +- .../resources/templates/systemuser/home.html | 614 ++++++++++++++++++ .../templates/systemuser/system-select.html | 51 ++ .../templates/systemuser/temporary-login.html | 21 + 10 files changed, 739 insertions(+), 12 deletions(-) rename src/main/java/cn/com/tenlion/operator/controller/api/systemuser/{SystemUserApiontroller.java => SystemUserController.java} (83%) create mode 100644 src/main/resources/templates/systemuser/home.html create mode 100644 src/main/resources/templates/systemuser/system-select.html create mode 100644 src/main/resources/templates/systemuser/temporary-login.html diff --git a/doc/readme.md b/doc/readme.md index 658e430..29c0414 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -10,6 +10,14 @@ ADD COLUMN `wx_open_id` varchar(255) NULL COMMENT '微信-开放平台-openid' A ADD COLUMN `wx_union_id` varchar(255) NULL COMMENT '微信-开放平台-unionid' AFTER `wx_open_id`; ``` +## 开放白名单 + +### 临时登录接口 + +``` +/router/systemuser/temporary-login +``` + # 20250325(已上线) ## user_expand diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/systemuser/SystemUserApiontroller.java b/src/main/java/cn/com/tenlion/operator/controller/api/systemuser/SystemUserController.java similarity index 83% rename from src/main/java/cn/com/tenlion/operator/controller/api/systemuser/SystemUserApiontroller.java rename to src/main/java/cn/com/tenlion/operator/controller/api/systemuser/SystemUserController.java index 1b5b0e2..3d65a43 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/api/systemuser/SystemUserApiontroller.java +++ b/src/main/java/cn/com/tenlion/operator/controller/api/systemuser/SystemUserController.java @@ -3,12 +3,12 @@ package cn.com.tenlion.operator.controller.api.systemuser; import cn.com.tenlion.operator.pojo.dtos.account.AccountDTO; import cn.com.tenlion.operator.service.account.IAccountService; import cn.com.tenlion.operator.service.custompersonal.ICustomPersonalService; +import cn.com.tenlion.operator.service.login.temporary.LoginTemporaryService; import cn.com.tenlion.projectconfig.util.ProjectConfigUtil; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.exceptions.SearchException; import ink.wgink.interfaces.consts.ISystemConstant; -import ink.wgink.interfaces.user.IUserBaseService; import ink.wgink.pojo.result.ErrorResult; import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultData; @@ -16,7 +16,6 @@ import ink.wgink.service.user.service.IUserService; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; /** * @ClassName: SystemUserlController @@ -28,7 +27,7 @@ import org.springframework.web.servlet.ModelAndView; @Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "系统用户接口") @RestController @RequestMapping(ISystemConstant.API_PREFIX + "/systemuser") -public class SystemUserApiontroller extends DefaultBaseController { +public class SystemUserController extends DefaultBaseController { @Autowired private ICustomPersonalService customPersonalService; @@ -38,6 +37,8 @@ public class SystemUserApiontroller extends DefaultBaseController { @Autowired private IUserService iUserService; + @Autowired + private LoginTemporaryService loginTemporaryService; @ApiOperation(value = "更改开放状态", notes = "更改开放状态") @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @@ -77,4 +78,14 @@ public class SystemUserApiontroller extends DefaultBaseController { throw new SearchException("系统错误"); } + @GetMapping("get-temporary-password") + public SuccessResultData getTemporaryPassword() { + return new SuccessResultData<>(loginTemporaryService.getPassword()); + } + + @GetMapping("generate-temporary-password") + public SuccessResultData generateTemporaryPassword() { + return new SuccessResultData<>(loginTemporaryService.generatePassword()); + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/controller/route/systemuser/SystemUserRouteController.java b/src/main/java/cn/com/tenlion/operator/controller/route/systemuser/SystemUserRouteController.java index 1a307aa..fda7074 100644 --- a/src/main/java/cn/com/tenlion/operator/controller/route/systemuser/SystemUserRouteController.java +++ b/src/main/java/cn/com/tenlion/operator/controller/route/systemuser/SystemUserRouteController.java @@ -64,7 +64,7 @@ public class SystemUserRouteController extends DefaultBaseController { List roleSimpleDTOList = userInfoBO.getRoles(); String url = systemProperties.getUrl(); if (userInfoBO.getUserId().equals("1")) { - return new ModelAndView("forward:/default-main"); + return new ModelAndView("forward:/route/systemuser/system-select"); } if (roleSimpleDTOList == null || roleSimpleDTOList.isEmpty()) { throw new SaveException("角色不存在"); @@ -73,7 +73,7 @@ public class SystemUserRouteController extends DefaultBaseController { StringUtils.contains("项目运营", roleSimpleDTO.getRoleName()) || StringUtils.contains("开发人员", roleSimpleDTO.getRoleName())); if (isAdmin || userInfoBO.getUserId().equals("1")) { - return new ModelAndView("forward:/default-main"); + return new ModelAndView("forward:/route/systemuser/system-select"); } else if (roleSimpleDTOList.stream().anyMatch(roleSimpleDTO -> StringUtils.contains("普通用户", roleSimpleDTO.getRoleName()))) { return new ModelAndView(new RedirectView(ProjectConfigUtil.getText("AiServerUrl"))); } @@ -99,5 +99,24 @@ public class SystemUserRouteController extends DefaultBaseController { return mv; } + @GetMapping("home") + public ModelAndView home() { + ModelAndView mv = new ModelAndView(); + mv.setViewName("systemuser/home"); + return mv; + } + + @GetMapping("system-select") + public ModelAndView systemSelect() { + ModelAndView mv = new ModelAndView(); + mv.setViewName("systemuser/system-select"); + return mv; + } + + @GetMapping("temporary-login") + public ModelAndView temporaryLogin() { + ModelAndView mv = new ModelAndView("systemuser/temporary-login"); + return mv; + } } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/operator/login/temporary/auth/LoginTemporaryAuthFilter.java b/src/main/java/cn/com/tenlion/operator/login/temporary/auth/LoginTemporaryAuthFilter.java index ac13f05..6125e67 100644 --- a/src/main/java/cn/com/tenlion/operator/login/temporary/auth/LoginTemporaryAuthFilter.java +++ b/src/main/java/cn/com/tenlion/operator/login/temporary/auth/LoginTemporaryAuthFilter.java @@ -22,7 +22,7 @@ public class LoginTemporaryAuthFilter extends AbstractAuthenticationProcessingFi private final LoginTemporaryService loginTemporaryService; public LoginTemporaryAuthFilter(LoginTemporaryService loginTemporaryService) { - super(new AntPathRequestMatcher("/oauth/temporary", "POST")); + super(new AntPathRequestMatcher("/oauth/temporary/login", "POST")); this.loginTemporaryService = loginTemporaryService; } diff --git a/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthProvider.java b/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthProvider.java index e1b22e3..6121a30 100644 --- a/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthProvider.java +++ b/src/main/java/cn/com/tenlion/operator/login/wx/oauth2/auth/LoginWxOauth2AuthProvider.java @@ -75,7 +75,7 @@ public class LoginWxOauth2AuthProvider implements AuthenticationProvider { username = openid; } else { UserPO userPO = userService.getPO(userExpandPO.getUserId()); - username = userPO.getUserName(); + username = userPO.getUserUsername(); if (userPO.getUserState() == 1) { userService.updateUserState(userPO.getUserId(), UserStateEnum.NORMAL); } diff --git a/src/main/java/cn/com/tenlion/operator/service/login/temporary/LoginTemporaryService.java b/src/main/java/cn/com/tenlion/operator/service/login/temporary/LoginTemporaryService.java index 9c957ed..a3f67e1 100644 --- a/src/main/java/cn/com/tenlion/operator/service/login/temporary/LoginTemporaryService.java +++ b/src/main/java/cn/com/tenlion/operator/service/login/temporary/LoginTemporaryService.java @@ -1,5 +1,6 @@ package cn.com.tenlion.operator.service.login.temporary; +import ink.wgink.util.UUIDUtil; import ink.wgink.util.string.WStringUtil; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -11,9 +12,10 @@ public class LoginTemporaryService { private long lastUpdateTime = 0; public String generatePassword() { - String code = "" + System.currentTimeMillis(); + String code = UUIDUtil.get32UUID(); this.lastUpdateTime = System.currentTimeMillis(); - return WStringUtil.randomSubStr(code, 6); + this.password = WStringUtil.randomSubStr(code, 10); + return password; } public String getPassword() { diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 83c06c8..8cf09f8 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -2,10 +2,11 @@ server: port: 8091 # url: http://127.0.0.1:8091/operator/ url: http://121.36.71.250:58038/operator/ - ip: 127.0.0.1 + ip: 121.36.71.250 system-title: 运营平台 system-sub-title: 运营平台 default-index-page: route/systemuser/index + default-home-page: route/systemuser/home servlet: context-path: /operator @@ -116,7 +117,7 @@ file: security: oauth2: - oauth-server: http://127.0.0.1:8091/operator/ + oauth-server: http://121.36.71.250:58038/operator/ oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url} client: client-id: 46c4715a2a504dd48398bda88b5c3a88 @@ -134,7 +135,7 @@ security: api-path: user-center: http://127.0.0.1:8091/operator/ copyright: http://127.0.0.1:7025/copyright/ - copyright-external: http://192.168.0.15:7025/copyright/ + copyright-external: http://121.36.71.250:58038/copyright/ operator-plugin: http://192.168.0.15:8099/operator-plugin/ diff --git a/src/main/resources/templates/systemuser/home.html b/src/main/resources/templates/systemuser/home.html new file mode 100644 index 0000000..8fa9ecf --- /dev/null +++ b/src/main/resources/templates/systemuser/home.html @@ -0,0 +1,614 @@ + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+ 系统登录用户量 + +
+
+

0

+

+ 增长率 + + 0% + +

+
+
+
+
+
+
+ 新增用户量 + +
+
+

0

+

+ 占比 + + 0% + +

+
+
+
+
+
+
+ 总用户量 + +
+
+

0

+

+ 增长人数 + + 0 + +

+
+
+
+
+
+
+
+
+
+ 临时密码 + +
+
+ + + + +
+
+
+
+
+
+
+ 角色数量 + +
+
+

0

+
+
+
+
+
+
+ 职位数量 + +
+
+

0

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
用户状态占比
+
+
+
+
+
+
+
+
用户类型占比
+
+
+
+
+
+
+
+
+
+
+ 系统登录日志(最新10条) +
+
+ + + + + + + + + + + + + +
+ {{loginLogger.creatorName}} 登录了系统 + {{loginLogger.loginAddress}} {{loginLogger.gmtCreate}}
+
+
+
+
+
+
+ 用户调整日志(最新10条) +
+
+ + + + + + + + + + + + + +
+ {{userAdjustment.userName}} 变更了用户名为 {{userAdjustment.newValue}} + + {{userAdjustment.userName}} 修改了密码 + + {{userAdjustment.userName}} 重置了密码为 {{userAdjustment.newValue}} + {{userAdjustment.gmtCreate}}
+
+
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/systemuser/system-select.html b/src/main/resources/templates/systemuser/system-select.html new file mode 100644 index 0000000..7e3a7a7 --- /dev/null +++ b/src/main/resources/templates/systemuser/system-select.html @@ -0,0 +1,51 @@ + + + + + + + + + AI喵著 + + + +
+
+
+ +
统一用户
+
+
+ +
运营平台
+
+
+ +
喵著系统
+
+
+
+ + + + \ No newline at end of file diff --git a/src/main/resources/templates/systemuser/temporary-login.html b/src/main/resources/templates/systemuser/temporary-login.html new file mode 100644 index 0000000..ec18dc9 --- /dev/null +++ b/src/main/resources/templates/systemuser/temporary-login.html @@ -0,0 +1,21 @@ + + + + + + 临时登录 + + +
+
+ + +
+
+ + +
+ +
+ + \ No newline at end of file