更新 sql文件
This commit is contained in:
parent
e3dde6274f
commit
2ace559a6f
18
README.md
18
README.md
@ -1,11 +1,14 @@
|
||||
## 参考资料
|
||||
AntDesignPro:https://pro.antdv.com/docs/getting-started
|
||||
|
||||
sa-token 文档:https://sa-token.cc/doc.html#/
|
||||
|
||||
Knife4j 文档 :https://doc.xiaominfo.com/
|
||||
|
||||
雪花算法 :https://github.com/yitter/idgenerator/tree/master/Java
|
||||
|
||||
波市科技文献共享服务平台:https://www.nbsti.net/Public/html/index.html
|
||||
|
||||
lambok:
|
||||
```
|
||||
@Data 标签,生成getter/setter toString()等方法
|
||||
@ -23,4 +26,17 @@ lambok:
|
||||
@Synchronized : 同步方法安全的转化
|
||||
@Getter(lazy=true) :
|
||||
@Log : 支持各种logger对象,使用时用对应的注解,如:@Log4j
|
||||
```
|
||||
```
|
||||
|
||||
### 目录结构
|
||||
|
||||
- config:里面存放的都是配置类 例如 @Configuration 、 @Component 等等
|
||||
- controller:里面存放的是接口(术语:存放所有处理HTTP请求的控制器类。这些类通过定义路由和方法来处理前端发送的请求,并返回响应。)
|
||||
- service:里面存放的是接口对应的服务(术语:定义业务逻辑接口,这些接口定义了业务操作的抽象,与数据访问层(DAO或Repository)解耦)
|
||||
- impl:里面存放服务的具体实现(术语:这个子目录存放service接口的具体实现。这里通常包含对业务逻辑的具体实现,可能会调用数据访问层的方法来完成数据操作。)
|
||||
- util:存放工具类,这些类通常包含静态方法,用于执行通用任务,如日期时间处理、加密解密、日志记录等。
|
||||
- mapper:mapper接口用于定义数据访问层的方法,这些方法通常直接映射到数据库操作。(映射文件xml)
|
||||
- domain: 存放与数据库表相对应的实体类(Entity)、数据传输对象(DTO)和视图对象(VO)。
|
||||
- dto: 里面的对象一同来接收前端传来的参数(数据传输对象,用于不同层之间传输数据,特别是跨系统或跨模块传输时,可能需要根据需要进行数据封装。)
|
||||
- entity:实体类,与数据库表结构一一对应,用于ORM映射。
|
||||
- vo:视图对象,通常用于返回给前端的数据封装,可以包含多个实体类的属性或仅包含部分实体类的属性。
|
228
harmonylife_20241008.sql
Normal file
228
harmonylife_20241008.sql
Normal file
@ -0,0 +1,228 @@
|
||||
/*
|
||||
Navicat Premium Data Transfer
|
||||
|
||||
Source Server : 本地连接
|
||||
Source Server Type : MySQL
|
||||
Source Server Version : 50743 (5.7.43-log)
|
||||
Source Host : localhost:3306
|
||||
Source Schema : harmonylife
|
||||
|
||||
Target Server Type : MySQL
|
||||
Target Server Version : 50743 (5.7.43-log)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 08/10/2024 20:47:14
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for agent_info
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `agent_info`;
|
||||
CREATE TABLE `agent_info` (
|
||||
`id` bigint(20) NOT NULL COMMENT 'id',
|
||||
`merchant_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户编号',
|
||||
`userId` int(11) NULL DEFAULT NULL COMMENT '用户id(负责人)',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '商户表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of agent_info
|
||||
-- ----------------------------
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for system_action
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `system_action`;
|
||||
CREATE TABLE `system_action` (
|
||||
`id` bigint(11) NOT NULL COMMENT '动作id',
|
||||
`tag` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '动作标签 例如 add',
|
||||
`describe` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '动作标题 例如 增加',
|
||||
`default_check` tinyint(4) NULL DEFAULT NULL COMMENT '0 false 1 true',
|
||||
`status` tinyint(4) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '动作表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of system_action
|
||||
-- ----------------------------
|
||||
INSERT INTO `system_action` VALUES (1, 'add', '新增', 0, 1);
|
||||
INSERT INTO `system_action` VALUES (2, 'import', '导入', 0, 1);
|
||||
INSERT INTO `system_action` VALUES (3, 'get', '详情', 0, 1);
|
||||
INSERT INTO `system_action` VALUES (4, 'update', '更新', 0, 1);
|
||||
INSERT INTO `system_action` VALUES (5, 'delete', '删除', 0, 1);
|
||||
INSERT INTO `system_action` VALUES (6, 'export', '导出', 0, 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for system_menu
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `system_menu`;
|
||||
CREATE TABLE `system_menu` (
|
||||
`id` bigint(11) NOT NULL COMMENT 'id',
|
||||
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '显示的中文名称',
|
||||
`key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'key',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '路由名称',
|
||||
`component` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '组件名称',
|
||||
`redirect` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '重定向',
|
||||
`icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '图标名称',
|
||||
`status` tinyint(4) NULL DEFAULT NULL COMMENT '状态 0 未启用 -1 删除 1正常使用',
|
||||
`parent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '父级',
|
||||
`order` int(11) NULL DEFAULT NULL COMMENT '排序,数字越小,越靠前',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of system_menu
|
||||
-- ----------------------------
|
||||
INSERT INTO `system_menu` VALUES (1, '首页', NULL, 'index', 'BasicLayout', '/dashboard/workplace', '', 1, NULL, 1);
|
||||
INSERT INTO `system_menu` VALUES (2, '仪表盘', 'dashboard', 'dashboard', 'RouteView', NULL, 'dashboard', 1, 'index', 1);
|
||||
INSERT INTO `system_menu` VALUES (3, '分析页', 'analysis', NULL, NULL, NULL, NULL, NULL, NULL, 1);
|
||||
INSERT INTO `system_menu` VALUES (4, '系统管理', 'system', 'system', 'PageView', NULL, 'setting', NULL, 'index', 1);
|
||||
INSERT INTO `system_menu` VALUES (5, '用户管理', 'userList', 'userList', NULL, NULL, NULL, NULL, 'system', 1);
|
||||
INSERT INTO `system_menu` VALUES (6, '菜单管理', 'menuList', 'menuList', NULL, NULL, NULL, NULL, 'system', 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for system_permission
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `system_permission`;
|
||||
CREATE TABLE `system_permission` (
|
||||
`id` bigint(11) NOT NULL COMMENT '权限id',
|
||||
`permission_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限id(文本型)',
|
||||
`permission_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限名称(菜单名称)',
|
||||
`status` tinyint(4) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '权限表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of system_permission
|
||||
-- ----------------------------
|
||||
INSERT INTO `system_permission` VALUES (1, 'dashboard', '数据中心', 1);
|
||||
INSERT INTO `system_permission` VALUES (2, 'exception', '异常管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (3, 'result', '结果管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (4, 'profile', '个人信息管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (5, 'table', '表格管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (6, 'form', '表单管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (7, 'order', '订单管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (8, 'permission', '权限管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (9, 'role', '个人设置', 1);
|
||||
INSERT INTO `system_permission` VALUES (10, 'user', '个人中心', 1);
|
||||
INSERT INTO `system_permission` VALUES (11, 'system', '系统管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (12, 'otherPage', '其他页面', 1);
|
||||
INSERT INTO `system_permission` VALUES (13, 'UserList', '用户列表', 1);
|
||||
INSERT INTO `system_permission` VALUES (14, 'RoleList', '角色列表', 1);
|
||||
INSERT INTO `system_permission` VALUES (15, 'support', '支持', 1);
|
||||
INSERT INTO `system_permission` VALUES (16, 'userManage', '用户管理', 1);
|
||||
INSERT INTO `system_permission` VALUES (17, 'menuManage', '菜单管理', 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for system_permission_action
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `system_permission_action`;
|
||||
CREATE TABLE `system_permission_action` (
|
||||
`id` bigint(11) NOT NULL COMMENT 'id',
|
||||
`action_tag` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '动作id 文本型',
|
||||
`permission_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限id 文本型',
|
||||
`status` tinyint(4) NULL DEFAULT NULL COMMENT '状态',
|
||||
`uid` bigint(20) NULL DEFAULT NULL COMMENT '用户id Long',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of system_permission_action
|
||||
-- ----------------------------
|
||||
INSERT INTO `system_permission_action` VALUES (1, 'add', 'role', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (2, 'import', 'role', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (3, 'get', 'role', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (4, 'update', 'role', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (5, 'delete', 'role', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (6, 'export', 'role', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (7, 'add', 'permission', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (8, 'import', 'permission', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (9, 'get', 'permission', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (10, 'update', 'permission', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (11, 'delete', 'permission', 1, 1);
|
||||
INSERT INTO `system_permission_action` VALUES (12, 'export', 'permission', 1, 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for system_role
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `system_role`;
|
||||
CREATE TABLE `system_role` (
|
||||
`id` bigint(11) NOT NULL COMMENT '角色id role_id',
|
||||
`role_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色名称',
|
||||
`role_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '角色id(文本型)',
|
||||
`status` tinyint(4) NULL DEFAULT NULL,
|
||||
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
|
||||
`level` int(11) NULL DEFAULT NULL COMMENT '数字越小 级别越高 顶级权限为1',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '角色表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of system_role
|
||||
-- ----------------------------
|
||||
INSERT INTO `system_role` VALUES (1, '超级管理员', 'root', 1, '最高权限', 1);
|
||||
INSERT INTO `system_role` VALUES (2, '管理员', 'admin', 1, '管理权限', 2);
|
||||
INSERT INTO `system_role` VALUES (3, '机构', 'agent', 1, '使用权限', 3);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for system_role_permission
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `system_role_permission`;
|
||||
CREATE TABLE `system_role_permission` (
|
||||
`id` bigint(11) NOT NULL,
|
||||
`role_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '注意是文本型',
|
||||
`permission_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '注意是文本型',
|
||||
`status` tinyint(4) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of system_role_permission
|
||||
-- ----------------------------
|
||||
INSERT INTO `system_role_permission` VALUES (1, 'root', 'dashboard', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (2, 'root', 'exception', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (3, 'root', 'result', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (4, 'root', 'profile', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (5, 'root', 'table', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (6, 'root', 'form', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (7, 'root', 'order', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (8, 'root', 'permission', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (9, 'root', 'role', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (10, 'root', 'user', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (11, 'root', 'system', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (12, 'root', 'otherPage', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (13, 'root', 'UserList', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (14, 'root', 'RoleList', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (15, 'root', 'support', 1);
|
||||
INSERT INTO `system_role_permission` VALUES (16, 'root', 'userManage', 1);
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for user_info
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user_info`;
|
||||
CREATE TABLE `user_info` (
|
||||
`id` bigint(11) NOT NULL COMMENT '用户uid',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '昵称(用于显示,可以随意更改)',
|
||||
`username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '用户名(登录使用的账号)',
|
||||
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '密码',
|
||||
`avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '头像图片地址',
|
||||
`status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '状态',
|
||||
`telephone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号',
|
||||
`email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '邮箱',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '注册时间',
|
||||
`merchant_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '商户编号',
|
||||
`deleted` tinyint(4) NULL DEFAULT NULL COMMENT '1 已删除 0未删除',
|
||||
`role_id` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '权限id 文本类型',
|
||||
`creator_id` int(11) NULL DEFAULT NULL COMMENT '创建者id 0 或者空为自己注册',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user_info
|
||||
-- ----------------------------
|
||||
INSERT INTO `user_info` VALUES (1, '萌狼蓝天', 'xrilang', 'VomAhgnr1XAkMKzicqYxdCFBx0ooiXBN66Xq9XCWGJTsJgH3uLJVAVGkoZi2n1Ml', 'https://q1.qlogo.cn/g?b=qq&nk=3447902411&s=640', '1', NULL, NULL, '2024-09-21 22:31:02', '1', 0, 'root', NULL);
|
||||
INSERT INTO `user_info` VALUES (2, '明月新星', 'moon', NULL, 'https://q1.qlogo.cn/g?b=qq&nk=2952458479&s=640', '1', NULL, NULL, '2024-09-24 11:42:44', '1', 0, 'admin', 1);
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
3877
logs/app.log
3877
logs/app.log
File diff suppressed because it is too large
Load Diff
4584
logs/application.log
Normal file
4584
logs/application.log
Normal file
File diff suppressed because one or more lines are too long
@ -1,12 +1,10 @@
|
||||
package com.guaiguailang.harmony.config;
|
||||
|
||||
import cn.dev33.satoken.util.SaResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
|
@ -1,16 +1,14 @@
|
||||
package com.guaiguailang.harmony.controller;
|
||||
|
||||
import com.guaiguailang.harmony.domain.dto.ParamLogin;
|
||||
import com.guaiguailang.harmony.domain.dto.ParamUserAdd;
|
||||
import com.guaiguailang.harmony.domain.dto.ParamUserList;
|
||||
import com.guaiguailang.harmony.service.UserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@ -48,4 +46,15 @@ public class UserController {
|
||||
public ResponseEntity getUserListNum(){
|
||||
return ResponseEntity.ok(userService.getUserListNum());
|
||||
}
|
||||
|
||||
@PostMapping("/add/roleList")
|
||||
public ResponseEntity getRoleListWhenAddUser(@RequestParam String role){
|
||||
// System.out.println("当前用户权限:"+role);
|
||||
return ResponseEntity.ok(userService.getRoleListWhenAddUser(role));
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public ResponseEntity addUser(@RequestBody ParamUserAdd userAddParam){
|
||||
return ResponseEntity.ok(userService.addUser(userAddParam));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.guaiguailang.harmony.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class ParamUserAdd {
|
||||
// 创建人
|
||||
Long creatorId;
|
||||
String name;
|
||||
String userName;
|
||||
String password;
|
||||
String email;
|
||||
String telphone;
|
||||
String roleId;
|
||||
String avatar;
|
||||
int status;
|
||||
LocalDateTime createTime;
|
||||
String merchantCode; // 商户编号
|
||||
Long id;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.guaiguailang.harmony.mapper;
|
||||
|
||||
import com.guaiguailang.harmony.domain.dto.ParamUserAdd;
|
||||
import com.guaiguailang.harmony.domain.entity.SystemRole;
|
||||
import com.guaiguailang.harmony.domain.entity.UserInfo;
|
||||
import com.guaiguailang.harmony.domain.vo.UserListNum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -23,4 +25,9 @@ public interface UserMapper {
|
||||
List<UserInfo> getUserListAll(int limit,int end, String merchantCode, Map<String, Object> queryConditions);
|
||||
|
||||
UserListNum getUserListNum(String merchantCode);
|
||||
@Select("SELECT * FROM system_role WHERE level > (SELECT level FROM system_role WHERE role_id = #{roleId})")
|
||||
List<SystemRole> getRoleListWhenAddUser(String role);
|
||||
|
||||
|
||||
int addUser(ParamUserAdd userAddParam);
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.guaiguailang.harmony.service;
|
||||
|
||||
import com.guaiguailang.harmony.domain.dto.ParamUserAdd;
|
||||
import com.guaiguailang.harmony.domain.dto.ParamUserList;
|
||||
import com.guaiguailang.harmony.domain.vo.ResponseResult;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
public interface UserService {
|
||||
ResponseResult getUserInfo();
|
||||
@ -9,4 +11,8 @@ public interface UserService {
|
||||
ResponseResult getUserList(ParamUserList userListParam);
|
||||
|
||||
Object getUserListNum();
|
||||
|
||||
ResponseResult getRoleListWhenAddUser(String role);
|
||||
|
||||
ResponseResult addUser(ParamUserAdd userAddParam);
|
||||
}
|
||||
|
@ -16,11 +16,13 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDateTime;
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class AuthServiceImpl implements AuthService {
|
||||
@Autowired
|
||||
private final AuthMapper authMapper;
|
||||
@ -42,6 +44,7 @@ public class AuthServiceImpl implements AuthService {
|
||||
return ResponseResult.error("用户不存在");
|
||||
}
|
||||
log.info("查询到用户{}", userInfo.toString());
|
||||
|
||||
// 验证密码
|
||||
boolean isVerified = PasswordEncryptor.verifyPassword(userInfo.getPassword(), loginParam.getPassword());
|
||||
if (!isVerified) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.guaiguailang.harmony.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.github.yitter.idgen.YitIdHelper;
|
||||
import com.guaiguailang.harmony.domain.dto.ParamUserAdd;
|
||||
import com.guaiguailang.harmony.domain.dto.ParamUserList;
|
||||
import com.guaiguailang.harmony.domain.entity.SystemAction;
|
||||
import com.guaiguailang.harmony.domain.entity.SystemPermission;
|
||||
@ -10,15 +12,20 @@ import com.guaiguailang.harmony.domain.vo.*;
|
||||
import com.guaiguailang.harmony.mapper.AuthMapper;
|
||||
import com.guaiguailang.harmony.mapper.UserMapper;
|
||||
import com.guaiguailang.harmony.service.UserService;
|
||||
import com.guaiguailang.harmony.utils.PasswordEncryptor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
private final UserMapper userMapper;
|
||||
@ -120,4 +127,58 @@ public class UserServiceImpl implements UserService {
|
||||
UserListNum userListNum = userMapper.getUserListNum(merchantCode);
|
||||
return ResponseResult.success(userListNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult getRoleListWhenAddUser(String role) {
|
||||
return ResponseResult.success(userMapper.getRoleListWhenAddUser(role));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult addUser(ParamUserAdd userAddParam) {
|
||||
// 先根据用户账号username查询用户是否存在,避免重复
|
||||
UserInfo userInfo = getUserByAccount(userAddParam.getUserName());
|
||||
if (userInfo != null) {
|
||||
return ResponseResult.error("用户账号已存在");
|
||||
}
|
||||
// 创建者
|
||||
userAddParam.setCreatorId(Long.parseLong(StpUtil.getLoginId().toString()));
|
||||
System.out.println(
|
||||
userAddParam.getCreatorId()
|
||||
);
|
||||
// 判断是否包含商户信息,不包含则继承创建人的商户信息
|
||||
if (userAddParam.getMerchantCode()==null){
|
||||
UserInfo creator = userMapper.getUserById(userAddParam.getCreatorId());
|
||||
userAddParam.setMerchantCode(creator.getMerchantCode());
|
||||
}
|
||||
|
||||
// userInfo add data
|
||||
// 密码加密
|
||||
try{
|
||||
userAddParam.setPassword( PasswordEncryptor.hashPassword(userAddParam.getPassword()));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return ResponseResult.error(e.getMessage());
|
||||
}
|
||||
// 配置id
|
||||
userAddParam.setId(YitIdHelper.nextId());
|
||||
// 注册时间
|
||||
userAddParam.setCreateTime(LocalDateTime.now());
|
||||
// 账号状态 默认激活
|
||||
|
||||
userAddParam.setStatus(1);
|
||||
|
||||
|
||||
|
||||
int result = userMapper.addUser(userAddParam);
|
||||
if (result == 1) {
|
||||
return ResponseResult.success(userAddParam);
|
||||
}else {
|
||||
return ResponseResult.error("新增用户失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 方法
|
||||
public UserInfo getUserByAccount(String username){
|
||||
return userMapper.getUserByAccount(username);
|
||||
}
|
||||
}
|
||||
|
@ -55,4 +55,16 @@
|
||||
WHERE merchant_code = #{merchantCode}
|
||||
</if>
|
||||
</select>
|
||||
<!-- 插入新用户 -->
|
||||
<insert id="addUser" parameterType="com.guaiguailang.harmony.domain.dto.ParamUserAdd">
|
||||
INSERT INTO user_info (
|
||||
id, name, username, password, avatar, status, telephone, email, create_time, merchant_code, deleted, role_id, creator_id
|
||||
) VALUES (
|
||||
#{id}, #{name}, #{userName}, #{password}, #{avatar}, #{status}, #{telphone}, #{email}, #{createTime},
|
||||
<!-- 使用嵌套查询来获取merchant_code -->
|
||||
#{merchantCode},
|
||||
0, #{roleId}, #{creatorId}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user