From b956084da4529bc466aa226962571a0c070a40b3 Mon Sep 17 00:00:00 2001 From: wxc <191104855@qq.com> Date: Fri, 8 Mar 2024 17:39:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E7=BE=A4=E4=BC=97=E7=AB=AF=E9=99=90?= =?UTF-8?q?=E5=88=B6=E4=BA=BA=E8=84=B8=E8=AE=A4=E8=AF=81=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E4=B8=BA8=E5=B0=8F=E6=97=B6=202.=20=E7=BE=A4=E4=BC=97?= =?UTF-8?q?=E7=AB=AF=E8=B0=83=E6=95=B4=E7=9F=AD=E4=BF=A1=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E4=B8=BA10=E5=88=86=E9=92=9F=203.=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8C=89=E9=92=AE=E6=B3=A8=E8=A7=A3=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=9A=84=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flow.json | 3 -- .../biutag/lan/config/AdminInterceptor.java | 9 +++++ .../biutag/lan/config/stp/StpInterConfig.java | 2 - .../java/com/biutag/lan/ws/WsController.java | 3 +- .../outer/controller/AuthController.java | 22 +++++++---- .../com/biutag/outer/domain/bo/AuthUser.java | 38 +++++++++++++++++++ .../com/biutag/outer/service/UserService.java | 3 +- .../java/com/biutag/outer/util/CodeUtil.java | 4 +- .../java/com/biutag/outer/util/TokenUtil.java | 9 +++-- .../com/biutag/outer/util/UserHelper.java | 7 ++-- .../java/com/biutag/outer/DurationTest.java | 15 ++++++++ truncate.sql | 1 + 12 files changed, 91 insertions(+), 25 deletions(-) create mode 100644 mailbox-outer/src/main/java/com/biutag/outer/domain/bo/AuthUser.java create mode 100644 mailbox-outer/src/test/java/com/biutag/outer/DurationTest.java diff --git a/flow.json b/flow.json index 752e1f9..e69de29 100644 --- a/flow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5POc565zQhlCOVpNTnkmXYiwjcp6456+9QN9ritEMvz2bEEj+NVzxz0I/WtyK0SNX8w72l++x79qhNg7L5LzM0XTZgdPTPWmFzRGMcUUUUiT//R7GiiiszMKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigD/0uxooorMzCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA/9k=" -} \ No newline at end of file diff --git a/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java b/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java index a5719f9..d7f2e72 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/config/AdminInterceptor.java @@ -1,5 +1,6 @@ package com.biutag.lan.config; +import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.stp.StpUtil; import com.alibaba.fastjson2.JSON; import com.biutag.aop.NotLogin; @@ -159,6 +160,14 @@ public class AdminInterceptor implements HandlerInterceptor { if (StringUtils.isNotNull(method) && method.isAnnotationPresent(NotPower.class)) { break; } + if (StringUtils.isNotNull(method) && method.isAnnotationPresent(SaCheckPermission.class)) { + String[] auths = method.getAnnotation(SaCheckPermission.class).value(); + for (String auth : auths) { + // 校验权限 + StpUtil.checkPermission(auth); + } + break; + } // 路由转权限 String prefix = "/api/"; String route = uri.replaceFirst(prefix, ""); diff --git a/mailbox-lan/src/main/java/com/biutag/lan/config/stp/StpInterConfig.java b/mailbox-lan/src/main/java/com/biutag/lan/config/stp/StpInterConfig.java index 3715e96..44809b4 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/config/stp/StpInterConfig.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/config/stp/StpInterConfig.java @@ -39,11 +39,9 @@ public class StpInterConfig implements StpInterface { public List getPermissionList(Object loginId, String loginType) { List roleIds = AdminThreadLocal.getRoleIds(); List perms = new LinkedList<>(); - if (roleIds.isEmpty()) { return perms; } - List permList = PermMapper.selectList( new QueryWrapper() .select("id,role_id,menu_id") diff --git a/mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java b/mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java index d0b5724..8d2d6f2 100644 --- a/mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java +++ b/mailbox-lan/src/main/java/com/biutag/lan/ws/WsController.java @@ -14,9 +14,10 @@ import org.springframework.stereotype.Controller; public class WsController { @MessageMapping("/con") - public void con(JSONObject message) { + public AjaxResult con(JSONObject message) { System.out.println("con"); System.out.println(message.toJSONString()); + return AjaxResult.success(); } } diff --git a/mailbox-outer/src/main/java/com/biutag/outer/controller/AuthController.java b/mailbox-outer/src/main/java/com/biutag/outer/controller/AuthController.java index 4dc71f7..c3ab15d 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/controller/AuthController.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/controller/AuthController.java @@ -5,8 +5,10 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.biutag.core.AjaxResult; +import com.biutag.enums.ErrorEnum; import com.biutag.exception.AuthException; import com.biutag.outer.domain.User; +import com.biutag.outer.domain.bo.AuthUser; import com.biutag.outer.domain.bo.FaceAuthBo; import com.biutag.outer.service.FaceAuthService; import com.biutag.outer.service.UserService; @@ -14,7 +16,6 @@ import com.biutag.outer.util.TokenUtil; import com.biutag.outer.util.UserHelper; import com.biutag.outer.util.Weixin; import com.biutag.outer.util.Weixin2; -import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; @@ -48,30 +49,35 @@ public class AuthController { user.setCreateTime(LocalDateTime.now()); userService.save(user); } - return AjaxResult.success(JSONObject.of("token", TokenUtil.set(user), "user", user)); + return AjaxResult.success(JSONObject.of("token", TokenUtil.set(AuthUser.of(user)), "user", user)); } @PostMapping("openid") public AjaxResult openid(@RequestParam String openid) { User user = userService.getByOpenid(openid); - return AjaxResult.success(JSONObject.of("token", TokenUtil.set(user), "user", user)); + AuthUser authUser = AuthUser.of(user); + return AjaxResult.success(JSONObject.of("token", TokenUtil.set(authUser), "user", authUser)); } @GetMapping("user") - public AjaxResult user() { + public AjaxResult user() { return AjaxResult.success(UserHelper.getCurrentUser()); } @GetMapping("realUser") - public AjaxResult realUser(@RequestParam Integer userId) { + public AjaxResult realUser(@RequestParam Integer userId) { log.info("请求 realUser: {}", userId); User user = userService.getById(userId); - if (user != null && StrUtil.isNotBlank(user.getIdCard())) { + if (user == null) { + return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg()); + } + AuthUser authUser = AuthUser.of(user); + if (StrUtil.isNotBlank(user.getIdCard())) { log.info("用户信息:{}", JSON.toJSONString(user)); // 更新用户信息 - UserHelper.update(user); + UserHelper.update(authUser); } - return AjaxResult.success(user); + return AjaxResult.success(authUser); } @GetMapping("wx/sign") diff --git a/mailbox-outer/src/main/java/com/biutag/outer/domain/bo/AuthUser.java b/mailbox-outer/src/main/java/com/biutag/outer/domain/bo/AuthUser.java new file mode 100644 index 0000000..591e801 --- /dev/null +++ b/mailbox-outer/src/main/java/com/biutag/outer/domain/bo/AuthUser.java @@ -0,0 +1,38 @@ +package com.biutag.outer.domain.bo; + +import cn.hutool.core.util.StrUtil; +import com.biutag.outer.domain.User; +import lombok.Getter; +import lombok.Setter; +import org.springframework.beans.BeanUtils; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.util.Objects; + +@Setter +@Getter +public class AuthUser { + + private Integer id; + + private String openid; + + private String phone; + + private String realName; + + private String idCard; + + private Boolean faceAuth = false; + + public static AuthUser of(User user) { + AuthUser authUser = new AuthUser(); + BeanUtils.copyProperties(user, authUser); + if (StrUtil.isNotBlank(user.getIdCard()) && Objects.nonNull(user.getFaceAuthTime())) { + // 8小时 + authUser.setFaceAuth(Duration.between(user.getFaceAuthTime(), LocalDateTime.now()).toHours() < 8); + } + return authUser; + } +} diff --git a/mailbox-outer/src/main/java/com/biutag/outer/service/UserService.java b/mailbox-outer/src/main/java/com/biutag/outer/service/UserService.java index a57235b..27bee85 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/service/UserService.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/service/UserService.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.biutag.outer.domain.User; +import com.biutag.outer.domain.bo.AuthUser; import com.biutag.outer.mapper.UserMapper; import com.biutag.outer.util.UserHelper; import org.springframework.stereotype.Service; @@ -17,7 +18,7 @@ public class UserService extends ServiceImpl { } public boolean updatePhoneByCurrent(String phone) { - User currentUser = UserHelper.getCurrentUser(); + AuthUser currentUser = UserHelper.getCurrentUser(); boolean updated = update(new LambdaUpdateWrapper().eq(User::getId, currentUser.getId()).set(User::getPhone, phone)); if (updated) { currentUser.setPhone(phone); diff --git a/mailbox-outer/src/main/java/com/biutag/outer/util/CodeUtil.java b/mailbox-outer/src/main/java/com/biutag/outer/util/CodeUtil.java index 09b28b6..3d1c045 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/util/CodeUtil.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/util/CodeUtil.java @@ -9,12 +9,10 @@ import java.util.concurrent.TimeUnit; public class CodeUtil { private static final Cache cache = Caffeine.newBuilder() - .expireAfterWrite(5, TimeUnit.MINUTES) // 设置写入后过期时间 + .expireAfterWrite(10, TimeUnit.MINUTES) // 设置写入后过期时间 .maximumSize(1000) // 最多1000人 .build(); - - public static String set(String code) { String key = IdUtil.fastSimpleUUID(); cache.put(key, code); diff --git a/mailbox-outer/src/main/java/com/biutag/outer/util/TokenUtil.java b/mailbox-outer/src/main/java/com/biutag/outer/util/TokenUtil.java index 9d502bd..eed636e 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/util/TokenUtil.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/util/TokenUtil.java @@ -2,6 +2,7 @@ package com.biutag.outer.util; import cn.hutool.core.util.IdUtil; import com.biutag.outer.domain.User; +import com.biutag.outer.domain.bo.AuthUser; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; import org.springframework.util.Assert; @@ -9,23 +10,23 @@ import org.springframework.util.Assert; import java.util.concurrent.TimeUnit; public class TokenUtil { - private static final Cache cache = Caffeine.newBuilder() + private static final Cache cache = Caffeine.newBuilder() .expireAfterWrite(60, TimeUnit.MINUTES) // 设置写入后过期时间 .maximumSize(1000) // 最多1000人 .build(); - public static String set(User user) { + public static String set(AuthUser user) { Assert.notNull(user, "未找到该用户"); String key = IdUtil.fastSimpleUUID(); cache.put(key, user); return key; } - public static User update(String key, User user) { + public static AuthUser update(String key, AuthUser user) { cache.put(key, user); return user; } - public static User get(String key) { + public static AuthUser get(String key) { return cache.getIfPresent(key); } diff --git a/mailbox-outer/src/main/java/com/biutag/outer/util/UserHelper.java b/mailbox-outer/src/main/java/com/biutag/outer/util/UserHelper.java index bf1ffb3..fa5d152 100644 --- a/mailbox-outer/src/main/java/com/biutag/outer/util/UserHelper.java +++ b/mailbox-outer/src/main/java/com/biutag/outer/util/UserHelper.java @@ -2,24 +2,25 @@ package com.biutag.outer.util; import com.biutag.exception.AuthException; import com.biutag.outer.domain.User; +import com.biutag.outer.domain.bo.AuthUser; import jakarta.servlet.http.HttpServletRequest; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; public class UserHelper { - public static User getCurrentUser() { + public static AuthUser getCurrentUser() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // 获取请求头的值 String authorization = request.getHeader("Authorization"); - User user = TokenUtil.get(authorization); + AuthUser user = TokenUtil.get(authorization); if (user == null) { throw new AuthException(); } return user; } - public static User update(User user) { + public static AuthUser update(AuthUser user) { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // 获取请求头的值 String authorization = request.getHeader("Authorization"); diff --git a/mailbox-outer/src/test/java/com/biutag/outer/DurationTest.java b/mailbox-outer/src/test/java/com/biutag/outer/DurationTest.java new file mode 100644 index 0000000..d61dcba --- /dev/null +++ b/mailbox-outer/src/test/java/com/biutag/outer/DurationTest.java @@ -0,0 +1,15 @@ +package com.biutag.outer; + +import org.junit.jupiter.api.Test; + +import java.time.Duration; +import java.time.LocalDateTime; + +public class DurationTest { + + @Test + public void testBetween() { + System.out.println(Duration.between(LocalDateTime.of(2024, 3, 8, 7, 0, 0, 0), LocalDateTime.now()).toHours()); + System.out.println(Duration.between(LocalDateTime.of(2024, 3, 8, 16, 0, 0, 0), LocalDateTime.now()).toHours() < 8); + } +} diff --git a/truncate.sql b/truncate.sql index 464b006..3747395 100644 --- a/truncate.sql +++ b/truncate.sql @@ -12,6 +12,7 @@ truncate table mail_mark; truncate table work; truncate table favorite; +truncate table notice; truncate table system_log_operate; truncate table system_log_login;