소스 검색

新增管理员模块

Linyt 1 년 전
부모
커밋
14ca4933b1
47개의 변경된 파일690개의 추가작업 그리고 34개의 파일을 삭제
  1. 7 7
      .idea/mybatisx/templates.xml
  2. 26 0
      java/src/main/java/boot/common/config/WebConfig.java
  3. 14 0
      java/src/main/java/boot/common/interceptor/ManageCheck.java
  4. 151 0
      java/src/main/java/boot/common/interceptor/ManagePermissionInterceptor.java
  5. 4 4
      java/src/main/java/boot/common/utils/RedisUtils.java
  6. 9 6
      java/src/main/java/boot/modules/manage/controller/CalendarController.java
  7. 96 0
      java/src/main/java/boot/modules/manage/controller/ManageController.java
  8. 2 2
      java/src/main/java/boot/modules/manage/mapper/CalendarMapper.java
  9. 19 0
      java/src/main/java/boot/modules/manage/mapper/ManageMapper.java
  10. 1 1
      java/src/main/java/boot/modules/manage/param/CalendarParam.java
  11. 1 1
      java/src/main/java/boot/modules/manage/pojo/Calendar.java
  12. 173 0
      java/src/main/java/boot/modules/manage/pojo/Manage.java
  13. 1 1
      java/src/main/java/boot/modules/manage/respond/CalendarDTO.java
  14. 2 2
      java/src/main/java/boot/modules/manage/service/CalendarService.java
  15. 14 0
      java/src/main/java/boot/modules/manage/service/ManageService.java
  16. 4 4
      java/src/main/java/boot/modules/manage/service/impl/CalendarServiceImpl.java
  17. 23 0
      java/src/main/java/boot/modules/manage/service/impl/ManageServiceImpl.java
  18. 21 0
      java/src/main/java/boot/modules/user/service/impl/AuthService.java
  19. 2 2
      java/src/main/resources/boot/modules/calendar/mapper/CalendarMapper.xml
  20. 32 0
      java/src/main/resources/boot/modules/manage/mapper/ManageMapper.xml
  21. 27 1
      java/src/main/resources/sql/project.sql
  22. BIN
      java/target/classes/boot/common/config/WebConfig.class
  23. BIN
      java/target/classes/boot/common/interceptor/ManageCheck.class
  24. BIN
      java/target/classes/boot/common/interceptor/ManagePermissionInterceptor.class
  25. BIN
      java/target/classes/boot/common/utils/RedisUtils.class
  26. BIN
      java/target/classes/boot/modules/calendar/controller/CalendarController.class
  27. BIN
      java/target/classes/boot/modules/calendar/mapper/CalendarMapper.class
  28. 2 2
      java/target/classes/boot/modules/calendar/mapper/CalendarMapper.xml
  29. BIN
      java/target/classes/boot/modules/calendar/service/CalendarService.class
  30. BIN
      java/target/classes/boot/modules/calendar/service/impl/CalendarServiceImpl.class
  31. BIN
      java/target/classes/boot/modules/manage/controller/CalendarController.class
  32. BIN
      java/target/classes/boot/modules/manage/controller/ManageController$1.class
  33. BIN
      java/target/classes/boot/modules/manage/controller/ManageController.class
  34. BIN
      java/target/classes/boot/modules/manage/mapper/CalendarMapper.class
  35. BIN
      java/target/classes/boot/modules/manage/mapper/ManageMapper.class
  36. 32 0
      java/target/classes/boot/modules/manage/mapper/ManageMapper.xml
  37. BIN
      java/target/classes/boot/modules/manage/param/CalendarParam.class
  38. BIN
      java/target/classes/boot/modules/manage/pojo/Calendar.class
  39. BIN
      java/target/classes/boot/modules/manage/pojo/Manage.class
  40. BIN
      java/target/classes/boot/modules/manage/respond/CalendarDTO.class
  41. BIN
      java/target/classes/boot/modules/manage/service/CalendarService.class
  42. BIN
      java/target/classes/boot/modules/manage/service/ManageService.class
  43. BIN
      java/target/classes/boot/modules/manage/service/impl/CalendarServiceImpl.class
  44. BIN
      java/target/classes/boot/modules/manage/service/impl/ManageServiceImpl.class
  45. BIN
      java/target/classes/boot/modules/user/controller/UserController$1.class
  46. BIN
      java/target/classes/boot/modules/user/service/impl/AuthService.class
  47. 27 1
      java/target/classes/sql/project.sql

+ 7 - 7
.idea/mybatisx/templates.xml

@@ -6,7 +6,7 @@
         <option name="generateConfig">
           <GenerateConfig>
             <option name="annotationType" value="MYBATIS_PLUS3" />
-            <option name="basePackage" value="calendar" />
+            <option name="basePackage" value="manage" />
             <option name="basePath" value="src/main/java/boot/modules" />
             <option name="classNameStrategy" value="camel" />
             <option name="encoding" value="UTF-8" />
@@ -20,7 +20,7 @@
             <option name="moduleUIInfoList">
               <list>
                 <ModuleInfoGo>
-                  <option name="basePath" value="${domain.basePath}" />
+                  <option name="basePath" value="src/main/java/boot/modules/manage" />
                   <option name="configFileName" value="serviceImpl.ftl" />
                   <option name="configName" value="serviceImpl" />
                   <option name="encoding" value="${domain.encoding}" />
@@ -30,7 +30,7 @@
                   <option name="packageName" value="${domain.basePackage}.service.impl" />
                 </ModuleInfoGo>
                 <ModuleInfoGo>
-                  <option name="basePath" value="${domain.basePath}" />
+                  <option name="basePath" value="src/main/java/boot/modules/manage" />
                   <option name="configFileName" value="mapperInterface.ftl" />
                   <option name="configName" value="mapperInterface" />
                   <option name="encoding" value="${domain.encoding}" />
@@ -40,7 +40,7 @@
                   <option name="packageName" value="${domain.basePackage}.mapper" />
                 </ModuleInfoGo>
                 <ModuleInfoGo>
-                  <option name="basePath" value="${domain.basePath}" />
+                  <option name="basePath" value="src/main/java/boot/modules/manage" />
                   <option name="configFileName" value="serviceInterface.ftl" />
                   <option name="configName" value="serviceInterface" />
                   <option name="encoding" value="${domain.encoding}" />
@@ -50,7 +50,7 @@
                   <option name="packageName" value="${domain.basePackage}.service" />
                 </ModuleInfoGo>
                 <ModuleInfoGo>
-                  <option name="basePath" value="src/main/resources/boot/modules/calendar" />
+                  <option name="basePath" value="src/main/resources/boot/modules/manage" />
                   <option name="configFileName" value="mapperXml.ftl" />
                   <option name="configName" value="mapperXml" />
                   <option name="encoding" value="${domain.encoding}" />
@@ -69,8 +69,8 @@
             <option name="tableUIInfoList">
               <list>
                 <TableUIInfo>
-                  <option name="className" value="Calendar" />
-                  <option name="tableName" value="calendar" />
+                  <option name="className" value="Manage" />
+                  <option name="tableName" value="manage" />
                 </TableUIInfo>
               </list>
             </option>

+ 26 - 0
java/src/main/java/boot/common/config/WebConfig.java

@@ -1,7 +1,12 @@
 package boot.common.config;
 
+import boot.common.interceptor.ManagePermissionInterceptor;
+import boot.common.interceptor.PermissionInterceptor;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
@@ -20,4 +25,25 @@ public class WebConfig implements WebMvcConfigurer {
         registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
         registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
     }
+
+    @Bean
+    public HandlerInterceptor getPermissionInterceptor() {
+        //用户请求拦截器
+        return new PermissionInterceptor();
+    }
+    @Bean
+    public ManagePermissionInterceptor getManagePermissionInterceptor(){
+        //管理员请求拦截器
+        return new ManagePermissionInterceptor();
+    }
+
+    /**
+     * 请求拦截器
+     * @param registry
+     */
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(this.getPermissionInterceptor());
+        registry.addInterceptor(this.getManagePermissionInterceptor());
+    }
 }

+ 14 - 0
java/src/main/java/boot/common/interceptor/ManageCheck.java

@@ -0,0 +1,14 @@
+package boot.common.interceptor;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+/**
+ * @ClassName 自定义权限注解
+ **/
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ManageCheck {
+    int value() default 4;
+}

+ 151 - 0
java/src/main/java/boot/common/interceptor/ManagePermissionInterceptor.java

@@ -0,0 +1,151 @@
+package boot.common.interceptor;
+
+import boot.common.bean.LocalUser;
+import boot.common.constant.SchoolConstant;
+import boot.common.respond.ApiCode;
+import boot.common.respond.UnAuthenticatedException;
+import boot.common.utils.JwtToken;
+import boot.common.utils.RedisUtils;
+import boot.modules.manage.pojo.Manage;
+import boot.modules.manage.service.ManageService;
+import boot.modules.user.pojo.User;
+import boot.modules.user.service.UserService;
+import com.auth0.jwt.interfaces.Claim;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+import java.util.Optional;
+
+public class ManagePermissionInterceptor extends HandlerInterceptorAdapter {
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private RedisUtils redisUtils;
+    @Autowired
+    private ManageService manageService;
+
+    public ManagePermissionInterceptor() {
+        super();
+    }
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        Optional<ManageCheck> authCheck = this.getAuthCheck(handler);
+        //如果没有在方法(接口方法上)上注释 @AuthCheck 就会直接放行,不进行权限检查
+        if (!authCheck.isPresent()) {
+            return true;
+        }
+
+        //获取请求头中的 Token,没有就抛异常 “401, "非法访问"
+        String bearerToken = request.getHeader("Authorization");
+        if (StringUtils.isEmpty(bearerToken)) {
+            throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED);
+        }
+
+        if (!bearerToken.startsWith("Bearer")) {
+            throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED);
+        }
+        //根据Token以空格来进行分离 Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjEsInVOYW1lIjoiMTM0MTExMTExMTEiLCJzY29wZSI6OCwiZXhwIjoxNzg5MjY5MDI2LCJpYXQiOjE3MDI4NjkwMjZ9.brwajljjhr4LYi9kh9lDKvtQsbfrFaDU30lYx5Min9Y
+        String[] tokens = bearerToken.split(" ");
+        if (!(tokens.length == 2)) {
+            throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED);
+        }
+        //分离后的数组第一个是 Bearer,第二个是该用户的 Token
+        String token = tokens[1];
+
+        //用于验证并提取JWT中的声明(Claims)
+        Optional<Map<String, Claim>> optionalMap = JwtToken.getClaims(token);
+        //获取每一个值 如果为空直接抛异常
+        Map<String, Claim> map = optionalMap
+                .orElseThrow(() -> new UnAuthenticatedException(ApiCode.UNAUTHORIZED));
+
+        String username = map.get("uName").asString();
+
+        //检测用户是否被踢出
+        if (redisUtils.get(SchoolConstant.SCHOOL_LOGIN_USER + username + ":" + token) == null) {
+            throw new UnAuthenticatedException(ApiCode.UNAUTHORIZED);
+        }
+        //
+        boolean valid = this.hasPermission(authCheck.get(), map);
+        if (valid) {
+            this.setToThreadLocal(map);
+        }
+        return valid;
+    }
+
+    /**
+     * 如果权限验证通过的情况下 将相关信息存储在线程本地
+     *
+     * @param map
+     */
+    private void setToThreadLocal(Map<String, Claim> map) {
+        Integer uid = map.get("uid").asInt();
+        Integer scope = map.get("scope").asInt();
+        User user = userService.getById(uid);
+        if (user == null) {
+            throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION);
+        }
+        LocalUser.set(user, scope);
+//        System.out.println(LocalUser.getUser());
+    }
+
+    /**
+     * 验证传入的权限级别是否与 "scope" 的值匹配
+     *
+     * @param authCheck
+     * @param map
+     * @return
+     */
+    private boolean hasPermission(ManageCheck authCheck, Map<String, Claim> map) {
+        //获取注解上的 value 值
+        Integer level = authCheck.value();
+        Integer scope = map.get("scope").asInt();
+        if (level > scope) {
+            throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION);
+        }
+
+        LambdaQueryWrapper<Manage> wrapper = new LambdaQueryWrapper<>();
+        Long uid = map.get("uid").asLong();
+
+        wrapper.eq(Manage::getId,uid);
+
+        Manage manage = manageService.getById(uid);
+        if (manage==null){
+            throw new UnAuthenticatedException(ApiCode.NOT_PERMISSION);
+        }
+        return true;
+    }
+
+    @Override
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
+        super.postHandle(request, response, handler, modelAndView);
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
+        LocalUser.clear();
+        super.afterCompletion(request, response, handler, ex);
+    }
+
+    private Optional<ManageCheck> getAuthCheck(Object handler) {
+        //先检查它的类型,以确保安全地访问其属性或方法。
+        if (handler instanceof HandlerMethod) {
+            HandlerMethod handlerMethod = (HandlerMethod) handler;
+            // 获取方法上的注解信息 是否添加了 @AuthCheck 注解
+            ManageCheck authCheck = handlerMethod.getMethod().getAnnotation(ManageCheck.class);
+            if (authCheck == null) {
+                return Optional.empty();
+            }
+            return Optional.of(authCheck);
+        }
+        return Optional.empty();
+    }
+
+}

+ 4 - 4
java/src/main/java/boot/common/utils/RedisUtils.java

@@ -6,6 +6,7 @@ package boot.common.utils;
 //
 
 
+import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.connection.RedisConnection;
@@ -146,10 +147,9 @@ public class RedisUtils {
     public boolean set(String key, Object value, long time) {
         try {
             if (time > 0L) {
-//                JSONObject jsonObject = new JSONObject(value);
-//                String jsonStr = String.valueOf(value);
-                String v = JSONUtil.toJsonStr(value);
-                this.redisTemplate.opsForValue().set(key, v, time, TimeUnit.SECONDS);
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.set("json",value);
+                this.redisTemplate.opsForValue().set(key, jsonObject.get("json"), time, TimeUnit.SECONDS);
             } else {
                 this.set(key, value);
             }

+ 9 - 6
java/src/main/java/boot/modules/calendar/controller/CalendarController.java → java/src/main/java/boot/modules/manage/controller/CalendarController.java

@@ -1,14 +1,14 @@
-package boot.modules.calendar.controller;
+package boot.modules.manage.controller;
 
+import boot.common.interceptor.ManageCheck;
 import boot.common.respond.ApiCode;
 import boot.common.respond.ApiResult;
-import boot.modules.calendar.param.CalendarParam;
-import boot.modules.calendar.pojo.Calendar;
-import boot.modules.calendar.respond.CalendarDTO;
-import boot.modules.calendar.service.CalendarService;
+import boot.modules.manage.param.CalendarParam;
+import boot.modules.manage.pojo.Calendar;
+import boot.modules.manage.respond.CalendarDTO;
+import boot.modules.manage.service.CalendarService;
 
 import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.util.ObjUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import io.swagger.annotations.Api;
@@ -47,6 +47,7 @@ public class CalendarController {
         return ApiResult.ok(calendars);
     }
 
+    @ManageCheck
     @PostMapping("/addCalendar")
     @ApiOperation(value = "添加单个日历事件",notes = "添加")
     public ApiResult<Object> addCalendar(@RequestBody CalendarParam param){
@@ -73,6 +74,7 @@ public class CalendarController {
         return ApiResult.ok(save);
     }
 
+    @ManageCheck
     @DeleteMapping("/delById/{id}")
     @ApiOperation(value = "根据id删除事件",notes = "删除")
     public ApiResult<Object> delById(@PathVariable Long id){
@@ -87,6 +89,7 @@ public class CalendarController {
         return ApiResult.ok(b);
     }
 
+    @ManageCheck
     @PutMapping("/editCalendar")
     @ApiOperation(value = "根据id修改校历事件",notes = "修改")
     public ApiResult<Object> editById(@RequestBody CalendarParam param){

+ 96 - 0
java/src/main/java/boot/modules/manage/controller/ManageController.java

@@ -0,0 +1,96 @@
+package boot.modules.manage.controller;
+
+import boot.common.respond.ApiResult;
+import boot.common.respond.EException;
+import boot.common.utils.JwtToken;
+import boot.common.utils.RedisUtils;
+import boot.modules.manage.pojo.Manage;
+import boot.modules.manage.service.ManageService;
+import boot.modules.user.param.HLoginParam;
+import boot.modules.user.param.RegParam;
+import boot.modules.user.pojo.User;
+import boot.modules.user.service.UserService;
+import boot.modules.user.service.impl.AuthService;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.crypto.SecureUtil;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+@Api(value = "管理员控制模块", tags = "管理员")
+@RestController
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
+@RequestMapping("/manage")
+public class ManageController {
+
+    private final ManageService manageService;
+    private final RedisUtils redisUtil;
+    private final AuthService authService;
+    @Value("${single.login}")
+    private Boolean singleLogin;
+
+    @ApiOperation("管理员登录")
+    @PostMapping(value = "/login")
+    public ApiResult<Map<String, Object>> login(@Validated @RequestBody HLoginParam loginDTO, HttpServletRequest request) {
+        //查询数据库是否有此用户
+        Manage user = manageService.getOne(Wrappers.<Manage>lambdaQuery()
+                .eq(Manage::getUsername, loginDTO.getUsername())
+                .eq(Manage::getPassword, SecureUtil.md5(loginDTO.getPassword())), false);
+
+        if (user == null) {
+            throw new EException("账号或者密码不正确");
+        }
+        //生成 token
+        String token = JwtToken.makeToken(user.getId(), user.getUsername());
+        //token 过期时间
+        String expiresTimeStr = JwtToken.getExpireTime(token);
+
+        // 保存在线信息
+        authService.saveManage(user, token, request);
+        // 返回 token
+        Map<String, Object> map = new HashMap<String, Object>(2) {{
+            put("token", token);
+            put("expires_time", expiresTimeStr);
+        }};
+        //singleLogin 是在yaml配置文件中的一项 默认值为 false
+        if (singleLogin) {
+            //踢掉之前已经登录的token
+            authService.checkLoginOnUser(user.getUsername(), token);
+        }
+
+        return ApiResult.ok(map).setMsg("登陆成功");
+    }
+
+
+    @PostMapping("/register")
+    @ApiOperation(value = "H5/APP注册新用户", notes = "H5/APP注册新用户")
+    public ApiResult<String> register(@Validated @RequestBody RegParam param) {
+        Object codeObj = redisUtil.get("code_" + param.getAccount());
+        if (codeObj == null) {
+            return ApiResult.fail("请先获取验证码");
+        }
+        String code = codeObj.toString();
+        if (!StrUtil.equals(code, param.getCaptcha())) {
+            return ApiResult.fail("验证码错误");
+        }
+        Manage manager = manageService.getOne(Wrappers.<Manage>lambdaQuery()
+                .eq(Manage::getPhone, param.getAccount()), false);
+        if (manager != null) {
+            return ApiResult.fail("该手机号已存在");
+        }
+        authService.register(param);
+        return ApiResult.ok("", "注册成功");
+    }
+}

+ 2 - 2
java/src/main/java/boot/modules/calendar/mapper/CalendarMapper.java → java/src/main/java/boot/modules/manage/mapper/CalendarMapper.java

@@ -1,7 +1,7 @@
-package boot.modules.calendar.mapper;
+package boot.modules.manage.mapper;
 
 
-import boot.modules.calendar.pojo.Calendar;
+import boot.modules.manage.pojo.Calendar;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 

+ 19 - 0
java/src/main/java/boot/modules/manage/mapper/ManageMapper.java

@@ -0,0 +1,19 @@
+package boot.modules.manage.mapper;
+
+
+import boot.modules.manage.pojo.Manage;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author Lin
+* @description 针对表【manage(系统用户)】的数据库操作Mapper
+* @createDate 2024-06-06 14:02:01
+* @Entity manage.pojo.Manage
+*/
+public interface ManageMapper extends BaseMapper<Manage> {
+
+}
+
+
+
+

+ 1 - 1
java/src/main/java/boot/modules/calendar/param/CalendarParam.java → java/src/main/java/boot/modules/manage/param/CalendarParam.java

@@ -1,4 +1,4 @@
-package boot.modules.calendar.param;
+package boot.modules.manage.param;
 
 import lombok.AllArgsConstructor;
 import lombok.Data;

+ 1 - 1
java/src/main/java/boot/modules/calendar/pojo/Calendar.java → java/src/main/java/boot/modules/manage/pojo/Calendar.java

@@ -1,4 +1,4 @@
-package boot.modules.calendar.pojo;
+package boot.modules.manage.pojo;
 
 import com.baomidou.mybatisplus.annotation.*;
 

+ 173 - 0
java/src/main/java/boot/modules/manage/pojo/Manage.java

@@ -0,0 +1,173 @@
+package boot.modules.manage.pojo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 系统用户
+ * @TableName manage
+ */
+@TableName(value ="manage")
+@Data
+public class Manage implements Serializable {
+    /**
+     * ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 头像
+     */
+    private Long avatarId;
+
+    /**
+     * 邮箱
+     */
+    private String email;
+
+    /**
+     * 状态:1启用、0禁用
+     */
+    private Long enabled;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 用户名
+     */
+    private String username;
+
+    /**
+     * 部门名称
+     */
+    private Long deptId;
+
+    /**
+     * 手机号码
+     */
+    private String phone;
+
+    /**
+     * 岗位名称
+     */
+    private Long jobId;
+
+    /**
+     * 创建日期
+     */
+    private Date createTime;
+
+    /**
+     * 最后修改密码的日期
+     */
+    private Date lastPasswordResetTime;
+
+    /**
+     * 
+     */
+    private String nickName;
+
+    /**
+     * 
+     */
+    private String sex;
+
+    /**
+     * 
+     */
+    private Date updateTime;
+
+    /**
+     * 
+     */
+    private Integer isDel;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Manage other = (Manage) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getAvatarId() == null ? other.getAvatarId() == null : this.getAvatarId().equals(other.getAvatarId()))
+            && (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
+            && (this.getEnabled() == null ? other.getEnabled() == null : this.getEnabled().equals(other.getEnabled()))
+            && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
+            && (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
+            && (this.getDeptId() == null ? other.getDeptId() == null : this.getDeptId().equals(other.getDeptId()))
+            && (this.getPhone() == null ? other.getPhone() == null : this.getPhone().equals(other.getPhone()))
+            && (this.getJobId() == null ? other.getJobId() == null : this.getJobId().equals(other.getJobId()))
+            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
+            && (this.getLastPasswordResetTime() == null ? other.getLastPasswordResetTime() == null : this.getLastPasswordResetTime().equals(other.getLastPasswordResetTime()))
+            && (this.getNickName() == null ? other.getNickName() == null : this.getNickName().equals(other.getNickName()))
+            && (this.getSex() == null ? other.getSex() == null : this.getSex().equals(other.getSex()))
+            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
+            && (this.getIsDel() == null ? other.getIsDel() == null : this.getIsDel().equals(other.getIsDel()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getAvatarId() == null) ? 0 : getAvatarId().hashCode());
+        result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
+        result = prime * result + ((getEnabled() == null) ? 0 : getEnabled().hashCode());
+        result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
+        result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
+        result = prime * result + ((getDeptId() == null) ? 0 : getDeptId().hashCode());
+        result = prime * result + ((getPhone() == null) ? 0 : getPhone().hashCode());
+        result = prime * result + ((getJobId() == null) ? 0 : getJobId().hashCode());
+        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+        result = prime * result + ((getLastPasswordResetTime() == null) ? 0 : getLastPasswordResetTime().hashCode());
+        result = prime * result + ((getNickName() == null) ? 0 : getNickName().hashCode());
+        result = prime * result + ((getSex() == null) ? 0 : getSex().hashCode());
+        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
+        result = prime * result + ((getIsDel() == null) ? 0 : getIsDel().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", avatarId=").append(avatarId);
+        sb.append(", email=").append(email);
+        sb.append(", enabled=").append(enabled);
+        sb.append(", password=").append(password);
+        sb.append(", username=").append(username);
+        sb.append(", deptId=").append(deptId);
+        sb.append(", phone=").append(phone);
+        sb.append(", jobId=").append(jobId);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", lastPasswordResetTime=").append(lastPasswordResetTime);
+        sb.append(", nickName=").append(nickName);
+        sb.append(", sex=").append(sex);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append(", isDel=").append(isDel);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 1 - 1
java/src/main/java/boot/modules/calendar/respond/CalendarDTO.java → java/src/main/java/boot/modules/manage/respond/CalendarDTO.java

@@ -1,4 +1,4 @@
-package boot.modules.calendar.respond;
+package boot.modules.manage.respond;
 
 import lombok.AllArgsConstructor;
 import lombok.Data;

+ 2 - 2
java/src/main/java/boot/modules/calendar/service/CalendarService.java → java/src/main/java/boot/modules/manage/service/CalendarService.java

@@ -1,7 +1,7 @@
-package boot.modules.calendar.service;
+package boot.modules.manage.service;
 
 
-import boot.modules.calendar.pojo.Calendar;
+import boot.modules.manage.pojo.Calendar;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.springframework.stereotype.Service;
 

+ 14 - 0
java/src/main/java/boot/modules/manage/service/ManageService.java

@@ -0,0 +1,14 @@
+package boot.modules.manage.service;
+
+
+import boot.modules.manage.pojo.Manage;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author Lin
+* @description 针对表【manage(系统用户)】的数据库操作Service
+* @createDate 2024-06-06 14:02:01
+*/
+public interface ManageService extends IService<Manage> {
+
+}

+ 4 - 4
java/src/main/java/boot/modules/calendar/service/impl/CalendarServiceImpl.java → java/src/main/java/boot/modules/manage/service/impl/CalendarServiceImpl.java

@@ -1,8 +1,8 @@
-package boot.modules.calendar.service.impl;
+package boot.modules.manage.service.impl;
 
-import boot.modules.calendar.mapper.CalendarMapper;
-import boot.modules.calendar.pojo.Calendar;
-import boot.modules.calendar.service.CalendarService;
+import boot.modules.manage.mapper.CalendarMapper;
+import boot.modules.manage.pojo.Calendar;
+import boot.modules.manage.service.CalendarService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 

+ 23 - 0
java/src/main/java/boot/modules/manage/service/impl/ManageServiceImpl.java

@@ -0,0 +1,23 @@
+package boot.modules.manage.service.impl;
+
+import boot.modules.manage.mapper.ManageMapper;
+import boot.modules.manage.pojo.Manage;
+import boot.modules.manage.service.ManageService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import org.springframework.stereotype.Service;
+
+/**
+* @author Lin
+* @description 针对表【manage(系统用户)】的数据库操作Service实现
+* @createDate 2024-06-06 14:02:01
+*/
+@Service
+public class ManageServiceImpl extends ServiceImpl<ManageMapper, Manage>
+    implements ManageService {
+
+}
+
+
+
+

+ 21 - 0
java/src/main/java/boot/modules/user/service/impl/AuthService.java

@@ -6,6 +6,7 @@ import boot.common.utils.EncryptUtils;
 import boot.common.utils.IpUtil;
 import boot.common.utils.RedisUtils;
 import boot.common.utils.StringUtils;
+import boot.modules.manage.pojo.Manage;
 import boot.modules.user.param.RegParam;
 import boot.modules.user.pojo.User;
 import boot.modules.user.service.UserService;
@@ -82,6 +83,26 @@ public class AuthService {
         }
         redisUtils.set(SchoolConstant.SCHOOL_LOGIN_USER + onlineUser.getUserName() + ":" + token, onlineUser, AuthService.expiredTimeIn);
     }
+    /**
+     * 保存在线用户信息
+     * @param user /
+     * @param token /
+     * @param request /
+     */
+    public void saveManage(Manage user, String token, HttpServletRequest request){
+        String job = "开发工程师";
+        String ip = IpUtil.getRequestIp();
+        String browser = StringUtils.getBrowser(request);
+        String address = StringUtils.getCityInfo(ip);
+        OnlineUser onlineUser = null;
+        try {
+            onlineUser = new OnlineUser(user.getUsername(), user.getNickName(), job, browser ,
+                    ip, address, EncryptUtils.desEncrypt(token), new Date());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        redisUtils.set(SchoolConstant.SCHOOL_LOGIN_USER + onlineUser.getUserName() + ":" + token, onlineUser, AuthService.expiredTimeIn);
+    }
 
     /**
      * 检测用户是否在之前已经登录,已经登录踢下线

+ 2 - 2
java/src/main/resources/boot/modules/calendar/mapper/CalendarMapper.xml

@@ -2,9 +2,9 @@
 <!DOCTYPE mapper
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="boot.modules.calendar.mapper.CalendarMapper">
+<mapper namespace="boot.modules.manage.mapper.CalendarMapper">
 
-    <resultMap id="BaseResultMap" type="boot.modules.calendar.pojo.Calendar">
+    <resultMap id="BaseResultMap" type="boot.modules.manage.pojo.Calendar">
             <id property="id" column="id" jdbcType="BIGINT"/>
             <result property="title" column="title" jdbcType="VARCHAR"/>
             <result property="detail" column="detail" jdbcType="VARCHAR"/>

+ 32 - 0
java/src/main/resources/boot/modules/manage/mapper/ManageMapper.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="boot.modules.manage.mapper.ManageMapper">
+
+    <resultMap id="BaseResultMap" type="boot.modules.manage.pojo.Manage">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="avatarId" column="avatar_id" jdbcType="BIGINT"/>
+            <result property="email" column="email" jdbcType="VARCHAR"/>
+            <result property="enabled" column="enabled" jdbcType="BIGINT"/>
+            <result property="password" column="password" jdbcType="VARCHAR"/>
+            <result property="username" column="username" jdbcType="VARCHAR"/>
+            <result property="deptId" column="dept_id" jdbcType="BIGINT"/>
+            <result property="phone" column="phone" jdbcType="VARCHAR"/>
+            <result property="jobId" column="job_id" jdbcType="BIGINT"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="lastPasswordResetTime" column="last_password_reset_time" jdbcType="TIMESTAMP"/>
+            <result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
+            <result property="sex" column="sex" jdbcType="VARCHAR"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+            <result property="isDel" column="is_del" jdbcType="TINYINT"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,avatar_id,email,
+        enabled,password,username,
+        dept_id,phone,job_id,
+        create_time,last_password_reset_time,nick_name,
+        sex,update_time,is_del
+    </sql>
+</mapper>

+ 27 - 1
java/src/main/resources/sql/project.sql

@@ -48,4 +48,30 @@ create table calendar
     file      varchar(255) null comment '文件',
     file_type varchar(50)  null comment '文件类型',
     is_del    tinyint(1)        default 0 null comment '这条数据是否被删除 0未删除 1已删除'
-)
+);
+
+drop table if exists manage;
+create table manage
+(
+    id                       bigint auto_increment comment 'ID'
+        primary key,
+    avatar_id                bigint               null comment '头像',
+    email                    varchar(255)         null comment '邮箱',
+    enabled                  bigint               null comment '状态:1启用、0禁用',
+    password                 varchar(255)         null comment '密码',
+    username                 varchar(255)         null comment '用户名',
+    dept_id                  bigint               null comment '部门名称',
+    phone                    varchar(255)         null comment '手机号码',
+    job_id                   bigint               null comment '岗位名称',
+    create_time              datetime             null comment '创建日期',
+    last_password_reset_time datetime             null comment '最后修改密码的日期',
+    nick_name                varchar(255)         null,
+    sex                      varchar(255)         null,
+    update_time              datetime             null,
+    is_del                   tinyint(1) default 0 null,
+    constraint UK_kpubos9gc2cvtkb0thktkbkes
+        unique (email),
+    constraint username
+        unique (username)
+)
+    comment '系统用户'

BIN
java/target/classes/boot/common/config/WebConfig.class


BIN
java/target/classes/boot/common/interceptor/ManageCheck.class


BIN
java/target/classes/boot/common/interceptor/ManagePermissionInterceptor.class


BIN
java/target/classes/boot/common/utils/RedisUtils.class


BIN
java/target/classes/boot/modules/calendar/controller/CalendarController.class


BIN
java/target/classes/boot/modules/calendar/mapper/CalendarMapper.class


+ 2 - 2
java/target/classes/boot/modules/calendar/mapper/CalendarMapper.xml

@@ -2,9 +2,9 @@
 <!DOCTYPE mapper
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="boot.modules.calendar.mapper.CalendarMapper">
+<mapper namespace="boot.modules.manage.mapper.CalendarMapper">
 
-    <resultMap id="BaseResultMap" type="boot.modules.calendar.pojo.Calendar">
+    <resultMap id="BaseResultMap" type="boot.modules.manage.pojo.Calendar">
             <id property="id" column="id" jdbcType="BIGINT"/>
             <result property="title" column="title" jdbcType="VARCHAR"/>
             <result property="detail" column="detail" jdbcType="VARCHAR"/>

BIN
java/target/classes/boot/modules/calendar/service/CalendarService.class


BIN
java/target/classes/boot/modules/calendar/service/impl/CalendarServiceImpl.class


BIN
java/target/classes/boot/modules/manage/controller/CalendarController.class


BIN
java/target/classes/boot/modules/manage/controller/ManageController$1.class


BIN
java/target/classes/boot/modules/manage/controller/ManageController.class


BIN
java/target/classes/boot/modules/manage/mapper/CalendarMapper.class


BIN
java/target/classes/boot/modules/manage/mapper/ManageMapper.class


+ 32 - 0
java/target/classes/boot/modules/manage/mapper/ManageMapper.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="boot.modules.manage.mapper.ManageMapper">
+
+    <resultMap id="BaseResultMap" type="boot.modules.manage.pojo.Manage">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="avatarId" column="avatar_id" jdbcType="BIGINT"/>
+            <result property="email" column="email" jdbcType="VARCHAR"/>
+            <result property="enabled" column="enabled" jdbcType="BIGINT"/>
+            <result property="password" column="password" jdbcType="VARCHAR"/>
+            <result property="username" column="username" jdbcType="VARCHAR"/>
+            <result property="deptId" column="dept_id" jdbcType="BIGINT"/>
+            <result property="phone" column="phone" jdbcType="VARCHAR"/>
+            <result property="jobId" column="job_id" jdbcType="BIGINT"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="lastPasswordResetTime" column="last_password_reset_time" jdbcType="TIMESTAMP"/>
+            <result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
+            <result property="sex" column="sex" jdbcType="VARCHAR"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+            <result property="isDel" column="is_del" jdbcType="TINYINT"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,avatar_id,email,
+        enabled,password,username,
+        dept_id,phone,job_id,
+        create_time,last_password_reset_time,nick_name,
+        sex,update_time,is_del
+    </sql>
+</mapper>

BIN
java/target/classes/boot/modules/calendar/param/CalendarParam.class → java/target/classes/boot/modules/manage/param/CalendarParam.class


BIN
java/target/classes/boot/modules/calendar/pojo/Calendar.class → java/target/classes/boot/modules/manage/pojo/Calendar.class


BIN
java/target/classes/boot/modules/manage/pojo/Manage.class


BIN
java/target/classes/boot/modules/calendar/respond/CalendarDTO.class → java/target/classes/boot/modules/manage/respond/CalendarDTO.class


BIN
java/target/classes/boot/modules/manage/service/CalendarService.class


BIN
java/target/classes/boot/modules/manage/service/ManageService.class


BIN
java/target/classes/boot/modules/manage/service/impl/CalendarServiceImpl.class


BIN
java/target/classes/boot/modules/manage/service/impl/ManageServiceImpl.class


BIN
java/target/classes/boot/modules/user/controller/UserController$1.class


BIN
java/target/classes/boot/modules/user/service/impl/AuthService.class


+ 27 - 1
java/target/classes/sql/project.sql

@@ -48,4 +48,30 @@ create table calendar
     file      varchar(255) null comment '文件',
     file_type varchar(50)  null comment '文件类型',
     is_del    tinyint(1)        default 0 null comment '这条数据是否被删除 0未删除 1已删除'
-)
+);
+
+drop table if exists manage;
+create table manage
+(
+    id                       bigint auto_increment comment 'ID'
+        primary key,
+    avatar_id                bigint               null comment '头像',
+    email                    varchar(255)         null comment '邮箱',
+    enabled                  bigint               null comment '状态:1启用、0禁用',
+    password                 varchar(255)         null comment '密码',
+    username                 varchar(255)         null comment '用户名',
+    dept_id                  bigint               null comment '部门名称',
+    phone                    varchar(255)         null comment '手机号码',
+    job_id                   bigint               null comment '岗位名称',
+    create_time              datetime             null comment '创建日期',
+    last_password_reset_time datetime             null comment '最后修改密码的日期',
+    nick_name                varchar(255)         null,
+    sex                      varchar(255)         null,
+    update_time              datetime             null,
+    is_del                   tinyint(1) default 0 null,
+    constraint UK_kpubos9gc2cvtkb0thktkbkes
+        unique (email),
+    constraint username
+        unique (username)
+)
+    comment '系统用户'