2 Commits

Author SHA1 Message Date
aa736525b6 更新 .drone.yml 2026-01-13 11:45:15 +08:00
b423ea902c 1 2025-11-08 18:11:16 +08:00
148 changed files with 1468 additions and 1105 deletions

View File

@@ -36,8 +36,8 @@ buildNumber.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
### Example user template template
### Example user template
### Example userDetail template template
### Example userDetail template
# IntelliJ project files
.idea

View File

@@ -3,15 +3,16 @@ type: docker
name: fateverse
steps:
- name: build-jar # 流水线名称
image: maven:3.8.5-openjdk-11 # 定义创建容器的Docker镜像,maven:3.8.5-openjdk-8用于对java进行打包使用
volumes: # 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-cache
path: /root/.m2 # 将maven下载依赖的目录挂载出来防止重复下载
- name: settings
path: /usr/share/maven/conf/settings.xml
- name: maven-build
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
- name: skywalking-agent
path: /app/build/skywalking-agent
commands: # 定义在Docker容器中执行的shell命令
- sed -i 's/$DRONE_COMMIT_BRANCH/'"$DRONE_COMMIT_BRANCH"'/' start.sh
- bash maven.sh
@@ -19,6 +20,8 @@ steps:
- name: build-docker # 制作docker镜像
image: registry.cn-chengdu.aliyuncs.com/claywang/docker:20.10.1 # 使用官方docker镜像
volumes: # 将容器内目录挂载到宿主机
- name: maven-build
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
- name: docker
path: /var/run/docker.sock # 挂载宿主机的docker
environment: # 获取到密文的docker用户名和密码
@@ -51,20 +54,25 @@ steps:
- name: deploy # rancher运行
image: registry.cn-chengdu.aliyuncs.com/claywang/kubectl #阿里云的kubectl镜像,里面包含kubectl命令行工具
volumes: # 将容器内目录挂载到宿主机
- name: maven-build
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
- name: config
path: /app/config # 将kubectl 配置文件挂载出来
commands: # 定义在Docker容器中执行的shell命令
- cd /app/build/$DRONE_COMMIT_BRANCH
# 通过kubectl指令运行deployment.yml,并指定授权文件kubectl_conf.yml
- kubectl apply -f deployment.yml -n master --kubeconfig=/app/config/kubectl.yml
- kubectl apply -f deployment.yml -n fateverse --kubeconfig=/app/config/base-taishan-kubectl.yml
volumes:
- name: settings
- name: maven-build
host:
path: /home/kubect/settings.xml
- name: config
path: /home/build/fateverse
- name: skywalking-agent
host:
path: /home/build/skywalking-agent
- name: config # k8s对接的配置文件
host:
path: /home/kubect
- name: maven-cache
@@ -73,8 +81,6 @@ volumes:
- name: docker
host:
path: /var/run/docker.sock
# 定义触发条件
trigger:
branch:

View File

@@ -2,7 +2,7 @@ package cn.fateverse.admin.dto;
import cn.fateverse.admin.entity.Config;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@@ -20,41 +20,41 @@ public class ConfigDto {
/**
* 参数主键
*/
@Schema(description = "参数主键")
@ApiModelProperty("参数主键")
private Integer configId;
/**
* 参数名称
*/
@NotNull(message = "参数名称不能为空!")
@Schema(description = "参数名称")
@ApiModelProperty("参数名称")
private String configName;
/**
* 参数键名
*/
@NotNull(message = "参数键名不能为空!")
@Schema(description = "参数键名")
@ApiModelProperty("参数键名")
private String configKey;
/**
* 参数键值
*/
@NotNull(message = "参数键值不能为空!")
@Schema(description = "参数键值")
@ApiModelProperty("参数键值")
private String configValue;
/**
* 系统内置1是 0否
*/
@NotNull(message = "是否系统内置不能为空!")
@Schema(description = "系统内置1是 0否")
@ApiModelProperty("系统内置1是 0否")
private Integer configType;
/**
* 备注
*/
@Schema(description = "备注")
@ApiModelProperty("备注")
private String remark;
public Config toConfig() {

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@@ -20,51 +20,51 @@ public class DictDataDto {
/**
* 字典排序
*/
@Schema(description = "字典排序")
@ApiModelProperty("字典排序")
@NotNull(message = "状态不能为空!")
private Integer dictSort;
/**
* 字典标签
*/
@Schema(description = "字典标签")
@ApiModelProperty("字典标签")
@NotNull(message = "字典标签不能为空!")
private String dictLabel;
/**
* 字典键值
*/
@Schema(description = "字典键值")
@ApiModelProperty("字典键值")
@NotNull(message = "字典键值不能为空!")
private String dictValue;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
@NotNull(message = "字典类型不能为空!")
private String dictType;
/**
* 样式属性(其他样式扩展)
*/
@Schema(description = "样式属性(其他样式扩展)")
@ApiModelProperty("样式属性(其他样式扩展)")
private Boolean isType;
/**
* 表格回显样式
*/
@Schema(description = "表格回显样式")
@ApiModelProperty("表格回显样式")
private String listClass;
/**
* 字典显示主题(ui框架时)or文字颜色(自定义颜色时)
*/
@Schema(description = "字典显示主题(ui框架时)or文字颜色(自定义颜色时)")
@ApiModelProperty("字典显示主题(ui框架时)or文字颜色(自定义颜色时)")
private String theme;
/**
* 是否默认Y是 N否
*/
@Schema(description = "是否默认Y是 N否")
@ApiModelProperty("是否默认Y是 N否")
private Integer isDefault;
/**
* 状态1正常 0停用
*/
@Schema(description = "状态1正常 0停用",required = true)
@ApiModelProperty(value = "状态1正常 0停用",required = true)
@NotNull(message = "状态不能为空!")
private String state;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@@ -17,24 +17,24 @@ public class DictTypeDto {
/**
* 字典主键
*/
@Schema(description = "字典主键")
@ApiModelProperty("字典主键")
private Long dictId;
/**
* 字典名称
*/
@Schema(description = "字典名称")
@ApiModelProperty("字典名称")
@NotNull(message = "字典名称不能为空!")
private String dictName;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
@NotNull(message = "字典类型不能为空!")
private String dictType;
/**
* 字典状态1正常 0停用
*/
@Schema(description = "字典状态")
@ApiModelProperty("字典状态")
@NotNull(message = "字典状态不能为空!")
private String state;

View File

@@ -1,6 +1,6 @@
package cn.fateverse.admin.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@@ -14,13 +14,13 @@ public class IpBackDto {
/**
* 主键id
*/
@Schema(description = "主键id")
@ApiModelProperty("主键id")
private Long id;
/**
* ip地址
*/
@NotBlank(message = "ip地址不能为空")
@Schema(description = "ip地址")
@ApiModelProperty("ip地址")
private String ipAddr;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@@ -21,7 +21,7 @@ public class MenuDto implements Serializable {
/**
* 菜单ID
*/
@Schema(description = "菜单ID")
@ApiModelProperty("菜单ID")
private Long menuId;
/**
@@ -29,86 +29,86 @@ public class MenuDto implements Serializable {
*/
@NotBlank(message = "菜单名称不能为空")
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
@Schema(description = "菜单名称")
@ApiModelProperty("菜单名称")
private String menuName;
/**
* 父菜单ID
*/
@Schema(description = "父菜单ID")
@ApiModelProperty("父菜单ID")
private Long parentId;
/**
* 显示顺序
*/
@Schema(description = "显示顺序")
@ApiModelProperty("显示顺序")
@NotNull(message = "显示顺序不能为空")
private Integer orderNum;
/**
* 路由地址
*/
@Schema(description = "路由地址")
@ApiModelProperty("路由地址")
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
private String path;
@Schema(description = "路径参数")
@ApiModelProperty("路径参数")
private String pathParams;
/**
* 组件路径
*/
@Schema(description = "组件路径")
@ApiModelProperty("组件路径")
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
private String component;
/**
* 是否为外链0是 1否
*/
@Schema(description = "是否为外链0是 1否")
@ApiModelProperty("是否为外链0是 1否")
private Boolean isFrame;
/**
* 是否缓存0缓存 1不缓存
*/
@Schema(description = "是否缓存0缓存 1不缓存")
@ApiModelProperty("是否缓存0缓存 1不缓存")
private Boolean isCache;
@Schema(description = "不重定向")
@ApiModelProperty("不重定向")
private Boolean noRedirect;
@Schema(description = "面包屑")
@ApiModelProperty("面包屑")
private Boolean breadcrumb;
/**
* 类型D目录 M菜单 B按钮
*/
@Schema(description = "类型D目录 M菜单 B按钮")
@ApiModelProperty("类型D目录 M菜单 B按钮")
@NotBlank(message = "菜单类型不能为空")
private String menuType;
/**
* 显示状态0显示 1隐藏
*/
@Schema(description = "显示状态0显示 1隐藏")
@ApiModelProperty("显示状态0显示 1隐藏")
private String visible;
/**
* 菜单状态0显示 1隐藏
*/
@Schema(description = "菜单状态0显示 1隐藏")
@ApiModelProperty("菜单状态0显示 1隐藏")
private String state;
/**
* 权限字符串
*/
@Schema(description = "权限字符串")
@ApiModelProperty("权限字符串")
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
private String perms;
/**
* 菜单图标
*/
@Schema(description = "菜单图标")
@ApiModelProperty("菜单图标")
private String icon;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@@ -17,30 +17,30 @@ public class PostDto {
/**
* 岗位ID
*/
@Schema(description = "岗位ID")
@ApiModelProperty("岗位ID")
private Long postId;
/**
* 岗位编码
*/
@Schema(description = "岗位编码")
@ApiModelProperty("岗位编码")
@NotNull(message = "岗位编码不能为空!")
private String postCode;
/**
* 岗位名称
*/
@Schema(description = "岗位名称")
@ApiModelProperty("岗位名称")
@NotNull(message = "岗位名称不能为空!")
private String postName;
/**
* 显示顺序
*/
@Schema(description = "显示顺序")
@ApiModelProperty("显示顺序")
@NotNull(message = "显示顺序不能为空!")
private Integer postSort;
/**
* 状态1正常 0停用
*/
@Schema(description = "状态1正常 0停用")
@ApiModelProperty("状态1正常 0停用")
@NotNull(message = "状态不能为空!")
private String state;

View File

@@ -2,7 +2,7 @@ package cn.fateverse.admin.dto;
import cn.fateverse.common.core.entity.Role;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -24,53 +24,53 @@ public class RoleDto {
/**
* 角色ID
*/
@Schema(description = "角色id")
@ApiModelProperty("角色id")
private Long roleId;
/**
* 角色名称
*/
@Schema(description = "角色名称")
@ApiModelProperty("角色名称")
@NotBlank(message = "角色名称不能为空!")
private String roleName;
/**
* 角色关键词
*/
@Schema(description = "角色关键词")
@ApiModelProperty("角色关键词")
@NotBlank(message = "角色关键词不能为空!")
private String roleKey;
/**
* 角色排序
*/
@Schema(description = "角色排序")
@ApiModelProperty("角色排序")
@NotNull(message = "角色排序不能为空!")
private Integer roleSort;
/**
* 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限
*/
@Schema(description = "数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限")
@ApiModelProperty("数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限")
private String dataScope;
/**
* 角色状态1正常 0停用
*/
@Schema(description = "角色状态1正常 0停用")
@ApiModelProperty("角色状态1正常 0停用")
@NotBlank(message = "角色状态不能为空!")
private String state;
/**
* 菜单组
*/
@Schema(description = "菜单组")
@ApiModelProperty("菜单组")
private Set<Long> menuIds;
/**
* 部门组(数据权限)
*/
@Schema(description = "部门组(数据权限)")
@ApiModelProperty("部门组(数据权限)")
private Long[] deptIds;
public Role toRole() {

View File

@@ -1,8 +1,8 @@
package cn.fateverse.admin.dto;
import cn.fateverse.common.core.entity.UserBase;
import cn.fateverse.common.core.entity.User;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Email;
@@ -74,17 +74,17 @@ public class UserDto{
/**
* 岗位ids
*/
@Schema(description = "岗位ids")
@ApiModelProperty("岗位ids")
private List<Long> postIds;
/**
* 角色ids
*/
@Schema(description = "角色ids")
@ApiModelProperty("角色ids")
private List<Long> roleIds;
public UserBase toUser() {
return UserBase.builder()
public User toUser() {
return User.builder()
.userId(userId)
.deptId(deptId)
.userName(userName)

View File

@@ -1,7 +1,8 @@
package cn.fateverse.admin.dubbo;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.UserDetail;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.List;
@@ -17,7 +18,7 @@ public interface DubboUserService {
* @param username 用户名称
* @return 用户信息
*/
User getUserByUsername(String username);
UserVo getUserByUsername(String username);
/**
* 根据用户id查询用户信息
@@ -25,7 +26,7 @@ public interface DubboUserService {
* @param userId 用户id
* @return 用户信息
*/
User getUserByUserId(Long userId);
UserVo getUserByUserId(Long userId);
/**
* 根据roleId查询用户列表
@@ -57,4 +58,12 @@ public interface DubboUserService {
* @return 所有用户的id
*/
List<Long> searchAllUserIds();
/**
* 通过用户名获取用户详细信息
*
* @param userName 用户名
* @return {@link UserDetails }
*/
UserDetail getUserDetailsByUserName(String userName);
}

View File

@@ -3,7 +3,7 @@ package cn.fateverse.admin.entity;
import cn.fateverse.common.core.annotaion.EnableAutoField;
import cn.fateverse.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@@ -20,24 +20,24 @@ public class DictType extends BaseEntity {
/**
* 字典主键
*/
@Schema(description = "字典主键")
@ApiModelProperty("字典主键")
private Long dictId;
/**
* 字典名称
*/
@Schema(description = "字典名称")
@ApiModelProperty("字典名称")
@NotNull(message = "字典名称不能为空!")
private String dictName;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
@NotNull(message = "字典类型不能为空!")
private String dictType;
/**
* 字典状态1正常 0停用
*/
@Schema(description = "字典状态")
@ApiModelProperty("字典状态")
@NotNull(message = "字典状态不能为空!")
private String state;

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
@@ -19,45 +19,45 @@ public class OnlineUser {
/**
* 会话id
*/
@Schema(description = "会话id")
@ApiModelProperty("会话id")
private String tokenId;
/**
* 用户名
*/
@Schema(description = "用户名")
@ApiModelProperty("用户名")
private String username;
/**
* 部门名称
*/
@Schema(description = "部门名称")
@ApiModelProperty("部门名称")
private String deptName;
/**
* 登录ip
*/
@Schema(description = "登录ip")
@ApiModelProperty("登录ip")
private String ipAddr;
/**
* 登录地点
*/
@Schema(description = "登录地点")
@ApiModelProperty("登录地点")
private String loginLocation;
/**
* 浏览器类型
*/
@Schema(description = "浏览器类型")
@ApiModelProperty("浏览器类型")
private String browser;
/**
* 操作系统
*/
@Schema(description = "操作系统")
@ApiModelProperty("操作系统")
private String os;
/**
* 登录时间
*/
@Schema(description = "登录时间")
@ApiModelProperty("登录时间")
private Date loginTime;

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.query;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -21,18 +21,18 @@ public class ConfigQuery {
/**
* 参数名称
*/
@Schema(description = "参数名称")
@ApiModelProperty("参数名称")
private String configName;
/**
* 参数键名
*/
@Schema(description = "参数键名")
@ApiModelProperty("参数键名")
private String configKey;
/**
* 系统内置1是 0否
*/
@Schema(description = "系统内置1是 0否")
@ApiModelProperty("系统内置1是 0否")
private Integer configType;
}

View File

@@ -1,6 +1,6 @@
package cn.fateverse.admin.query;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -13,16 +13,16 @@ public class DictDataQuery {
/**
* 字典类型
*/
@Schema(description = "字典名称",required = true)
@ApiModelProperty(value = "字典名称",required = true)
private String dictType;
/**
* 字典标签
*/
@Schema(description = "字典标签")
@ApiModelProperty("字典标签")
private String dictLabel;
/**
* 状态1正常 0停用
*/
@Schema(description = "帐号状态1正常 0停用")
@ApiModelProperty("帐号状态1正常 0停用")
private String state;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.query;
import cn.fateverse.common.core.entity.QueryTime;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -14,18 +14,18 @@ public class DictTypeQuery extends QueryTime {
/**
* 字典名称
*/
@Schema(description = "字典名称")
@ApiModelProperty("字典名称")
private String dictName;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
private String dictType;
/**
* 帐号状态1正常 0停用
*/
@Schema(description = "帐号状态1正常 0停用")
@ApiModelProperty("帐号状态1正常 0停用")
private String state;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.query;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -12,12 +12,12 @@ import lombok.Data;
@ApiModel("接口开关Query")
public class MappingSwitchQuery {
@Schema(description = "应用名称")
@ApiModelProperty("应用名称")
private String applicationName;
@Schema(description = "类别名称")
@ApiModelProperty("类别名称")
private String className;
@Schema(description = "方法名称")
@ApiModelProperty("方法名称")
private String methodName;
}

View File

@@ -1,6 +1,6 @@
package cn.fateverse.admin.query;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -17,18 +17,18 @@ public class PostQuery {
/**
* 岗位编码
*/
@Schema(description = "岗位编码")
@ApiModelProperty("岗位编码")
private String postCode;
/**
* 岗位名称
*/
@Schema(description = "岗位名称")
@ApiModelProperty("岗位名称")
private String postName;
/**
* 状态1正常 0停用
*/
@Schema(description = "状态1正常 0停用")
@ApiModelProperty("状态1正常 0停用")
private String state;
}

View File

@@ -2,7 +2,7 @@ package cn.fateverse.admin.query;
import cn.fateverse.common.core.entity.QueryTime;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -15,17 +15,17 @@ public class RoleQuery extends QueryTime {
/**
* 权限字符
*/
@Schema(description = "角色名称")
@ApiModelProperty("角色名称")
private String roleName;
/**
* 权限字符
*/
@Schema(description = "权限字符")
@ApiModelProperty("权限字符")
private String roleKey;
/**
* 帐号状态1正常 0停用
*/
@Schema(description = "帐号状态1正常 0停用")
@ApiModelProperty("帐号状态1正常 0停用")
private String state;
}

View File

@@ -2,7 +2,7 @@ package cn.fateverse.admin.query;
import cn.fateverse.common.core.entity.QueryTime;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -16,25 +16,25 @@ public class UserQuery extends QueryTime {
/**
* 部门ID
*/
@Schema(description = "部门ID")
@ApiModelProperty("部门ID")
private Long deptId;
/**
* 用户账号
*/
@Schema(description = "用户账号")
@ApiModelProperty("用户账号")
private String userName;
/**
* 手机号码
*/
@Schema(description = "手机号码")
@ApiModelProperty("手机号码")
private String phoneNumber;
/**
* 帐号状态1正常 0停用
*/
@Schema(description = "帐号状态1正常 0停用")
@ApiModelProperty("帐号状态1正常 0停用")
private String state;

View File

@@ -3,7 +3,7 @@ package cn.fateverse.admin.vo;
import cn.fateverse.admin.entity.Config;
import cn.fateverse.common.core.annotaion.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -25,41 +25,41 @@ public class ConfigVo {
/**
* 参数主键
*/
@Schema(description = "参数主键")
@ApiModelProperty("参数主键")
private Integer configId;
/**
* 参数名称
*/
@Schema(description = "参数名称")
@ApiModelProperty("参数名称")
@Excel("参数名称")
private String configName;
/**
* 参数键名
*/
@Schema(description = "参数键名")
@ApiModelProperty("参数键名")
@Excel("参数键名")
private String configKey;
/**
* 参数键值
*/
@Schema(description = "参数键值")
@ApiModelProperty("参数键值")
@Excel("参数键值")
private String configValue;
/**
* 系统内置1是 0否
*/
@Schema(description = "系统内置1是 0否")
@ApiModelProperty("系统内置1是 0否")
@Excel("系统内置1是 0否")
private Integer configType;
/**
* 备注
*/
@Schema(description = "备注")
@ApiModelProperty("备注")
@Excel("备注")
private String remark;

View File

@@ -2,7 +2,7 @@ package cn.fateverse.admin.vo;
import cn.fateverse.admin.entity.DictData;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -23,34 +23,34 @@ public class DictDataSimpVo {
/**
* 字典标签
*/
@Schema(description = "字典标签")
@ApiModelProperty("字典标签")
@NotNull(message = "字典标签不能为空!")
private String label;
/**
* 字典键值
*/
@Schema(description = "字典键值")
@ApiModelProperty("字典键值")
@NotNull(message = "字典键值不能为空!")
private String value;
/**
* 样式属性(其他样式扩展)
*/
@Schema(description = "样式属性(其他样式扩展)")
@ApiModelProperty("样式属性(其他样式扩展)")
private Boolean isType;
/**
* 表格回显样式
*/
@Schema(description = "表格回显样式")
@ApiModelProperty("表格回显样式")
private String listClass;
/**
* 字典显示主题(ui框架时)or文字颜色(自定义颜色时)
*/
@Schema(description = "字典显示主题(ui框架时)or文字颜色(自定义颜色时)")
@ApiModelProperty("字典显示主题(ui框架时)or文字颜色(自定义颜色时)")
private String theme;
/**
* 是否默认Y是 N否
*/
@Schema(description = "是否默认Y是 N否")
@ApiModelProperty("是否默认Y是 N否")
private Integer isDefault;

View File

@@ -1,13 +1,12 @@
package cn.fateverse.admin.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
@@ -29,52 +28,52 @@ public class DictDataVo implements Serializable {
/**
* 字典排序
*/
@Schema(description = "字典排序")
@ApiModelProperty("字典排序")
private Integer dictSort;
/**
* 字典标签
*/
@Schema(description = "字典标签")
@ApiModelProperty("字典标签")
private String dictLabel;
/**
* 字典键值
*/
@Schema(description = "字典键值")
@ApiModelProperty("字典键值")
private String dictValue;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
private String dictType;
/**
* 样式属性(其他样式扩展)
*/
@Schema(description = "样式属性(其他样式扩展)")
@ApiModelProperty("样式属性(其他样式扩展)")
private Boolean isType;
/**
* 表格回显样式
*/
@Schema(description = "表格回显样式")
@ApiModelProperty("表格回显样式")
private String listClass;
/**
* 字典显示主题(ui框架时)or文字颜色(自定义颜色时)
*/
@Schema(description = "字典显示主题(ui框架时)or文字颜色(自定义颜色时)")
@ApiModelProperty("字典显示主题(ui框架时)or文字颜色(自定义颜色时)")
private String theme;
/**
* 是否默认Y是 N否
*/
@Schema(description = "是否默认Y是 N否")
@ApiModelProperty("是否默认Y是 N否")
private Integer isDefault;
/**
* 状态1正常 0停用
*/
@Schema(description = "状态1正常 0停用")
@ApiModelProperty(value = "状态1正常 0停用")
private String state;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}

View File

@@ -2,7 +2,7 @@ package cn.fateverse.admin.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
@@ -19,29 +19,29 @@ public class DictTypeVo {
/**
* 字典id
*/
@Schema(description = "字典id")
@ApiModelProperty("字典id")
private Long dictId;
/**
* 字典名称
*/
@Schema(description = "字典名称")
@ApiModelProperty("字典名称")
private String dictName;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
private String dictType;
/**
* 帐号状态1正常 0停用
*/
@Schema(description = "帐号状态1正常 0停用")
@ApiModelProperty("帐号状态1正常 0停用")
private String state;
/**
* 创建时间
*/
@Schema(description = "创建时间")
@ApiModelProperty("创建时间")
private LocalDateTime createTime;

View File

@@ -3,7 +3,7 @@ package cn.fateverse.admin.vo;
import cn.fateverse.admin.entity.IpBack;
import cn.fateverse.common.core.annotaion.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -24,19 +24,19 @@ public class IpBackVo {
/**
* 主键id
*/
@Schema(description = "主键id")
@ApiModelProperty("主键id")
@Excel("id")
private Long id;
/**
* ip地址
*/
@Schema(description = "ip地址")
@ApiModelProperty("ip地址")
@Excel("ip地址")
private String ipAddr;
/**
* ip类型 ipv4 ipv6
*/
@Schema(description = "ip类型 ipv4 ipv6")
@ApiModelProperty("ip类型 ipv4 ipv6")
@Excel("ip类型 ipv4 ipv6")
private String type;
/**
@@ -45,7 +45,7 @@ public class IpBackVo {
@Excel("备注信息")
private String remark;
@Schema(description = "创建时间")
@ApiModelProperty("创建时间")
@Excel("创建时间")
private LocalDateTime createTime;

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -25,48 +25,48 @@ public class MenuSimpVo {
/**
* 菜单ID
*/
@Schema(description = "菜单ID")
@ApiModelProperty("菜单ID")
private Long menuId;
/**
* 菜单名称
*/
@Schema(description = "菜单名称")
@ApiModelProperty("菜单名称")
private String menuName;
/**
* 菜单图标
*/
@Schema(description = "菜单图标")
@ApiModelProperty("菜单图标")
private String icon;
/**
* 显示顺序
*/
@Schema(description = "显示顺序")
@ApiModelProperty("显示顺序")
private Integer orderNum;
@Schema(description = "显示顺序")
@ApiModelProperty("显示顺序")
private String menuType;
/**
* 权限字符串
*/
@Schema(description = "权限字符串")
@ApiModelProperty("权限字符串")
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
private String perms;
/**
* 组件路径
*/
@Schema(description = "组件路径")
@ApiModelProperty("组件路径")
private String component;
/**
* 菜单状态0显示 1隐藏
*/
@Schema(description = "菜单状态0显示 1隐藏")
@ApiModelProperty("菜单状态0显示 1隐藏")
private String state;
/**

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@@ -18,87 +18,87 @@ public class MenuVo implements Serializable {
/**
* 菜单ID
*/
@Schema(description = "菜单ID")
@ApiModelProperty("菜单ID")
private Long menuId;
/**
* 菜单名称
*/
@Schema(description = "菜单名称")
@ApiModelProperty("菜单名称")
private String menuName;
/**
* 父菜单ID
*/
@Schema(description = "父菜单ID")
@ApiModelProperty("父菜单ID")
private Long parentId;
/**
* 显示顺序
*/
@Schema(description = "显示顺序")
@ApiModelProperty("显示顺序")
private Integer orderNum;
/**
* 路由地址
*/
@Schema(description = "路由地址")
@ApiModelProperty("路由地址")
private String path;
@Schema(description = "路径参数")
@ApiModelProperty("路径参数")
private String pathParams;
/**
* 组件路径
*/
@Schema(description = "组件路径")
@ApiModelProperty("组件路径")
private String component;
/**
* 是否为外链0是 1否
*/
@Schema(description = "是否为外链0是 1否")
@ApiModelProperty("是否为外链0是 1否")
private Boolean isFrame;
/**
* 是否缓存0缓存 1不缓存
*/
@Schema(description = "是否缓存0缓存 1不缓存")
@ApiModelProperty("是否缓存0缓存 1不缓存")
private Boolean isCache;
@Schema(description = "不重定向")
@ApiModelProperty("不重定向")
private Boolean noRedirect;
@Schema(description = "面包屑")
@ApiModelProperty("面包屑")
private Boolean breadcrumb;
/**
* 类型D目录 M菜单 B按钮
*/
@Schema(description = "类型D目录 M菜单 B按钮")
@ApiModelProperty("类型D目录 M菜单 B按钮")
private String menuType;
/**
* 显示状态0显示 1隐藏
*/
@Schema(description = "显示状态0显示 1隐藏")
@ApiModelProperty("显示状态0显示 1隐藏")
private String visible;
/**
* 菜单状态0显示 1隐藏
*/
@Schema(description = "菜单状态0显示 1隐藏")
@ApiModelProperty("菜单状态0显示 1隐藏")
private String state;
/**
* 权限字符串
*/
@Schema(description = "权限字符串")
@ApiModelProperty("权限字符串")
private String perms;
/**
* 菜单图标
*/
@Schema(description = "菜单图标")
@ApiModelProperty("菜单图标")
private String icon;
}

View File

@@ -2,7 +2,7 @@ package cn.fateverse.admin.vo;
import cn.fateverse.common.core.entity.OptionTree;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
@@ -18,9 +18,9 @@ import java.util.Set;
@ApiModel("角色修改时菜单返回实体")
public class OptionMenuVo {
@Schema(description = "已选择的")
@ApiModelProperty("已选择的")
private Set<Long> checked;
@Schema(description = "菜单选择option")
@ApiModelProperty("菜单选择option")
private List<OptionTree> menuOption;
}

View File

@@ -3,12 +3,11 @@ package cn.fateverse.admin.vo;
import cn.fateverse.admin.entity.Post;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;
/**
@@ -23,30 +22,30 @@ public class PostVo {
/**
* 岗位ID
*/
@Schema(description = "岗位ID")
@ApiModelProperty("岗位ID")
private Long postId;
/**
* 岗位编码
*/
@Schema(description = "岗位编码")
@ApiModelProperty("岗位编码")
@NotNull(message = "岗位编码不能为空!")
private String postCode;
/**
* 岗位名称
*/
@Schema(description = "岗位名称")
@ApiModelProperty("岗位名称")
@NotNull(message = "岗位名称不能为空!")
private String postName;
/**
* 显示顺序
*/
@Schema(description = "显示顺序")
@ApiModelProperty("显示顺序")
@NotNull(message = "显示顺序不能为空!")
private Integer postSort;
/**
* 状态1正常 0停用
*/
@Schema(description = "状态1正常 0停用")
@ApiModelProperty("状态1正常 0停用")
@NotNull(message = "状态不能为空!")
private String state;
@@ -54,7 +53,7 @@ public class PostVo {
* 创建时间
*/
@JsonFormat(locale = "zh",timezone = "GMT+8",pattern = "yyyy-MM-dd")
private LocalDateTime createTime;
private Date createTime;
public static PostVo toPostVo(Post post){
return PostVo.builder()

View File

@@ -2,13 +2,12 @@ package cn.fateverse.admin.vo;
import cn.fateverse.common.core.entity.Role;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Set;
@@ -23,46 +22,46 @@ import java.util.Set;
@NoArgsConstructor
public class RoleVo {
@Schema(description = "角色id")
@ApiModelProperty("角色id")
private Long roleId;
@Schema(description = "角色名称")
@ApiModelProperty("角色名称")
private String roleName;
@Schema(description = "角色权限字符串")
@ApiModelProperty("角色权限字符串")
private String roleKey;
@Schema(description = "角色排序")
@ApiModelProperty("角色排序")
private Integer roleSort;
/**
* 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限
*/
@Schema(description = "数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限")
@ApiModelProperty("数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限")
private String dataScope;
/**
* 角色状态1正常 0停用
*/
@Schema(description = "角色状态1正常 0停用")
@ApiModelProperty("角色状态1正常 0停用")
private String state;
/**
* 菜单组
*/
@Schema(description = "菜单组")
@ApiModelProperty("菜单组")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Set<Long> menuIds;
/**
* 部门组(数据权限)
*/
@Schema(description = "部门组(数据权限)")
@ApiModelProperty("部门组(数据权限)")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Long[] deptIds;
private LocalDateTime createTime;
private LocalDateTime updateTime;
private Date createTime;
private Date updateTime;
public static RoleVo toRoleVo(Role role){
return RoleVo.builder()

View File

@@ -1,9 +1,9 @@
package cn.fateverse.admin.vo;
import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
@@ -14,21 +14,20 @@ import java.util.List;
* @date 2022/11/4
*/
@Data
@Builder
@ApiModel("用户详细信息")
public class UserDetailVo {
@Schema(description = "用户基本细腻系")
private User user;
@ApiModelProperty("用户基本细腻系")
private UserDetail user;
@Schema(description = "用户所在的岗位")
@ApiModelProperty("用户所在的岗位")
private List<Long> postIds;
@Schema(description = "岗位option选择数组")
@ApiModelProperty("岗位option选择数组")
private List<Option> postList;
@Schema(description = "用户所拥有的的角色信息")
@ApiModelProperty("用户所拥有的的角色信息")
private List<Long> roleIds;
@Schema(description = "角色option选择数组")
@ApiModelProperty("角色option选择数组")
private List<Option> roleList;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@@ -18,13 +18,13 @@ public class UserVo implements Serializable {
/**
* 用户ID
*/
@Schema(description = "用户ID")
@ApiModelProperty("用户ID")
private Long userId;
/**
* 部门名称
*/
@Schema(description = "部门名称")
@ApiModelProperty("部门名称")
private String deptName;
private Long leaderDeptId;
@@ -34,7 +34,7 @@ public class UserVo implements Serializable {
/**
* 用户账号
*/
@Schema(description = "用户账号")
@ApiModelProperty("用户账号")
private String userName;
private String avatar;
@@ -48,25 +48,25 @@ public class UserVo implements Serializable {
/**
* 用户昵称
*/
@Schema(description = "用户昵称")
@ApiModelProperty("用户昵称")
private String nickName;
/**
* 手机号码
*/
@Schema(description = "手机号码")
@ApiModelProperty("手机号码")
private String phoneNumber;
/**
* 帐号状态1正常 0停用
*/
@Schema(description = "帐号状态1正常 0停用")
@ApiModelProperty("帐号状态1正常 0停用")
private String state;
/**
* 创建时间
*/
@Schema(description = "创建时间")
@ApiModelProperty("创建时间")
private Date createTime;
}

View File

@@ -1,8 +1,9 @@
package cn.fateverse.admin.controller;
import cn.fateverse.admin.dto.RoleDto;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.admin.entity.Role;
import cn.fateverse.admin.entity.User;
import cn.fateverse.admin.facade.RoleFacade;
import cn.fateverse.admin.query.RoleQuery;
import cn.fateverse.admin.vo.RoleVo;
import cn.fateverse.common.core.entity.IdWrapper;
@@ -23,6 +24,7 @@ import cn.fateverse.common.log.annotation.Log;
import cn.fateverse.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@@ -38,30 +40,21 @@ import java.util.Set;
@Api(tags = "角色管理")
@RestController
@RequestMapping("/role")
@RequiredArgsConstructor
public class RoleController {
private final RoleService roleService;
private final RoleFacade roleFacade;
private final UserService userService;
private final MenuService menuService;
private final TokenService tokenService;
public RoleController(RoleService roleService, UserService userService, MenuService menuService, TokenService tokenService) {
this.roleService = roleService;
this.userService = userService;
this.menuService = menuService;
this.tokenService = tokenService;
}
@ApiOperation("获取角色列表")
@GetMapping
@PreAuthorize("@ss.hasPermission('admin:role:list')")
public Result<TableDataInfo<RoleVo>> list(RoleQuery query) {
TableDataInfo<RoleVo> dataInfo = roleService.searchList(query);
TableDataInfo<RoleVo> dataInfo = roleFacade.searchList(query);
return Result.ok(dataInfo);
}
@@ -70,30 +63,30 @@ public class RoleController {
@GetMapping("/{roleId}")
@PreAuthorize("@ss.hasPermission('admin:role:info')")
public Result<RoleVo> info(@PathVariable Long roleId) {
checkRoleId(roleId);
RoleVo vo = roleService.searchById(roleId);
RoleVo vo = roleFacade.searchById(roleId);
return Result.ok(vo);
}
@ApiOperation("根据菜单id获取角色列表")
@GetMapping("/menu/list")
public Result<TableDataInfo<RoleVo>> roleExcludeMenuId(Long menuId, String roleName, String roleKey) {
if (ObjectUtils.isEmpty(menuId)) {
return Result.error("菜单id不能为空!");
}
TableDataInfo<RoleVo> dataInfo = roleService.searchListExcludeMenuId(menuId, roleName, roleKey);
public Result<TableDataInfo<RoleVo>> roleExcludeMenuId(@RequestParam Long menuId,
@RequestParam String roleName,
@RequestParam String roleKey) {
TableDataInfo<RoleVo> dataInfo = roleFacade.searchListExcludeMenuId(menuId, roleName, roleKey);
return Result.ok(dataInfo);
}
@ApiOperation("根据菜单id获取分配的角色信息")
@GetMapping("/menu")
public Result<TableDataInfo<RoleVo>> menuRole(Long menuId, String roleName, String roleKey) {
public Result<TableDataInfo<RoleVo>> menuRole(@RequestParam Long menuId,
@RequestParam String roleName,
@RequestParam String roleKey) {
if (ObjectUtils.isEmpty(menuId)) {
return Result.error("菜单id不能为空!");
}
TableDataInfo<RoleVo> dataInfo = roleService.searchListByMenuId(menuId, roleName, roleKey);
TableDataInfo<RoleVo> dataInfo = roleFacade.searchListByMenuId(menuId, roleName, roleKey);
return Result.ok(dataInfo);
}
@@ -105,7 +98,7 @@ public class RoleController {
public Result<Void> bindRole(@RequestBody IdWrapper wrapper) {
checkRoleIds(wrapper.getIds());
LongUtils.checkId(wrapper.getId(), "菜单id不能为空");
roleService.bindMenu(wrapper.getId(), wrapper.getIds());
roleFacade.bindMenu(wrapper.getId(), wrapper.getIds());
return Result.ok();
}
@@ -117,7 +110,7 @@ public class RoleController {
public Result<Void> unBindMenu(@RequestBody IdWrapper wrapper) {
checkRoleIds(wrapper.getIds());
LongUtils.checkId(wrapper.getId(), "菜单id不能为空");
roleService.unBindMenu(wrapper.getId(), wrapper.getIds());
roleFacade.unBindMenu(wrapper.getId(), wrapper.getIds());
return Result.ok();
}
@@ -127,7 +120,7 @@ public class RoleController {
@Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
public Result<Void> unBindAllMenu(@RequestBody IdWrapper wrapper) {
LongUtils.checkId(wrapper.getId(), "菜单id不能为空");
roleService.unBindAllMenu(wrapper.getId());
roleFacade.unBindAllMenu(wrapper.getId());
return Result.ok();
}
@@ -135,7 +128,7 @@ public class RoleController {
@ApiOperation("查询角色信息")
@GetMapping("/option")
public Result<List<Option>> option() {
List<Option> option = roleService.searchOption();
List<Option> option = roleFacade.searchOption();
return Result.ok(option);
}
@@ -146,7 +139,7 @@ public class RoleController {
@PreAuthorize("@ss.hasPermission('admin:role:add')")
public Result<Void> add(@RequestBody @Validated RoleDto role) {
checkNameAndKey(role);
roleService.save(role);
roleFacade.save(role);
return Result.ok();
}
@@ -157,7 +150,7 @@ public class RoleController {
public Result<Void> edit(@NotNull @RequestBody @Validated RoleDto role) {
checkRoleId(role.getRoleId());
checkNameAndKey(role);
roleService.edit(role);
roleFacade.edit(role);
checkUserRoleUpdate(role);
return Result.ok();
}
@@ -173,7 +166,7 @@ public class RoleController {
if (StrUtil.isEmpty(role.getState())) {
return Result.error("状态不能为空!");
}
roleService.editState(role.getRoleId(), role.getState());
roleFacade.editState(role.getRoleId(), role.getState());
checkUserRoleUpdate(role);
return Result.ok();
}
@@ -185,7 +178,7 @@ public class RoleController {
@PreAuthorize("@ss.hasPermission('admin:role:del')")
public Result<Void> delete(@PathVariable Long roleId) {
checkRoleId(roleId);
roleService.remove(roleId);
roleFacade.remove(roleId);
return Result.ok();
}
@@ -213,10 +206,10 @@ public class RoleController {
* 检查角色名称和角色关键词
*/
private void checkNameAndKey(RoleDto dto) {
if (roleService.checkNameUnique(dto)) {
if (roleFacade.checkNameUnique(dto)) {
throw new CustomException("角色名称已存在!");
}
if (roleService.checkRoleKeyUnique(dto)) {
if (roleFacade.checkRoleKeyUnique(dto)) {
throw new CustomException("角色权限名称已存在!");
}
}

View File

@@ -1,26 +1,27 @@
package cn.fateverse.admin.controller;
import cn.fateverse.admin.dto.UserDto;
import cn.fateverse.admin.facade.RoleFacade;
import cn.fateverse.admin.facade.UserFacade;
import cn.fateverse.admin.query.UserQuery;
import cn.fateverse.admin.service.PostService;
import cn.fateverse.admin.vo.UserChooseVo;
import cn.fateverse.admin.vo.UserDetailVo;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.IdWrapper;
import cn.hutool.core.util.StrUtil;
import cn.fateverse.admin.service.PostService;
import cn.fateverse.admin.service.RoleService;
import cn.fateverse.admin.service.UserService;
import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.core.result.Result;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.core.utils.LongUtils;
import cn.fateverse.common.security.annotation.Anonymity;
import cn.fateverse.common.log.annotation.Log;
import cn.fateverse.common.log.enums.BusinessType;
import cn.fateverse.common.mybatis.utils.PageUtils;
import cn.fateverse.common.security.annotation.Anonymity;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -37,31 +38,20 @@ import java.util.regex.Pattern;
@Api(tags = "用户管理")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class UserController {
private final UserService userService;
private final RoleService roleService;
private final UserFacade userFacade;
private final RoleFacade roleFacade;
private final PostService postService;
public UserController(UserService userService,
RoleService roleService,
PostService postService) {
this.userService = userService;
this.roleService = roleService;
this.postService = postService;
}
@ApiOperation("获取用户列表")
@GetMapping
@PreAuthorize("@ss.hasPermission('admin:user:list')")
public Result<TableDataInfo<UserVo>> list(UserQuery userQuery) {
PageUtils.startPage();
List<UserVo> userVos = userService.searchList(userQuery);
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userVos);
TableDataInfo<UserVo> dataTable = userFacade.searchList(userQuery);
return Result.ok(dataTable);
}
@@ -72,7 +62,7 @@ public class UserController {
if (null == type || null == chooseId || type > 1 || type < 0) {
return Result.error("参数异常!");
}
List<UserChooseVo> userChooseList = userService.searchUserChooseRoleOrDept(type, chooseId);
List<UserChooseVo> userChooseList = userFacade.searchUserChooseRoleOrDept(type, chooseId);
return Result.ok(userChooseList);
}
@@ -80,9 +70,8 @@ public class UserController {
@GetMapping("/info/{userId}")
@PreAuthorize("@ss.hasPermission('admin:user:info')")
public Result<UserDetailVo> info(@PathVariable Long userId) {
checkUserId(userId);
UserDetailVo userDetail = userService.searchByUserId(userId);
List<Option> roleOption = roleService.searchOption();
UserDetailVo userDetail = userFacade.searchDetailByUserId(userId);
List<Option> roleOption = roleFacade.searchOption();
List<Option> postOption = postService.searchOption();
userDetail.setRoleList(roleOption);
userDetail.setPostList(postOption);
@@ -94,7 +83,7 @@ public class UserController {
public Result<TableDataInfo<UserVo>> role(@PathVariable Long roleId, String userName, String phoneNumber) {
LongUtils.checkId(roleId, "角色id不能为空!");
PageUtils.startPage();
List<UserVo> userList = userService.searchListByRoleId(roleId, userName, phoneNumber);
List<UserVo> userList = userFacade.searchListByRoleId(roleId, userName, phoneNumber);
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userList);
return Result.ok(dataTable);
}
@@ -103,7 +92,7 @@ public class UserController {
@GetMapping("/role/exclude/{roleId}")
public Result<TableDataInfo<UserVo>> excludeRole(@PathVariable Long roleId, String userName, String phoneNumber) {
LongUtils.checkId(roleId, "角色id不能为空!");
TableDataInfo<UserVo> table = userService.searchUserListByExcludeRoleId(roleId, userName, phoneNumber);
TableDataInfo<UserVo> table = userFacade.searchUserListByExcludeRoleId(roleId, userName, phoneNumber);
return Result.ok(table);
}
@@ -114,7 +103,7 @@ public class UserController {
public Result<Void> bindRole(@RequestBody IdWrapper wrapper) {
checkUserId(wrapper.getIds());
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
userService.bindRole(wrapper.getIds(), wrapper.getId());
userFacade.bindRole(wrapper.getIds(), wrapper.getId());
return Result.ok();
}
@@ -125,7 +114,7 @@ public class UserController {
public Result<Void> unBindRole(@RequestBody IdWrapper wrapper) {
checkUserId(wrapper.getIds());
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
userService.unBindRole(wrapper.getIds(), wrapper.getId());
userFacade.unBindRole(wrapper.getIds(), wrapper.getId());
return Result.ok();
}
@@ -135,7 +124,7 @@ public class UserController {
@Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
public Result<Void> unBindAllRole(@RequestBody IdWrapper wrapper) {
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
userService.unBindAllRole(wrapper.getId());
userFacade.unBindAllRole(wrapper.getId());
return Result.ok();
}
@@ -144,7 +133,7 @@ public class UserController {
public Result<TableDataInfo<UserVo>> dept(@PathVariable Long deptId, String userName, String phoneNumber) {
LongUtils.checkId(deptId, "角色id不能为空!");
PageUtils.startPage();
List<UserVo> userList = userService.searchListByDeptId(deptId, userName, phoneNumber);
List<UserVo> userList = userFacade.searchListByDeptId(deptId, userName, phoneNumber);
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userList);
return Result.ok(dataTable);
}
@@ -153,7 +142,7 @@ public class UserController {
// @GetMapping("/dept/exclude/{deptId}")
public Result<TableDataInfo<UserVo>> excludeDept(@PathVariable Long deptId, String userName, String phoneNumber) {
LongUtils.checkId(deptId, "角色id不能为空!");
TableDataInfo<UserVo> table = userService.searchUserListByExcludeDeptId(deptId, userName, phoneNumber);
TableDataInfo<UserVo> table = userFacade.searchUserListByExcludeDeptId(deptId, userName, phoneNumber);
return Result.ok(table);
}
@@ -164,7 +153,7 @@ public class UserController {
public Result<Void> unBindDept(@PathVariable List<Long> userIds, @PathVariable Long deptId) {
checkUserId(userIds);
LongUtils.checkId(deptId, "角色id不能为空");
userService.unBindDept(userIds, deptId);
userFacade.unBindDept(userIds, deptId);
return Result.ok();
}
@@ -174,7 +163,7 @@ public class UserController {
// @Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
public Result<Void> unBindAllDept(@PathVariable Long deptId) {
LongUtils.checkId(deptId, "角色id不能为空");
userService.unBindAllDept(deptId);
userFacade.unBindAllDept(deptId);
return Result.ok();
}
@@ -185,7 +174,7 @@ public class UserController {
return Result.error("岗位id不能为空!");
}
PageUtils.startPage();
List<UserVo> userList = userService.searchListByPostId(postId, userName, phoneNumber);
List<UserVo> userList = userFacade.searchListByPostId(postId, userName, phoneNumber);
TableDataInfo<UserVo> dataTable = PageUtils.getDataTable(userList);
return Result.ok(dataTable);
}
@@ -195,7 +184,7 @@ public class UserController {
@GetMapping("/post/exclude/{postId}")
public Result<TableDataInfo<UserVo>> excludePost(@PathVariable Long postId, String userName, String phoneNumber) {
LongUtils.checkId(postId, "角色id不能为空!");
TableDataInfo<UserVo> table = userService.searchUserListByExcludePostId(postId, userName, phoneNumber);
TableDataInfo<UserVo> table = userFacade.searchUserListByExcludePostId(postId, userName, phoneNumber);
return Result.ok(table);
}
@@ -207,7 +196,7 @@ public class UserController {
public Result<Void> bindPost(@RequestBody IdWrapper wrapper) {
checkUserId(wrapper.getIds());
LongUtils.checkId(wrapper.getId(), "角色id不能为空");
userService.bindPost(wrapper.getIds(), wrapper.getId());
userFacade.bindPost(wrapper.getIds(), wrapper.getId());
return Result.ok();
}
@@ -218,7 +207,7 @@ public class UserController {
public Result<Void> unBindPost(@RequestBody IdWrapper wrapper) {
checkUserId(wrapper.getIds());
LongUtils.checkId(wrapper.getId(), "岗位id不能为空");
userService.unBindPost(wrapper.getIds(), wrapper.getId());
userFacade.unBindPost(wrapper.getIds(), wrapper.getId());
return Result.ok();
}
@@ -228,7 +217,7 @@ public class UserController {
@Log(title = "解除当前角色对应的所有用户的绑定关系", businessType = BusinessType.UPDATE)
public Result<Void> unBindAllPost(@RequestBody IdWrapper wrapper) {
LongUtils.checkId(wrapper.getId(), "岗位id不能为空");
userService.unBindAllPost(wrapper.getId());
userFacade.unBindAllPost(wrapper.getId());
return Result.ok();
}
@@ -241,7 +230,7 @@ public class UserController {
return Result.error("初始密码不能为空");
}
checkPhone(user.getPhoneNumber());
userService.save(user);
userFacade.save(user);
return Result.ok();
}
@@ -253,7 +242,7 @@ public class UserController {
public Result<Void> edit(@NotNull @RequestBody @Validated UserDto user) {
checkUserId(user.getUserId());
checkPhone(user.getPhoneNumber());
userService.edit(user);
userFacade.edit(user);
return Result.ok();
}
@@ -263,7 +252,7 @@ public class UserController {
@Log(title = "删除用户", businessType = BusinessType.DELETE)
public Result<Void> del(@PathVariable Long userId) {
checkUserId(userId);
userService.remove(userId);
userFacade.remove(userId);
return Result.ok();
}

View File

@@ -0,0 +1,14 @@
package cn.fateverse.admin.convert;
import cn.fateverse.admin.dto.RoleDto;
import cn.fateverse.admin.vo.RoleVo;
import cn.fateverse.common.core.convert.BaseConvertDefine;
import cn.fateverse.common.core.entity.Role;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface RoleConvert extends BaseConvertDefine<RoleDto, Role, RoleVo> {
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
}

View File

@@ -0,0 +1,22 @@
package cn.fateverse.admin.convert;
import cn.fateverse.admin.dto.UserDto;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.convert.BaseConvertDefine;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface UserConvert extends BaseConvertDefine<UserDto, User, UserVo> {
UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
/**
* 实体到细节
*
* @param user 用户
* @return {@link UserDetail }
*/
UserDetail entityToDetail(User user);
}

View File

@@ -1,6 +1,6 @@
package cn.fateverse.admin.dubbo;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.admin.entity.Role;
import cn.fateverse.admin.mapper.RoleMapper;
import cn.fateverse.admin.query.RoleQuery;
import org.apache.dubbo.config.annotation.DubboService;

View File

@@ -1,10 +1,10 @@
package cn.fateverse.admin.dubbo;
import cn.fateverse.admin.service.UserService;
import cn.fateverse.admin.facade.UserFacade;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserDetail;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.security.dubbo.DubboUserSearchService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
@@ -16,24 +16,21 @@ import java.util.List;
*/
@Slf4j
@DubboService
public class DubboUserServiceImpl implements DubboUserService, DubboUserSearchService {
@RequiredArgsConstructor
public class DubboUserServiceImpl implements DubboUserService {
private final UserService userService;
public DubboUserServiceImpl(UserService userService) {
this.userService = userService;
}
private final UserFacade userFacade;
@Override
public User getUserByUsername(String username) {
public UserVo getUserByUsername(String username) {
log.info("用户登录:{}", username);
return userService.searchByUserName(username);
return userFacade.searchByUserName(username);
}
@Override
public User getUserByUserId(Long userId) {
return userService.searchUserInfoByUserId(userId);
public UserVo getUserByUserId(Long userId) {
return userFacade.searchByUserId(userId);
}
@Override
@@ -41,7 +38,7 @@ public class DubboUserServiceImpl implements DubboUserService, DubboUserSearchSe
if (roleIds.isEmpty()) {
throw new CustomException("角色id不能为空");
}
return userService.searchListByRoleIds(roleIds);
return userFacade.searchListByRoleIds(roleIds);
}
@Override
@@ -49,7 +46,7 @@ public class DubboUserServiceImpl implements DubboUserService, DubboUserSearchSe
if (userIds.isEmpty()) {
throw new CustomException("用户id不能为空");
}
return userService.searchByUserIds(userIds);
return userFacade.searchByUserIds(userIds);
}
@Override
@@ -57,11 +54,16 @@ public class DubboUserServiceImpl implements DubboUserService, DubboUserSearchSe
if (deptIds.isEmpty()) {
throw new CustomException("部门id不能为空");
}
return userService.searchByDeptIds(deptIds);
return userFacade.searchByDeptIds(deptIds);
}
@Override
public List<Long> searchAllUserIds() {
return userService.searchAllUserIds();
return userFacade.searchAllUserIds();
}
@Override
public UserDetail getUserDetailsByUserName(String userName) {
return userFacade.getUserDetailsByUserName(userName);
}
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.entity.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import cn.fateverse.common.decrypt.annotation.EncryptField;
import lombok.Data;
@@ -19,7 +19,7 @@ public class MappingSwitchDto {
* key作为唯一编号
*/
@NotBlank(message = "唯一编号不能为空")
@Schema(description = "唯一编号不能为空")
@ApiModelProperty("唯一编号不能为空")
@EncryptField
private String key;
@@ -27,7 +27,7 @@ public class MappingSwitchDto {
* 当前方法的状态,true为正常放行,false为关闭
*/
@NotNull(message = "状态不能为空")
@Schema(description = "当前方法的状态,true为正常放行,false为关闭")
@ApiModelProperty("当前方法的状态,true为正常放行,false为关闭")
private Boolean state;
}

View File

@@ -3,7 +3,7 @@ package cn.fateverse.admin.entity.vo;
import cn.fateverse.common.decrypt.annotation.EncryptField;
import cn.fateverse.common.security.entity.MappingSwitchInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
@@ -24,66 +24,66 @@ public class MappingSwitchVo {
* key作为唯一编号
*/
@EncryptField
@Schema(description = "key作为唯一编号")
@ApiModelProperty("key作为唯一编号")
private String key;
/**
* 应用名称
*/
@Schema(description = "应用名称")
@ApiModelProperty("应用名称")
private String applicationName;
/**
* 类名
*/
@Schema(description = "类名")
@ApiModelProperty("类名")
private String className;
/**
* 方法名称
*/
@Schema(description = "方法名称")
@ApiModelProperty("方法名称")
private String methodName;
/**
* 描述MappingSwitch注解的value可以为空
*/
@Schema(description = "描述MappingSwitch注解的value可以为空")
@ApiModelProperty("描述MappingSwitch注解的value可以为空")
private String description;
/**
* HandlerMethod中的uri
*/
@Schema(description = "HandlerMethod中的uri")
@ApiModelProperty("HandlerMethod中的uri")
private Set<String> uris;
/**
* 当前开关类型
*/
@Schema(description = "当前开关类型")
@ApiModelProperty("当前开关类型")
private String type;
/**
* 当前方法请求类型
*/
@Schema(description = "当前方法请求类型")
@ApiModelProperty("当前方法请求类型")
private Set<String> httpMethods;
/**
* 当前方法的状态,true为正常放行,false为关闭
*/
@Schema(description = "当前方法的状态,true为正常放行,false为关闭")
@ApiModelProperty("当前方法的状态,true为正常放行,false为关闭")
private Boolean state;
/**
* 操作时间
*/
@Schema(description = "变更时间")
@ApiModelProperty("变更时间")
private Date operTime;
/**
* 操作人员
*/
@Schema(description = "操作人员")
@ApiModelProperty("操作人员")
private String operName;
public static MappingSwitchVo toMappingSwitchVo(MappingSwitchInfo mappingSwitchInfo) {

View File

@@ -0,0 +1,70 @@
package cn.fateverse.admin.facade;
import cn.fateverse.admin.convert.RoleConvert;
import cn.fateverse.admin.query.RoleQuery;
import cn.fateverse.admin.service.RoleService;
import cn.fateverse.admin.service.UserRoleService;
import cn.fateverse.admin.vo.RoleVo;
import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor
public class RoleFacade {
private final RoleService roleService;
private final UserRoleService userRoleService;
/**
* 搜索选项
*
* @return {@link List }<{@link Option }>
*/
public List<Option> searchOption() {
List<Role> list = roleService.list();
return null;
}
/**
* 搜索列表
*
* @param query 查询
* @return {@link TableDataInfo }<{@link RoleVo }>
*/
public TableDataInfo<RoleVo> searchList(RoleQuery query) {
IPage<Role> page = roleService.searchList(query);
return PageConditionUtil.convertDataTable(page, RoleConvert.INSTANCE::entityToVo);
}
/**
* 按id查询
*
* @param roleId 角色id
* @return {@link RoleVo }
*/
public RoleVo searchById(Long roleId) {
Role role = roleService.getById(roleId);
return RoleConvert.INSTANCE.entityToVo(role);
}
/**
* 搜索列表排除菜单id
*
* @param menuId 菜单id
* @param roleName 角色名
* @param roleKey 关键角色
* @return {@link TableDataInfo }<{@link RoleVo }>
*/
public TableDataInfo<RoleVo> searchListExcludeMenuId(Long menuId, String roleName, String roleKey) {
return null;
}
}

View File

@@ -0,0 +1,166 @@
package cn.fateverse.admin.facade;
import cn.fateverse.admin.convert.UserConvert;
import cn.fateverse.admin.query.UserQuery;
import cn.fateverse.admin.service.*;
import cn.fateverse.admin.vo.UserChooseVo;
import cn.fateverse.admin.vo.UserDetailVo;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.Dept;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserDetail;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class UserFacade {
private final UserService userService;
private final UserRoleService userRoleService;
private final UserPostService userPostService;
private final DeptService deptService;
private final RoleService roleService;
/**
* 按用户名搜索
*
* @param username 用户名
* @return {@link UserVo }
*/
public UserVo searchByUserName(String username) {
User user = userService.searchByUserName(username);
return UserConvert.INSTANCE.entityToVo(user);
}
/**
* 按用户id搜索
*
* @param userId 用户id
* @return {@link UserVo }
*/
public UserVo searchByUserId(Long userId) {
User user = userService.getById(userId);
return UserConvert.INSTANCE.entityToVo(user);
}
public UserDetail getUserDetailsByUserName(String username) {
User user = userService.searchByUserName(username);
return buildUserDetail(user);
}
/**
* 构建用户细节
*
* @param user 用户
* @return {@link UserDetail }
*/
private UserDetail buildUserDetail(User user) {
if (ObjectUtil.isNull(user)) {
return null;
}
UserDetail userDetail = UserConvert.INSTANCE.entityToDetail(user);
Dept dept = deptService.getById(user.getDeptId());
if (ObjectUtil.isNotNull(dept)) {
userDetail.setDept(dept);
}
List<Role> roleList = userRoleService.selectRoleByUserId(user.getUserId());
if (CollUtil.isNotEmpty(roleList)) {
userDetail.setRoles(roleList);
}
return userDetail;
}
/**
* 搜索列表
*
* @param userQuery 用户查询
* @return {@link List }<{@link UserVo }>
*/
public TableDataInfo<UserVo> searchList(UserQuery userQuery) {
IPage<UserVo> page = userService.searchList(userQuery);
return PageConditionUtil.convertDataTable(page);
}
/**
* 搜索用户选择角色或部门
*
* @param type 类型
* @param chooseId 选择id
* @return {@link List }<{@link UserChooseVo }>
*/
public List<UserChooseVo> searchUserChooseRoleOrDept(Integer type, Long chooseId) {
switch (type) {
// 0代表角色
case 0:
return chooseRole(chooseId);
// 1代表部门
case 1:
return chooseDept(chooseId);
default:
throw new CustomException("参数异常");
}
}
/**
* 选择角色
*
* @param roleId 角色id
* @return 选择成功的用户信息
*/
private List<UserChooseVo> chooseRole(Long roleId) {
if (roleId.equals(0L)) {
List<Role> roleList = roleService.list();
return roleList.stream().map(UserChooseVo::toUserChooseByRole).collect(Collectors.toList());
} else {
List<UserVo> userList = userService.selectUserListByRoleId(roleId, null, null);
return userList.stream().map(user ->
UserChooseVo.toUserChooseByUser(user, roleId)
).collect(Collectors.toList());
}
}
/**
* 选择部门
*
* @param deptId
* @return
*/
private List<UserChooseVo> chooseDept(Long deptId) {
List<Dept> deptList = deptService.selectListByDeptParentId(deptId);
List<UserChooseVo> result = deptList.stream().map(dept -> UserChooseVo.toUserChooseByDept(dept, deptId)).collect(Collectors.toList());
List<UserVo> userList = userService.selectByDeptIds(Collections.singletonList(deptId));
userList.forEach(user -> result.add(UserChooseVo.toUserChooseByUser(user, deptId)));
return result;
}
/**
* 按用户id搜索详细信息
*
* @param userId 用户id
* @return {@link UserDetailVo }
*/
public UserDetailVo searchDetailByUserId(Long userId) {
User user = userService.getById(userId);
UserDetail userDetail = buildUserDetail(user);
UserDetailVo detailVo = new UserDetailVo();
detailVo.setUser(userDetail);
return detailVo;
}
}

View File

@@ -1,7 +1,8 @@
package cn.fateverse.admin.mapper;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.admin.query.RoleQuery;
import cn.fateverse.common.core.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -10,7 +11,7 @@ import java.util.List;
* @author Clay
* @date 2022/11/4
*/
public interface RoleMapper {
public interface RoleMapper extends BaseMapper<Role> {
/**

View File

@@ -3,10 +3,9 @@ package cn.fateverse.admin.mapper;
import cn.fateverse.admin.query.UserQuery;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserBase;
import cn.fateverse.common.core.entity.UserDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -15,7 +14,7 @@ import java.util.List;
* @author Clay
* @date 2022/10/30
*/
public interface UserMapper extends BaseMapper<UserBase> {
public interface UserMapper extends BaseMapper<User> {
/**
* 通过用户名查询用户
@@ -35,10 +34,11 @@ public interface UserMapper extends BaseMapper<UserBase> {
/**
* 查询用户列表
*
* @param page 页面
* @param query 用户查询信息
* @return 用户信息
*/
List<UserVo> selectList(UserQuery query);
IPage<UserVo> selectPage(@Param("page") IPage<User> page, @Param("query") UserQuery query);
/**
* 排除角色id
@@ -46,7 +46,7 @@ public interface UserMapper extends BaseMapper<UserBase> {
* @param roleId 角色id
* @return 表格数据信息
*/
IPage<UserVo> selectUserListByExcludeRoleId(@Param("page") IPage<UserVo> page, @Param("roleId") Long roleId, @Param("userName") String userName, @Param("phoneNumber") String phoneNumber);
List<UserVo> selectUserListByExcludeRoleId(@Param("roleId") Long roleId, @Param("userName") String userName, @Param("phoneNumber") String phoneNumber);
/**
@@ -57,7 +57,7 @@ public interface UserMapper extends BaseMapper<UserBase> {
* @param phoneNumber 手机号码
* @return 用户列表
*/
IPage<UserVo> selectUserListByExcludePostId(@Param("page") IPage<UserVo> page, @Param("postId") Long postId, @Param("userName") String userName, @Param("phoneNumber") String phoneNumber);
List<UserVo> selectUserListByExcludePostId(@Param("postId") Long postId, @Param("userName") String userName, @Param("phoneNumber") String phoneNumber);
/**
@@ -91,7 +91,7 @@ public interface UserMapper extends BaseMapper<UserBase> {
* @param deptIds 部门id列表
* @return 用户信息
*/
List<UserVo> selectUserByDeptIds(List<Long> deptIds);
List<UserVo> selectByDeptIds(List<Long> deptIds);
/**
* 根据岗位id查询用户信息
@@ -107,7 +107,7 @@ public interface UserMapper extends BaseMapper<UserBase> {
* @param userId 用户id
* @return 用户信息
*/
User selectUserByUserId(Long userId);
UserDetail selectUserByUserId(Long userId);
/**
* 校验用户是否唯一
@@ -139,7 +139,7 @@ public interface UserMapper extends BaseMapper<UserBase> {
* @param user 用户信息
* @return 结果
*/
int insert(UserBase user);
int insert(User user);
/**
* 更新用户
@@ -147,7 +147,7 @@ public interface UserMapper extends BaseMapper<UserBase> {
* @param user 用户信息
* @return 结果
*/
int update(UserBase user);
int update(User user);
/**
* 删除用户

View File

@@ -1,6 +1,7 @@
package cn.fateverse.admin.mapper;
import cn.fateverse.admin.entity.UserPost;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -9,7 +10,7 @@ import java.util.List;
* @author Clay
* @date 2022/11/26
*/
public interface UserPostMapper {
public interface UserPostMapper extends BaseMapper<UserPost> {
/**
* 批量新增用户角色映射关系
*

View File

@@ -2,6 +2,8 @@ package cn.fateverse.admin.mapper;
import cn.fateverse.admin.entity.UserRole;
import cn.fateverse.common.core.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -10,7 +12,7 @@ import java.util.List;
* @author Clay
* @date 2022/11/6
*/
public interface UserRoleMapper {
public interface UserRoleMapper extends BaseMapper<UserRole> {
/**
* 批量新增用户角色映射关系
@@ -54,4 +56,11 @@ public interface UserRoleMapper {
*/
int bind(@Param("userIds") List<Long> userIds, @Param("roleId") Long roleId);
/**
* 根据用户id选择角色
*
* @param userId 用户id
* @return {@link List }<{@link Role }>
*/
List<Role> selectRoleByUserId(Long userId);
}

View File

@@ -59,4 +59,12 @@ public interface DeptService extends IService<Dept> {
*/
List<Dept> selectChildrenById(Long deptId);
/**
* 按部门父级id选择列表
*
* @param deptId 部门id
* @return {@link List }<{@link Dept }>
*/
List<Dept> selectListByDeptParentId(Long deptId);
}

View File

@@ -4,7 +4,10 @@ import cn.fateverse.admin.dto.RoleDto;
import cn.fateverse.admin.query.RoleQuery;
import cn.fateverse.admin.vo.RoleVo;
import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.result.page.TableDataInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@@ -12,7 +15,7 @@ import java.util.List;
* @author Clay
* @date 2022/11/4
*/
public interface RoleService {
public interface RoleService extends IService<Role> {
/**
* 查询角色列表
@@ -20,7 +23,7 @@ public interface RoleService {
* @param query
* @return
*/
TableDataInfo<RoleVo> searchList(RoleQuery query);
IPage<Role> searchList(RoleQuery query);
/**

View File

@@ -0,0 +1,8 @@
package cn.fateverse.admin.service;
import cn.fateverse.admin.entity.UserPost;
import com.baomidou.mybatisplus.extension.service.IService;
public interface UserPostService extends IService<UserPost> {
}

View File

@@ -0,0 +1,13 @@
package cn.fateverse.admin.service;
import cn.fateverse.admin.entity.UserRole;
import cn.fateverse.common.core.entity.Role;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface UserRoleService extends IService<UserRole> {
List<Role> selectRoleByUserId(Long userId);
}

View File

@@ -6,8 +6,9 @@ import cn.fateverse.admin.vo.UserChooseVo;
import cn.fateverse.admin.vo.UserDetailVo;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserBase;
import cn.fateverse.common.core.entity.UserDetail;
import cn.fateverse.common.core.result.page.TableDataInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@@ -16,7 +17,7 @@ import java.util.List;
* @author Clay
* @date 2022/10/30
*/
public interface UserService extends IService<UserBase> {
public interface UserService extends IService<User> {
/**
* 通过用户名查询用户信息
@@ -33,7 +34,7 @@ public interface UserService extends IService<UserBase> {
* @param userId 用户ID
* @return 用户对象
*/
User searchUserInfoByUserId(Long userId);
UserDetail searchUserInfoByUserId(Long userId);
/**
@@ -42,7 +43,7 @@ public interface UserService extends IService<UserBase> {
* @param user
* @return
*/
List<UserVo> searchList(UserQuery user);
IPage<UserVo> searchList(UserQuery user);
/**
* 根据角色或者是部门获取到用户信息
@@ -93,14 +94,14 @@ public interface UserService extends IService<UserBase> {
*
* @param user@return
*/
boolean checkUserNameUnique(UserDto user);
boolean checkUserNameUnique(User user);
/**
* 校验手机号是否唯一
*
* @param user@return
*/
boolean checkPhoneNumberUnique(UserDto user);
boolean checkPhoneNumberUnique(User user);
/**
* 校验邮箱是否唯一
@@ -273,4 +274,22 @@ public interface UserService extends IService<UserBase> {
* @return boolean
*/
boolean checkExistUser(Long deptId);
/**
* 根据角色id选择用户列表
*
* @param roleId
* @param userName 用户名
* @param phoneNumber 电话号码
* @return {@link List }<{@link UserVo }>
*/
List<UserVo> selectUserListByRoleId(Long roleId, String userName, String phoneNumber);
/**
* 按部门id选择
*
* @param deptIds 部门id
* @return {@link List }<{@link UserVo }>
*/
List<UserVo> selectByDeptIds(List<Long> deptIds);
}

View File

@@ -1,20 +1,20 @@
package cn.fateverse.admin.service.impl;
import cn.fateverse.admin.dto.ConfigDto;
import cn.fateverse.admin.query.ConfigQuery;
import cn.fateverse.admin.vo.ConfigVo;
import cn.fateverse.admin.entity.Config;
import cn.fateverse.admin.mapper.ConfigMapper;
import cn.fateverse.admin.query.ConfigQuery;
import cn.fateverse.admin.service.ConfigService;
import cn.fateverse.admin.vo.ConfigVo;
import cn.fateverse.common.core.entity.PageInfo;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.core.utils.ObjectUtils;
import cn.fateverse.common.core.utils.TableSupport;
import cn.fateverse.common.mybatis.utils.PageUtils;
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
import cn.fateverse.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -48,7 +48,7 @@ public class ConfigServiceImpl implements ConfigService {
PageUtils.startPage();
List<Config> list = configMapper.selectList(query);
log.info("query time :{}", (System.currentTimeMillis() - startTime));
return PageUtils.convertDataTable(list, ConfigVo::toConfigVo);
return PageConditionUtil.convertDataTable(list, ConfigVo::toConfigVo);
}

View File

@@ -2,6 +2,7 @@ package cn.fateverse.admin.service.impl;
import cn.fateverse.admin.mapper.DeptMapper;
import cn.fateverse.admin.service.DeptService;
import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.Dept;
import cn.fateverse.common.core.utils.AssertUtil;
import cn.fateverse.common.core.utils.LongUtils;
@@ -73,4 +74,12 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept>
.eq(Dept::getParentId, deptId)
.list();
}
@Override
public List<Dept> selectListByDeptParentId(Long deptId) {
return this.lambdaQuery()
.eq(Dept::getParentId, deptId)
.list();
}
}

View File

@@ -9,6 +9,7 @@ import cn.fateverse.admin.mapper.DictDataMapper;
import cn.fateverse.admin.service.DictCacheService;
import cn.fateverse.admin.service.DictDataService;
import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.mybatis.utils.PageUtils;
import lombok.extern.slf4j.Slf4j;

View File

@@ -1,7 +1,7 @@
package cn.fateverse.admin.service.impl;
import cn.fateverse.admin.dto.MenuDto;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.admin.entity.User;
import cn.fateverse.admin.vo.MenuSimpVo;
import cn.fateverse.admin.vo.MenuVo;
import cn.fateverse.admin.vo.OptionMenuVo;
@@ -67,7 +67,7 @@ public class MenuServiceImpl implements MenuService {
@Override
public List<RouterVo> searchRouterByUserId(Long userId) {
List<Menu> menuList = null;
if (User.isAdmin(userId)) {
if (SecurityUtils.isAdmin(userId)) {
menuList = menuMapper.selectRouterMenuList();
} else {
menuList = menuMapper.selectRouterMenuListByUserId(userId);
@@ -79,7 +79,7 @@ public class MenuServiceImpl implements MenuService {
public List<MenuSimpVo> searchTree(String menuName, String state) {
List<Menu> menuList = null;
Long userId = Objects.requireNonNull(SecurityUtils.getUserId());
if (User.isAdmin(userId)) {
if (SecurityUtils.isAdmin(userId)) {
menuList = menuMapper.selectList(menuName, state, null, false);
} else {
menuList = menuMapper.selectListByUserId(userId, menuName, state, null, false);
@@ -103,7 +103,7 @@ public class MenuServiceImpl implements MenuService {
public List<OptionTree> searchTreeOption(Long excludeId) {
Long userId = Objects.requireNonNull(SecurityUtils.getUserId());
List<Menu> menuList = null;
if (User.isAdmin(userId)) {
if (SecurityUtils.isAdmin(userId)) {
menuList = menuMapper.selectList(null, null, excludeId, true);
} else {
menuList = menuMapper.selectListByUserId(userId, null, null, excludeId, true);
@@ -123,7 +123,7 @@ public class MenuServiceImpl implements MenuService {
}
Long userId = Objects.requireNonNull(SecurityUtils.getUserId());
List<Menu> menuList = null;
if (User.isAdmin(userId)) {
if (SecurityUtils.isAdmin(userId)) {
menuList = menuMapper.selectList(null, null, null, true);
} else {
menuList = menuMapper.selectListByUserId(userId, null, null, null, true);

View File

@@ -1,25 +1,27 @@
package cn.fateverse.admin.service.impl;
import cn.fateverse.admin.dto.RoleDto;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.admin.query.RoleQuery;
import cn.fateverse.admin.vo.RoleVo;
import cn.fateverse.admin.entity.RoleMenu;
import cn.fateverse.admin.mapper.MenuMapper;
import cn.fateverse.admin.mapper.RoleMapper;
import cn.fateverse.admin.mapper.RoleMenuMapper;
import cn.fateverse.admin.query.RoleQuery;
import cn.fateverse.admin.service.RoleService;
import cn.fateverse.admin.vo.RoleVo;
import cn.fateverse.common.core.entity.Option;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.core.utils.LongUtils;
import cn.fateverse.common.core.utils.ObjectUtils;
import cn.fateverse.common.core.utils.StateUtils;
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
import cn.fateverse.common.security.utils.SecurityUtils;
import cn.fateverse.common.mybatis.utils.PageUtils;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -32,7 +34,8 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Service
public class RoleServiceImpl implements RoleService {
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role>
implements RoleService {
private final RoleMapper roleMapper;
@@ -47,25 +50,31 @@ public class RoleServiceImpl implements RoleService {
@Override
public TableDataInfo<RoleVo> searchList(RoleQuery query) {
PageUtils.startPage();
List<Role> list = roleMapper.selectList(query);
return PageUtils.convertDataTable(list, RoleVo::toRoleVo);
public IPage<Role> searchList(RoleQuery query) {
IPage<Role> page = PageConditionUtil.getPage();
return this.lambdaQuery()
.like(StrUtil.isNotBlank(query.getRoleName()), Role::getRoleName, query.getRoleName())
.like(StrUtil.isNotBlank(query.getRoleKey()), Role::getRoleKey, query.getRoleKey())
.eq(ObjectUtil.isNotNull(query.getState()), Role::getState, query.getState())
.between(ObjectUtil.isNotNull(query.getStartTime()) && ObjectUtil.isNotNull(query.getEndTime()),
Role::getCreateTime, query.getStartTime(), query.getEndTime())
.page(page);
return PageConditionUtil.convertDataTable(list, RoleVo::toRoleVo);
}
@Override
public TableDataInfo<RoleVo> searchListByMenuId(Long menuId, String roleName, String roleKey) {
PageUtils.startPage();
PageConditionUtil.startPage();
List<Role> list = roleMapper.selectListByMenuId(menuId, roleName, roleKey);
return PageUtils.convertDataTable(list, RoleVo::toRoleVo);
return PageConditionUtil.convertDataTable(list, RoleVo::toRoleVo);
}
@Override
public TableDataInfo<RoleVo> searchListExcludeMenuId(Long menuId, String roleName, String roleKey) {
PageUtils.startPage();
PageConditionUtil.startPage();
List<Role> list = roleMapper.searchListExcludeMenuId(menuId, roleName, roleKey);
return PageUtils.convertDataTable(list, RoleVo::toRoleVo);
return PageConditionUtil.convertDataTable(list, RoleVo::toRoleVo);
}
@Override
@@ -175,7 +184,7 @@ public class RoleServiceImpl implements RoleService {
}
public void checkRoleAllowed(Role role) {
if (!ObjectUtils.isEmpty(role.getRoleId()) && role.isAdmin()) {
if (!ObjectUtils.isEmpty(role.getRoleId()) && SecurityUtils.isAdmin(role.getRoleId())) {
throw new CustomException("不允许操作超级管理员角色");
}
}

View File

@@ -0,0 +1,14 @@
package cn.fateverse.admin.service.impl;
import cn.fateverse.admin.entity.UserPost;
import cn.fateverse.admin.mapper.UserPostMapper;
import cn.fateverse.admin.service.UserPostService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class UserPostServiceImpl extends ServiceImpl<UserPostMapper, UserPost>
implements UserPostService {
}

View File

@@ -0,0 +1,23 @@
package cn.fateverse.admin.service.impl;
import cn.fateverse.admin.entity.UserRole;
import cn.fateverse.admin.mapper.UserRoleMapper;
import cn.fateverse.admin.service.UserRoleService;
import cn.fateverse.common.core.entity.Role;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole>
implements UserRoleService {
@Override
public List<Role> selectRoleByUserId(Long userId) {
return baseMapper.selectRoleByUserId(userId);
}
}

View File

@@ -13,18 +13,16 @@ import cn.fateverse.admin.vo.UserVo;
import cn.fateverse.common.core.entity.Dept;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserBase;
import cn.fateverse.common.core.entity.UserDetail;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.core.utils.LongUtils;
import cn.fateverse.common.core.utils.ObjectUtils;
import cn.fateverse.common.mybatisplus.utils.PageUtils;
import cn.fateverse.common.mybatisplus.utils.PageConditionUtil;
import cn.fateverse.common.security.utils.SecurityUtils;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -41,30 +39,47 @@ import java.util.stream.Collectors;
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
implements UserService {
private final UserMapper userMapper;
private final UserRoleMapper userRoleMapper;
private final UserPostMapper userPostMapper;
private final RoleMapper roleMapper;
private final DeptMapper deptMapper;
@Override
public User searchByUserName(String username) {
return userMapper.selectByUserName(username);
public UserServiceImpl(UserMapper userMapper,
UserRoleMapper userRoleMapper,
UserPostMapper userPostMapper,
RoleMapper roleMapper, DeptMapper deptMapper) {
this.userMapper = userMapper;
this.userRoleMapper = userRoleMapper;
this.userPostMapper = userPostMapper;
this.roleMapper = roleMapper;
this.deptMapper = deptMapper;
}
@Override
public User searchUserInfoByUserId(Long userId) {
public User searchByUserName(String username) {
return this.lambdaQuery()
.eq(User::getUserName, username)
.last("limit 1")
.one();
}
@Override
public UserDetail searchUserInfoByUserId(Long userId) {
return userMapper.selectUserByUserId(userId);
}
@Override
public List<UserVo> searchList(UserQuery user) {
return userMapper.selectList(user);
public IPage<UserVo> searchList(UserQuery user) {
IPage<User> page = PageConditionUtil.getPage();
return userMapper.selectPage(page, user);
}
@Override
@@ -98,39 +113,45 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
@Override
public List<UserVo> searchByDeptIds(List<Long> deptIds) {
return userMapper.selectUserByDeptIds(deptIds);
return userMapper.selectByDeptIds(deptIds);
}
@Override
public UserDetailVo searchByUserId(Long userId) {
User user = userMapper.selectUserByUserId(userId);
List<Long> roleIds = user.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
user.setDept(null);
user.setRoles(null);
user.setPassword(null);
UserDetail userDetail = userMapper.selectUserByUserId(userId);
List<Long> roleIds = userDetail.getRoles().stream().map(Role::getRoleId).collect(Collectors.toList());
userDetail.setDept(null);
userDetail.setRoles(null);
userDetail.setPassword(null);
List<Long> postIds = userPostMapper.selectPostIdListByUserId(userId);
return UserDetailVo.builder()
.user(user)
.user(userDetail)
.postIds(postIds)
.roleIds(roleIds)
.build();
}
@Override
public boolean checkUserNameUnique(UserDto user) {
public boolean checkUserNameUnique(User user) {
Long userId = getUserId(user);
User info = userMapper.selectUserInfoByUserName(user.getUserName());
User info = this.lambdaQuery()
.eq(User::getUserName, user.getUserName())
.last("limit 1")
.one();
return checkUser(info, userId);
}
@Override
public boolean checkPhoneNumberUnique(UserDto user) {
public boolean checkPhoneNumberUnique(User user) {
if (StrUtil.isEmpty(user.getPhoneNumber())) {
return false;
}
Long userId = getUserId(user);
User info = userMapper.selectUserInfoByUserName(user.getPhoneNumber());
User info = this.lambdaQuery()
.eq(User::getPhoneNumber, user.getPhoneNumber())
.last("limit 1")
.one();
return checkUser(info, userId);
}
@@ -140,7 +161,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
return false;
}
Long userId = getUserId(user);
User info = userMapper.selectByEmail(user.getEmail());
UserDetail info = userMapper.selectByEmail(user.getEmail());
return checkUser(info, userId);
}
@@ -151,9 +172,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
@Override
public TableDataInfo<UserVo> searchUserListByExcludeRoleId(Long roleId, String userName, String phoneNumber) {
Page<UserVo> page = PageUtils.getPage();
IPage<UserVo> mapperPage = userMapper.selectUserListByExcludeRoleId(page, roleId, userName, phoneNumber);
return PageUtils.convertDataTable(mapperPage);
PageConditionUtil.startPage();
List<UserVo> list = userMapper.selectUserListByExcludeRoleId(roleId, userName, phoneNumber);
Long total = PageConditionUtil.getTotal(list);
return PageConditionUtil.convertDataTable(list, total);
}
@@ -187,9 +209,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
@Override
public TableDataInfo<UserVo> searchUserListByExcludePostId(Long postId, String userName, String phoneNumber) {
IPage<UserVo> page = PageUtils.getPage();
IPage<UserVo> mapperPage = userMapper.selectUserListByExcludePostId(page, postId, userName, phoneNumber);
return PageUtils.convertDataTable(mapperPage);
PageConditionUtil.startPage();
List<UserVo> list = userMapper.selectUserListByExcludePostId(postId, userName, phoneNumber);
Long total = PageConditionUtil.getTotal(list);
return PageConditionUtil.convertDataTable(list, total);
}
@@ -225,7 +248,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
private List<UserChooseVo> chooseDept(Long deptId) {
List<Dept> deptList = deptMapper.selectListByDeptParentId(deptId);
List<UserChooseVo> result = deptList.stream().map(dept -> UserChooseVo.toUserChooseByDept(dept, deptId)).collect(Collectors.toList());
List<UserVo> userList = userMapper.selectUserByDeptIds(Collections.singletonList(deptId));
List<UserVo> userList = userMapper.selectByDeptIds(Collections.singletonList(deptId));
userList.forEach(user -> result.add(UserChooseVo.toUserChooseByUser(user, deptId)));
return result;
}
@@ -255,16 +278,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
@Override
public TableDataInfo<UserVo> searchUserListByExcludeDeptId(Long deptId, String userName, String phoneNumber) {
// PageUtils.startPage();
// Dept dept = deptMapper.selectById(deptId);
// if (null == dept) {
// throw new CustomException("当前部门不存在");
// }
//// dept.getAncestors()
// List<UserVo> list = userMapper.searchUserListByExcludeDeptId(deptId, userName, phoneNumber);
// Long total = PageUtils.getTotal(list);
// return PageUtils.convertDataTable(list, total);
return PageUtils.emptyTable();
PageConditionUtil.startPage();
Dept dept = deptMapper.selectById(deptId);
if (null == dept) {
throw new CustomException("当前部门不存在");
}
// dept.getAncestors()
List<UserVo> list = userMapper.searchUserListByExcludeDeptId(deptId, userName, phoneNumber);
Long total = PageConditionUtil.getTotal(list);
return PageConditionUtil.convertDataTable(list, total);
}
@Override
@@ -282,7 +304,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
@Transactional(rollbackFor = Exception.class)
public int save(UserDto dto) {
checkUser(dto);
UserBase user = insertInitUser(dto);
User user = insertInitUser(dto);
int result = userMapper.insert(user);
dto.setUserId(user.getUserId());
batchUserRole(dto, Boolean.FALSE);
@@ -300,7 +322,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
batchUserRole(dto, Boolean.TRUE);
batchUserPost(dto, Boolean.TRUE);
dto.setPassword(null);
UserBase user = dto.toUser();
User user = dto.toUser();
return userMapper.update(user);
}
@@ -324,10 +346,21 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
@Override
public boolean checkExistUser(Long deptId) {
return this.lambdaQuery()
.eq(UserBase::getDeptId, deptId)
.eq(User::getDeptId, deptId)
.exists();
}
@Override
public List<UserVo> selectUserListByRoleId(Long roleId, String userName, String phoneNumber) {
return baseMapper.selectUserListByRoleId(roleId, userName, phoneNumber);
}
@Override
public List<UserVo> selectByDeptIds(List<Long> deptIds) {
return baseMapper.selectByDeptIds(deptIds);
}
/**
* 批量处理用户与角色之间的对应关系
*/
@@ -371,8 +404,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
*
* @param dto
*/
private UserBase insertInitUser(UserDto dto) {
UserBase user = dto.toUser();
private User insertInitUser(UserDto dto) {
User user = dto.toUser();
user.setPassword(SecurityUtils.encryptPassword(dto.getPassword()));
return user;
}
@@ -383,7 +416,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
* @param user
* @return
*/
private Long getUserId(UserDto user) {
private Long getUserId(User user) {
return LongUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
}
@@ -413,6 +446,4 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserBase>
}
}

View File

@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.fateverse.admin.mapper.UserMapper">
<resultMap type="cn.fateverse.common.core.entity.User" id="UserResult">
<resultMap type="cn.fateverse.common.core.entity.UserDetail" id="UserResult">
<id property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
<result property="userName" column="user_name"/>
@@ -135,21 +135,21 @@
where u.user_name = #{userName} limit 0,1
</select>
<select id="selectList" resultType="cn.fateverse.admin.vo.UserVo">
<select id="selectPage" resultType="cn.fateverse.admin.vo.UserVo">
<include refid="selectUserVo"/>
<where>
u.del_flag = '0'
<if test="userName != null and userName != ''">and u.user_name like concat('%', #{userName}, '%')</if>
<if test="phoneNumber != null and phoneNumber != ''">and u.phone_number like
concat('%',#{phoneNumber},'%')
<if test="query.userName != null and query.userName != ''">and u.user_name like concat('%', #{query.userName}, '%')</if>
<if test="query.phoneNumber != null and query.phoneNumber != ''">and u.phone_number like
concat('%',#{query.phoneNumber},'%')
</if>
<if test="state != null and state != ''">and u.state = #{state}</if>
<if test="startTime != null and endTime != null">
and u.create_time between #{startTime} and #{endTime}
<if test="query.state != null">and u.state = #{query.state}</if>
<if test="query.startTime != null and query.endTime != null">
and u.create_time between #{query.startTime} and #{query.endTime}
</if>
<if test="deptId != null">
and (u.dept_id = #{deptId} or u.dept_id in ( select t.dept_id from sys_dept t where
find_in_set(#{deptId}, ancestors) ))
<if test="query.deptId != null">
and (u.dept_id = #{query.deptId} or u.dept_id in ( select t.dept_id from sys_dept t where
find_in_set(#{query.deptId}, ancestors) ))
</if>
</where>
</select>
@@ -218,17 +218,17 @@
</where>
</select>
<select id="selectUserInfoByUserName" resultType="cn.fateverse.common.core.entity.User">
<select id="selectUserInfoByUserName" resultType="cn.fateverse.common.core.entity.UserDetail">
<include refid="selectUser"/>
where user_name = #{userName}
</select>
<select id="selectByPhoneNum" resultType="cn.fateverse.common.core.entity.User">
<select id="selectByPhoneNum" resultType="cn.fateverse.common.core.entity.UserDetail">
<include refid="selectUser"/>
where phone_number = #{phoneNumber}
</select>
<select id="selectByEmail" resultType="cn.fateverse.common.core.entity.User">
<select id="selectByEmail" resultType="cn.fateverse.common.core.entity.UserDetail">
<include refid="selectUser"/>
where email = #{email} limit 0,1
</select>
@@ -243,7 +243,7 @@
</foreach>
</select>
<select id="selectUserByDeptIds" resultType="cn.fateverse.admin.vo.UserVo">
<select id="selectByDeptIds" resultType="cn.fateverse.admin.vo.UserVo">
select distinct u.user_id,u.user_name,u.nick_name,u.phone_number,u.state,u.create_time,
d.dept_name,u.user_type,u.sex,u.avatar,d.dept_id as leaderDeptId
from sys_user u
@@ -260,7 +260,7 @@
</select>
<insert id="insert" parameterType="cn.fateverse.common.core.entity.UserBase" useGeneratedKeys="true" keyProperty="userId"
<insert id="insert" parameterType="cn.fateverse.common.core.entity.User" useGeneratedKeys="true" keyProperty="userId"
keyColumn="user_id">
insert into sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@@ -32,4 +32,22 @@
#{userId}
</foreach>
</delete>
<select id="selectRoleByUserId" resultType="cn.fateverse.common.core.entity.Role">
select r.role_id,
r.role_name,
r.role_key,
r.role_sort,
r.data_scope,
r.`state`,
r.del_flag,
r.create_by,
r.create_time,
r.update_by,
r.update_time,
r.remark,
r.role_type
from sys_role r
left join sys_user_role ur on r.role_id = ur.role_id
where ur.user_id = #{userId}
</select>
</mapper>

View File

@@ -125,9 +125,9 @@ logging.resolver=${SW_LOGGING_RESOLVER:PATTERN}
# * %level means log level.
# * %timestamp means now of time with format yyyy-MM-dd HH:mm:ss:SSS.
# * %thread means name of current thread.
# * %msg means some message which user logged.
# * %msg means some message which userDetail logged.
# * %class means SimpleName of TargetClass.
# * %throwable means a throwable which user called.
# * %throwable means a throwable which userDetail called.
# * %agent_name means agent.service_name. Only apply to the PatternLogger.
logging.pattern=${SW_LOGGING_PATTERN:%level %timestamp %thread %class : %msg %throwable}
# Logging max_file_size, default: 300 * 1024 * 1024 = 314572800
@@ -155,7 +155,7 @@ jvm.buffer_size=${SW_JVM_BUFFER_SIZE:600}
buffer.channel_size=${SW_BUFFER_CHANNEL_SIZE:5}
# The buffer size.
buffer.buffer_size=${SW_BUFFER_BUFFER_SIZE:300}
# If true, skywalking agent will enable profile when user create a new profile task. Otherwise disable profile.
# If true, skywalking agent will enable profile when userDetail create a new profile task. Otherwise disable profile.
profile.active=${SW_AGENT_PROFILE_ACTIVE:true}
# Parallel monitor segment count
profile.max_parallel=${SW_AGENT_PROFILE_MAX_PARALLEL:5}

View File

@@ -54,7 +54,6 @@
<groupId>cn.fateverse</groupId>
<artifactId>admin-api</artifactId>
</dependency>
</dependencies>

View File

@@ -1,7 +1,7 @@
package cn.fateverse.auth.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@@ -16,26 +16,26 @@ public class LoginBody {
/**
* 用户名
*/
@Schema(description = "用户名")
@ApiModelProperty("用户名")
@NotBlank(message = "用户名不能为空")
private String username;
/**
* 用户密码
*/
@Schema(description = "用户密码")
@ApiModelProperty("用户密码")
@NotBlank(message = "密码不能为空")
private String password;
/**
* 验证码uuid
*/
@Schema(description = "验证码uuid")
@ApiModelProperty("验证码uuid")
@NotBlank(message = "验证码uuid")
private String uuid;
/**
* 验证码
*/
@Schema(description = "验证码")
@ApiModelProperty("验证码")
@NotBlank(message = "验证码不能为空")
private String code;

View File

@@ -1,6 +1,6 @@
package cn.fateverse.auth.entity;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.admin.entity.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

View File

@@ -1,35 +1,34 @@
package cn.fateverse.auth.service;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.admin.dubbo.DubboUserService;
import cn.fateverse.common.core.entity.LoginUser;
import cn.fateverse.common.core.entity.UserDetail;
import cn.fateverse.common.core.enums.UserState;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.core.utils.ObjectUtils;
import cn.fateverse.common.core.entity.LoginUser;
import cn.fateverse.common.security.dubbo.DubboUserSearchService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
/**
* @author Clay
* @date 2022/10/27
*/
@Slf4j
@Component
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
@DubboReference
private DubboUserSearchService userService;
private DubboUserService userService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//todo 编辑用户登录相关逻辑
log.info("有用户登录:{}", username);
User user = userService.getUserByUsername(username);
UserDetail user = userService.getUserDetailsByUserName(username);
if (ObjectUtils.isEmpty(user)) {
log.info("登录用户:{} 不存在.", username);
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");

View File

@@ -1,26 +1,26 @@
package cn.fateverse.auth.service.impl;
import cn.fateverse.auth.entity.UserInfo;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.entity.User;
import cn.hutool.core.date.DateUtil;
import cn.fateverse.admin.dubbo.DubboMenuService;
import cn.fateverse.admin.dubbo.DubboUserService;
import cn.fateverse.admin.vo.RouterVo;
import cn.fateverse.auth.entity.LoginBody;
import cn.fateverse.auth.entity.UserInfo;
import cn.fateverse.auth.event.LoginInfoEvent;
import cn.fateverse.auth.service.LoginService;
import cn.fateverse.auth.utils.LoginInfoUtil;
import cn.fateverse.common.core.constant.CacheConstants;
import cn.fateverse.common.core.constant.DateConstants;
import cn.fateverse.common.core.entity.LoginUser;
import cn.fateverse.common.core.entity.Role;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.exception.CustomException;
import cn.fateverse.common.core.exception.UserPasswordNotMatchException;
import cn.fateverse.common.core.utils.SpringContextHolder;
import cn.fateverse.common.core.utils.uuid.IdUtils;
import cn.fateverse.common.core.entity.LoginUser;
import cn.fateverse.common.security.service.TokenService;
import cn.fateverse.common.security.utils.SecurityUtils;
import cn.fateverse.auth.event.LoginInfoEvent;
import cn.fateverse.auth.utils.LoginInfoUtil;
import cn.fateverse.log.entity.LoginInfo;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.redisson.api.RLock;

View File

@@ -2,7 +2,8 @@ package cn.fateverse.auth.service.impl;
import cn.fateverse.admin.dubbo.DubboMenuService;
import cn.fateverse.common.core.entity.LoginUser;
import cn.fateverse.common.core.entity.User;
import cn.fateverse.common.core.entity.UserDetail;
import cn.fateverse.common.security.utils.SecurityUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
@@ -27,9 +28,9 @@ public class PermissionService {
* @param loginUser 登录用户
*/
public void getMenuPermission(LoginUser loginUser) {
User user = loginUser.getUser();
UserDetail user = loginUser.getUser();
Set<String> perms = new HashSet<>();
if (user.isAdmin()) {
if (SecurityUtils.isAdmin(user.getUserId())) {
perms.add("*:*:*");
} else {
Set<String> menuSet = menuService.selectMenuPermsByUserId(user.getUserId());

View File

@@ -1,7 +1,7 @@
package cn.fateverse.code.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -15,41 +15,41 @@ public class ApiClass {
/**
* 类id
*/
@Schema(description = "类id")
@ApiModelProperty("类id")
private String classId;
/**
* 模块id
*/
@Schema(description = "模块id")
@ApiModelProperty("模块id")
private String moduleId;
/**
* 类名
*/
@Schema(description = "类名")
@ApiModelProperty("类名")
private String className;
/**
* 类描述
*/
@Schema(description = "类描述")
@ApiModelProperty("类描述")
private String classDescribe;
/**
* 包名
*/
@Schema(description = "包名")
@ApiModelProperty("包名")
private String packageName;
/**
* 作者
*/
@Schema(description = "作者")
@ApiModelProperty("作者")
private String author;
/**
* 电子邮件
*/
@Schema(description = "电子邮件")
@ApiModelProperty("电子邮件")
private String email;
/**
* 前缀
*/
@Schema(description = "前缀")
@ApiModelProperty("前缀")
private String prefix;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.code.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -15,52 +15,52 @@ public class InterTable {
/**
* id
*/
@Schema(description = "id")
@ApiModelProperty("id")
private String interId;
/**
* 模块id
*/
@Schema(description = "模块id")
@ApiModelProperty("模块id")
private String moduleId;
/**
* 类id
*/
@Schema(description = "类id")
@ApiModelProperty("类id")
private String classId;
/**
* 接口名称
*/
@Schema(description = "接口名称")
@ApiModelProperty("接口名称")
private String itName;
/**
* 描述
*/
@Schema(description = "描述")
@ApiModelProperty("描述")
private String itDescribe;
/**
* 是否设置许可
*/
@Schema(description = "是否设置许可")
@ApiModelProperty("是否设置许可")
private String isPermission;
/**
* 请求路径
*/
@Schema(description = "请求路径")
@ApiModelProperty("请求路径")
private String reqUrl;
/**
* 请求方式
*/
@Schema(description = "请求方式")
@ApiModelProperty("请求方式")
private String method;
/**
* 是否生成
*/
@Schema(description = "是否生成")
@ApiModelProperty("是否生成")
private String isGenerate;
/**
* 类型(1,工作台,2流程)
*/
@Schema(description = "类型(1,工作台,2流程)")
@ApiModelProperty("类型(1,工作台,2流程)")
private String type;

View File

@@ -2,7 +2,7 @@ package cn.fateverse.code.entity;
import cn.fateverse.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -17,16 +17,16 @@ public class Module extends BaseEntity {
/**
* 模块id
*/
@Schema(description = "模块id")
@ApiModelProperty("模块id")
private Long modeId;
/**
* 模块名称
*/
@Schema(description = "模块名称")
@ApiModelProperty("模块名称")
private String modeName;
/**
* 模块描述
*/
@Schema(description = "模块描述")
@ApiModelProperty("模块描述")
private String modeDescribe;
}

View File

@@ -2,7 +2,7 @@ package cn.fateverse.code.entity;
import cn.fateverse.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -16,66 +16,66 @@ public class RelTable extends BaseEntity {
/**
* 关联表id
*/
@Schema(description = "关联表id")
@ApiModelProperty("关联表id")
private Long relTableId;
/**
* 主表id
*/
@Schema(description = "主表id")
@ApiModelProperty("主表id")
private Long tableId;
/**
* 关联子表表名
*/
@Schema(description = "关联子表表名")
@ApiModelProperty("关联子表表名")
private String relName;
/**
* 子表简称
*/
@Schema(description = "子表简称")
@ApiModelProperty("子表简称")
private String relAs;
/**
* 父表名称
*/
@Schema(description = "父表名称")
@ApiModelProperty("父表名称")
private String tableName;
/**
* 父表名简称
*/
@Schema(description = "父表名简称")
@ApiModelProperty("父表名简称")
private String tableAs;
/**
* 表描述
*/
@Schema(description = "表描述")
@ApiModelProperty("表描述")
private String relComment;
/**
* 关联子表的字段
*/
@Schema(description = "关联子表的字段")
@ApiModelProperty("关联子表的字段")
private String relColumn;
/**
* 关联父表字段
*/
@Schema(description = "关联父表字段")
@ApiModelProperty("关联父表字段")
private String tableColumn;
/**
* 实体类名称(子表)
*/
@Schema(description = "实体类名称(子表)")
@ApiModelProperty("实体类名称(子表)")
private String relClass;
/**
* 实体类名称(子表)小写
*/
@Schema(description = "实体类名称(子表)小写")
@ApiModelProperty("实体类名称(子表)小写")
private String relClassLower;
/**
* 关联类型
*/
@Schema(description = "关联类型")
@ApiModelProperty("关联类型")
private String queryType;
/**
* 排序
*/
@Schema(description = "排序")
@ApiModelProperty("排序")
private String sort;
}

View File

@@ -2,7 +2,7 @@ package cn.fateverse.code.entity;
import cn.fateverse.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
@@ -16,67 +16,67 @@ public class RelTableColumn extends BaseEntity {
/**
* 子表字段id
*/
@Schema(description = "子表字段id")
@ApiModelProperty("子表字段id")
private Long relColumnId;
/**
* 归属表编号
*/
@Schema(description = "归属表编号")
@ApiModelProperty("归属表编号")
private Long relTableId;
/**
* 列名称
*/
@Schema(description = "列名称")
@ApiModelProperty("列名称")
private String columnName;
/**
* 列描述
*/
@Schema(description = "列描述")
@ApiModelProperty("列描述")
private String columnComment;
/**
* 列类型
*/
@Schema(description = "列类型")
@ApiModelProperty("列类型")
private String columnType;
/**
* JAVA类型
*/
@Schema(description = "JAVA类型")
@ApiModelProperty("JAVA类型")
private String javaType;
/**
* JAVA字段名
*/
@Schema(description = "JAVA字段名")
@ApiModelProperty("JAVA字段名")
private String javaField;
/**
* 是否列表字段1是
*/
@Schema(description = "是否列表字段1是")
@ApiModelProperty("是否列表字段1是")
private String isList;
/**
* 是否查询字段1是
*/
@Schema(description = "是否查询字段1是")
@ApiModelProperty("是否查询字段1是")
private String isQuery;
/**
* 查询方式(等于、不等于、大于、小于、范围)
*/
@Schema(description = "查询方式(等于、不等于、大于、小于、范围)")
@ApiModelProperty("查询方式(等于、不等于、大于、小于、范围)")
private String queryType;
/**
* 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
*/
@Schema(description = "显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)")
@ApiModelProperty("显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)")
private String htmlType;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
private String dictType;
/**
* 排序
*/
@Schema(description = "排序")
@ApiModelProperty("排序")
private String sort;
}

View File

@@ -6,7 +6,7 @@ import cn.fateverse.code.enums.DynamicSourceEnum;
import cn.fateverse.code.enums.FrontTemplateEnum;
import cn.fateverse.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -26,101 +26,101 @@ public class Table extends BaseEntity {
/**
* 编号
*/
@Schema(description = "编号")
@ApiModelProperty("编号")
private Long tableId;
private Long parentMenuId;
/**
* 数据源id
*/
@Schema(description = "数据源id")
@ApiModelProperty("数据源id")
private Long dataSourceId;
@Schema(description = "数据源类型")
@ApiModelProperty("数据源类型")
private DynamicSourceEnum dataSourceType;
/**
* 表名称
*/
@Schema(description = "表名称")
@ApiModelProperty("表名称")
private String tableName;
/**
* 表描述
*/
@Schema(description = "表描述")
@ApiModelProperty("表描述")
private String tableComment;
/**
* 关联子表的表名
*/
@Schema(description = "关联子表的表名")
@ApiModelProperty("关联子表的表名")
private String subTableName;
/**
* 子表关联的外键名
*/
@Schema(description = "子表关联的外键名")
@ApiModelProperty("子表关联的外键名")
private String subTableFkName;
/**
* 实体类名称
*/
@Schema(description = "实体类名称")
@ApiModelProperty("实体类名称")
private String className;
/**
* 使用的模板crud单表操作 tree树表操作
*/
@Schema(description = "使用的模板")
@ApiModelProperty("使用的模板")
private String tplCategory;
/**
* 生成包路径
*/
@Schema(description = "生成包路径")
@ApiModelProperty("生成包路径")
private String packageName;
/**
* 生成模块名
*/
@Schema(description = "生成模块名")
@ApiModelProperty("生成模块名")
private String moduleName;
/**
* 生成服务名
*/
@Schema(description = "生成服务名")
@ApiModelProperty("生成服务名")
private String serviceName;
/**
* 生成业务名
*/
@Schema(description = "生成业务名")
@ApiModelProperty("生成业务名")
private String businessName;
/**
* 生成功能名
*/
@Schema(description = "生成功能名")
@ApiModelProperty("生成功能名")
private String functionName;
/**
* 生成功能作者
*/
@Schema(description = "生成功能作者")
@ApiModelProperty("生成功能作者")
private String functionAuthor;
@Schema(description = "后端模板 0: mybatis 1: mybatispuls ")
@ApiModelProperty("后端模板 0: mybatis 1: mybatispuls ")
private BackTemplateEnum backTemplate;
@Schema(description = "前端模板 0: vue 1: react")
@ApiModelProperty("前端模板 0: vue 1: react")
private FrontTemplateEnum frontTemplate;
/**
* 其它生成选项
*/
@Schema(description = "其它生成选项")
@ApiModelProperty("其它生成选项")
private String options;

View File

@@ -5,7 +5,7 @@ import cn.fateverse.common.core.annotaion.EnableAutoField;
import cn.fateverse.common.core.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.ObjectUtils;
@@ -22,108 +22,108 @@ public class TableColumn extends BaseEntity {
/**
* 编号
*/
@Schema(description = "编号")
@ApiModelProperty("编号")
private Long columnId;
/**
* 归属表编号
*/
@Schema(description = "归属表编号")
@ApiModelProperty("归属表编号")
private Long tableId;
/**
* 列名称
*/
@Schema(description = "列名称")
@ApiModelProperty("列名称")
private String columnName;
/**
* 列描述
*/
@Schema(description = "列描述")
@ApiModelProperty("列描述")
private String columnComment;
/**
* 列类型
*/
@Schema(description = "列类型")
@ApiModelProperty("列类型")
private String columnType;
@Schema(description = "列长度")
@ApiModelProperty("列长度")
private Integer columnLength;
@Schema(description = "列精度")
@ApiModelProperty("列精度")
private Integer columnScale;
/**
* JAVA类型
*/
@Schema(description = "JAVA类型")
@ApiModelProperty("JAVA类型")
private String javaType;
/**
* JAVA字段名
*/
@Schema(description = "JAVA字段名")
@ApiModelProperty("JAVA字段名")
private String javaField;
/**
* 是否主键1是
*/
@Schema(description = "是否主键1是")
@ApiModelProperty("是否主键1是")
private String isPk;
/**
* 是否自增1是
*/
@Schema(description = "是否自增1是")
@ApiModelProperty("是否自增1是")
private String isIncrement;
/**
* 是否必填1是
*/
@Schema(description = "是否必填1是")
@ApiModelProperty("是否必填1是")
private String isRequired;
/**
* 是否为插入字段1是
*/
@Schema(description = "是否为插入字段1是")
@ApiModelProperty("是否为插入字段1是")
private String isInsert;
/**
* 是否编辑字段1是
*/
@Schema(description = "是否编辑字段1是")
@ApiModelProperty("是否编辑字段1是")
private String isEdit;
/**
* 是否列表字段1是
*/
@Schema(description = "是否列表字段1是")
@ApiModelProperty("是否列表字段1是")
private String isList;
/**
* 是否查询字段1是
*/
@Schema(description = "是否查询字段1是")
@ApiModelProperty("是否查询字段1是")
private String isQuery;
/**
* 是否正则(1 否)
*/
@Schema(description = "是否正则(1 否)")
@ApiModelProperty("是否正则(1 否)")
private Long isRegular;
/**
* 正则表达式内容
*/
@Schema(description = "正则表达式内容")
@ApiModelProperty("正则表达式内容")
private String regular;
/**
* 查询方式(等于、不等于、大于、小于、范围)
*/
@Schema(description = "查询方式(等于、不等于、大于、小于、范围)")
@ApiModelProperty("查询方式(等于、不等于、大于、小于、范围)")
private String queryType;
/**
* 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
*/
@Schema(description = "显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)")
@ApiModelProperty("显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)")
private String htmlType;
/**
* 字典类型
*/
@Schema(description = "字典类型")
@ApiModelProperty("字典类型")
private String dictType;
/**
* 排序
*/
@Schema(description = "排序")
@ApiModelProperty("排序")
private String sort;
/**

View File

@@ -3,7 +3,7 @@ package cn.fateverse.code.entity.dto;
import cn.fateverse.code.entity.CodeDataSource;
import cn.fateverse.code.enums.DynamicSourceEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -29,64 +29,64 @@ public class DataSourceDto {
/**
* 数据源id
*/
@Schema(description = "数据源id")
@ApiModelProperty("数据源id")
private Long dsId;
/**
* 数据源名称
*/
@Schema(description = "数据源名称")
@ApiModelProperty("数据源名称")
@NotBlank(message = "数据源名称不能为空")
private String dsName;
/**
* 数据源用户名
*/
@Schema(description = "数据源用户名")
@ApiModelProperty("数据源用户名")
@NotBlank(message = "数据源用户名")
private String username;
/**
* 数据源密码
*/
@Schema(description = "数据源密码")
@ApiModelProperty("数据源密码")
private String password;
/**
* 数据源主机
*/
@Schema(description = "数据源主机")
@ApiModelProperty("数据源主机")
private String host;
/**
* 数据源主机端口
*/
@Schema(description = "数据源主机端口")
@ApiModelProperty("数据源主机端口")
private Integer port;
/**
* 数据源类型
*/
@Schema(description = "数据源类型")
@ApiModelProperty("数据源类型")
@NotNull(message = "数据源类型不能为空")
private DynamicSourceEnum type;
/**
* 数据库名称
*/
@Schema(description = "数据库名称")
@ApiModelProperty("数据库名称")
private String dbName;
/**
* 数据库连接地址
*/
@Schema(description = "数据库连接地址")
@ApiModelProperty("数据库连接地址")
private String jdbcUrl;
/**
* 数据源类型 (1:主机 2:jdbc连接url)
*/
@Schema(description = "数据源类型 (1:主机 2:jdbc连接url)")
@ApiModelProperty("数据源类型 (1:主机 2:jdbc连接url)")
@Max(value = 2, message = "参数不合法")
@Min(value = 1, message = "参数不合法")
private Integer confType;

View File

@@ -2,7 +2,7 @@ package cn.fateverse.code.entity.dto;
import cn.fateverse.code.entity.Regular;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@@ -21,34 +21,34 @@ public class RegularDto {
/**
* id
*/
@Schema(description = "id")
@ApiModelProperty("id")
private Long id;
/**
* 正则名称
*/
@Schema(description = "正则名称")
@ApiModelProperty("正则名称")
@NotBlank(message = "正则名称不能为空!")
private String name;
/**
* 正则内容
*/
@Schema(description = "正则内容")
@ApiModelProperty("正则内容")
@NotBlank(message = "正则内容不能为空!")
private String regular;
/**
* 验证内容
*/
@Schema(description = "验证内容")
@ApiModelProperty("验证内容")
@NotBlank(message = "验证内容不能为空!")
private String validation;
/**
* 是否启用 1:启动 2:关闭
*/
@Schema(description = "是否启用 1:启动 0:关闭")
@ApiModelProperty("是否启用 1:启动 0:关闭")
@NotNull(message = "是否启用不能为空!")
private String enable;

View File

@@ -1,6 +1,6 @@
package cn.fateverse.code.entity.query;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -13,7 +13,7 @@ public class DataSourceQuery {
/**
* 数据源名称
*/
@Schema(description = "数据源名称")
@ApiModelProperty("数据源名称")
private String dsName;
}

View File

@@ -1,7 +1,7 @@
package cn.fateverse.code.entity.query;
import cn.fateverse.common.core.entity.QueryTime;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -23,13 +23,13 @@ public class DynamicTable extends QueryTime {
/**
* 表名称
*/
@Schema(description = "表名称")
@ApiModelProperty("表名称")
private String tableName;
/**
* 表注释
*/
@Schema(description = "表注释")
@ApiModelProperty("表注释")
private String tableComment;
private Date createTime;

View File

@@ -1,7 +1,7 @@
package cn.fateverse.code.entity.query;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -21,18 +21,18 @@ public class RegularQuery {
/**
* 正则名称
*/
@Schema(description = "正则名称")
@ApiModelProperty("正则名称")
private String name;
/**
* 正则内容
*/
@Schema(description = "正则内容")
@ApiModelProperty("正则内容")
private String regular;
/**
* 是否启用 1:启动 2:关闭
*/
@Schema(description = "是否启用 1:启动 0:关闭")
@ApiModelProperty("是否启用 1:启动 0:关闭")
private Integer enable;
}

View File

@@ -2,7 +2,7 @@ package cn.fateverse.code.entity.query;
import cn.fateverse.common.core.entity.QueryTime;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -22,21 +22,21 @@ public class TableQuery extends QueryTime {
/**
* 数据源id
*/
@Schema(description = "数据源id")
@ApiModelProperty("数据源id")
private Long dataSourceId;
/**
* 表名称
*/
@Schema(description = "表名称")
@ApiModelProperty("表名称")
private String tableName;
/**
* 表描述
*/
@Schema(description = "表描述")
@ApiModelProperty("表描述")
private String tableComment;
@Schema(description = "数据类型")
@ApiModelProperty("数据类型")
private String dataSourceType;
}

View File

@@ -3,7 +3,7 @@ package cn.fateverse.code.entity.vo;
import cn.fateverse.code.entity.CodeDataSource;
import cn.fateverse.common.core.annotaion.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -28,68 +28,68 @@ public class DataSourceVo implements Serializable {
/**
* 数据源id
*/
@Schema(description = "数据源id")
@ApiModelProperty("数据源id")
private Long dsId;
/**
* 数据源名称
*/
@Schema(description = "数据源名称")
@ApiModelProperty("数据源名称")
@Excel("数据源名称")
private String dsName;
/**
* 数据源用户名
*/
@Schema(description = "数据源用户名")
@ApiModelProperty("数据源用户名")
@Excel("数据源用户名")
private String username;
/**
* 数据源密码
*/
@Schema(description = "数据源密码")
@ApiModelProperty("数据源密码")
@Excel("数据源密码")
private String password;
/**
* 数据源主机
*/
@Schema(description = "数据源主机")
@ApiModelProperty("数据源主机")
@Excel("数据源主机")
private String host;
/**
* 数据源主机端口
*/
@Schema(description = "数据源主机端口")
@ApiModelProperty("数据源主机端口")
@Excel("数据源主机端口")
private Integer port;
/**
* 数据源类型
*/
@Schema(description = "数据源类型")
@ApiModelProperty("数据源类型")
@Excel("数据源类型")
private String dsType;
/**
* 数据库名称
*/
@Schema(description = "数据库名称")
@ApiModelProperty("数据库名称")
@Excel("数据库名称")
private String dbName;
/**
* 数据库连接地址
*/
@Schema(description = "数据库连接地址")
@ApiModelProperty("数据库连接地址")
@Excel("数据库连接地址")
private String jdbcUrl;
/**
* 数据源类型 (1:主机 2:jdbc连接url)
*/
@Schema(description = "数据源类型 (1:主机 2:jdbc连接url)")
@ApiModelProperty("数据源类型 (1:主机 2:jdbc连接url)")
@Max(value = 2, message = "参数不合法")
@Min(value = 1, message = "参数不合法")
@Excel("数据源类型")

View File

@@ -3,7 +3,7 @@ package cn.fateverse.code.entity.vo;
import cn.fateverse.code.entity.Regular;
import cn.fateverse.common.core.annotaion.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -27,33 +27,33 @@ public class RegularVo {
/**
* id
*/
@Schema(description = "id")
@ApiModelProperty("id")
private Long id;
/**
* 正则名称
*/
@Schema(description = "正则名称")
@ApiModelProperty("正则名称")
@Excel("正则名称")
private String name;
/**
* 正则内容
*/
@Schema(description = "正则内容")
@ApiModelProperty("正则内容")
@Excel("正则内容")
private String regular;
/**
* 验证内容
*/
@Schema(description = "验证内容")
@ApiModelProperty("验证内容")
private String validation;
/**
* 是否启用 1:启动 2:关闭
*/
@Schema(description = "是否启用 1:启动 2:关闭")
@ApiModelProperty("是否启用 1:启动 2:关闭")
@Excel(value = "是否启用",dictType = "regular_enable")
private String enable;

View File

@@ -2,7 +2,7 @@ package cn.fateverse.code.entity.vo;
import cn.fateverse.common.core.annotaion.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -24,34 +24,34 @@ public class TableVo {
/**
* 编号
*/
@Schema(description = "编号")
@ApiModelProperty("编号")
@Excel("编号")
private Long tableId;
/**
* 数据源id
*/
@Schema(description = "数据源id")
@ApiModelProperty("数据源id")
@Excel("数据源id")
private Long dataSourceId;
/**
* 表名称
*/
@Schema(description = "表名称")
@ApiModelProperty("表名称")
@Excel("表名称")
private String tableName;
/**
* 表描述
*/
@Schema(description = "表描述")
@ApiModelProperty("表描述")
@Excel("表描述")
private String tableComment;
/**
* 实体类名称
*/
@Schema(description = "实体类名称")
@ApiModelProperty("实体类名称")
@Excel("实体类名称")
private String className;

View File

@@ -2,7 +2,7 @@ package ${packageName}.entity.dto;
import ${packageName}.entity.${ClassName};
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
#if($table.isRequired())
import javax.validation.constraints.NotNull;
@@ -28,7 +28,7 @@ public class ${ClassName}Dto {
/**
* ${pkColumn.columnComment}
*/
@Schema(description = "${pkColumn.columnComment}")
@ApiModelProperty("${pkColumn.columnComment}")
private $pkColumn.javaType $pkColumn.javaField;
#foreach ($column in $columns)
#if($column.from())
@@ -42,7 +42,7 @@ public class ${ClassName}Dto {
#if($column.isRegular())
@Pattern(regexp = "${column.regular}",message = "${column.columnComment}格式错误!")
#end
@Schema(description = "${column.columnComment}")
@ApiModelProperty("${column.columnComment}")
private $column.javaType $column.javaField;
#end
#end

View File

@@ -1,7 +1,7 @@
package ${packageName}.entity.query;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -29,7 +29,7 @@ public class ${ClassName}Query {
/**
* $column.columnComment
*/
@Schema(description = "${column.columnComment}")
@ApiModelProperty("${column.columnComment}")
#if($column.javaType.equals("Date"))
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#end
@@ -39,7 +39,7 @@ public class ${ClassName}Query {
/**
* $column.columnComment 开始
*/
@Schema(description = "${column.columnComment}开始")
@ApiModelProperty("${column.columnComment}开始")
#if($column.javaType.equals("Date"))
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#end
@@ -48,7 +48,7 @@ public class ${ClassName}Query {
/**
* $column.columnComment 结束
*/
@Schema(description = "${column.columnComment}结束")
@ApiModelProperty("${column.columnComment}结束")
#if($column.javaType.equals("Date"))
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#end

View File

@@ -3,7 +3,7 @@ package ${packageName}.entity.vo;
import ${packageName}.entity.${ClassName};
import cn.fateverse.common.core.annotaion.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -29,7 +29,7 @@ public class ${ClassName}Vo {
/**
* ${pkColumn.columnComment}
*/
@Schema(description = "${pkColumn.columnComment}")
@ApiModelProperty("${pkColumn.columnComment}")
private $pkColumn.javaType $pkColumn.javaField;
#foreach ($column in $columns)
#if($column.list())
@@ -37,7 +37,7 @@ public class ${ClassName}Vo {
/**
* $column.columnComment
*/
@Schema(description = "${column.columnComment}")
@ApiModelProperty("${column.columnComment}")
@Excel("${column.columnComment}")
private $column.javaType $column.javaField;
#end

View File

@@ -60,6 +60,12 @@
<artifactId>spring-security-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>${mybatis-plus.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>

View File

@@ -1,6 +1,9 @@
package cn.fateverse.common.core.entity;
import cn.fateverse.common.core.annotaion.EnableAutoField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -16,14 +19,16 @@ import javax.validation.constraints.Pattern;
* @date 2022/10/30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dept")
@EnableAutoField
@EqualsAndHashCode(callSuper = true)
public class Dept extends BaseEntity {
/**
* 部门ID
*/
@TableId(type = IdType.AUTO)
private Long deptId;
/**
@@ -83,5 +88,4 @@ public class Dept extends BaseEntity {
private String delFlag;
}

View File

@@ -5,7 +5,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.*;
import java.util.stream.Collectors;
@@ -16,7 +15,7 @@ import java.util.stream.Collectors;
*/
@Data
@NoArgsConstructor
public class LoginUser implements UserDetails {
public class LoginUser implements org.springframework.security.core.userdetails.UserDetails {
/**
* 用户唯一标识
@@ -36,7 +35,7 @@ public class LoginUser implements UserDetails {
/**
* 用户信息
*/
private User user;
private UserDetail user;
/**
* 登录ip

View File

@@ -1,28 +1,27 @@
package cn.fateverse.common.core.entity;
import cn.fateverse.common.core.annotaion.EnableAutoField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.*;
/**
*
* @author Clay
* @date 2022/10/30
*/
@Data
@Builder
@EnableAutoField
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_role")
@EqualsAndHashCode(callSuper = true)
public class Role extends BaseEntity {
/**
* 角色ID
*/
@TableId(type = IdType.AUTO)
private Long roleId;
/**

View File

@@ -1,38 +1,111 @@
package cn.fateverse.common.core.entity;
import cn.fateverse.common.core.annotaion.EnableAutoField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import java.util.List;
import java.util.Date;
/**
* @author Clay
* @date 2022/10/27
* @date 2022/11/7
*/
@Data
@EnableAutoField
@TableName("sys_user")
@EqualsAndHashCode(callSuper = true)
public class User extends UserBase {
public class User extends BaseEntity {
/**
* 部门对象
* 用户ID
*/
private Dept dept;
@TableId(type = IdType.AUTO)
private Long userId;
/**
* 角色对象
* 部门ID
*/
private List<Role> roles;
private Long deptId;
/**
* 用户账号
*/
private String userName;
/**
* 用户昵称
*/
private String nickName;
/**
* 用户邮箱
*/
private String email;
/**
* 手机号码
*/
private String phoneNumber;
/**
* 用户性别
*/
private String sex;
/**
* 用户头像
*/
private String avatar;
/**
* 密码
*/
private String password;
/**
* 盐加密
*/
@JsonIgnore
public boolean isAdmin() {
return isAdmin(super.getUserId());
}
private String salt;
/**
* 帐号状态1正常 0停用
*/
private String state;
/**
* 删除标志0代表存在 2代表删除
*/
@JsonIgnore
public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId;
}
private String delFlag;
/**
* 用户类型
*/
private String userType;
/**
* 一个微信开放平台帐号下的应用,同一用户的 union
*/
private String unionId;
/**
* 用户唯一标识
*/
private String openId;
/**
* 城市
*/
private String city;
/**
* 最后登录IP
*/
private String loginIp;
/**
* 最后登录时间
*/
private Date loginDate;
}

View File

@@ -1,109 +0,0 @@
package cn.fateverse.common.core.entity;
import cn.fateverse.common.core.annotaion.EnableAutoField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import java.util.Date;
/**
* @author Clay
* @date 2022/11/7
*/
@Data
@Builder
@EnableAutoField
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class UserBase extends BaseEntity {
/**
* 用户ID
*/
private Long userId;
/**
* 部门ID
*/
private Long deptId;
/**
* 用户账号
*/
private String userName;
/**
* 用户昵称
*/
private String nickName;
/**
* 用户邮箱
*/
private String email;
/**
* 手机号码
*/
private String phoneNumber;
/**
* 用户性别
*/
private String sex;
/**
* 用户头像
*/
private String avatar;
/**
* 密码
*/
private String password;
/**
* 盐加密
*/
@JsonIgnore
private String salt;
/**
* 帐号状态1正常 0停用
*/
private String state;
/**
* 删除标志0代表存在 2代表删除
*/
@JsonIgnore
private String delFlag;
/**
* 用户类型
*/
private String userType;
/**
* 一个微信开放平台帐号下的应用,同一用户的 union
*/
private String unionId;
/**
* 用户唯一标识
*/
private String openId;
/**
* 城市
*/
private String city;
/**
* 最后登录IP
*/
private String loginIp;
/**
* 最后登录时间
*/
private Date loginDate;
}

View File

@@ -0,0 +1,38 @@
package cn.fateverse.common.core.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* @author Clay
* @date 2022/10/27
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class UserDetail extends User {
/**
* 部门对象
*/
private Dept dept;
/**
* 角色对象
*/
private List<Role> roles;
@JsonIgnore
public boolean isAdmin() {
return isAdmin(super.getUserId());
}
@JsonIgnore
public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId;
}
}

View File

@@ -12,6 +12,7 @@
<artifactId>common-dubbo</artifactId>
<properties>
<dubbo.version>3.1.0</dubbo.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
@@ -47,6 +48,7 @@
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
<exclusions>
<exclusion>
<groupId>com.alibaba.fastjson2</groupId>

View File

@@ -12,7 +12,6 @@
<artifactId>common-mybatis-puls</artifactId>
<properties>
<mybatis-plus.version>3.5.3.1</mybatis-plus.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -48,10 +47,6 @@
<groupId>cn.fateverse</groupId>
<artifactId>common-core</artifactId>
</dependency>
<dependency>
<groupId>cn.fateverse</groupId>
<artifactId>common-security</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -4,7 +4,6 @@ import cn.fateverse.common.core.annotaion.EnableAutoField;
import cn.fateverse.common.core.entity.BaseEntity;
import cn.fateverse.common.core.enums.MethodEnum;
import cn.fateverse.common.core.utils.AutoSetValueUtils;
import cn.fateverse.common.security.utils.SecurityUtils;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

View File

@@ -3,6 +3,7 @@ package cn.fateverse.common.mybatisplus.utils;
import cn.fateverse.common.core.entity.PageInfo;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.core.utils.TableSupport;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
@@ -26,11 +27,21 @@ public class PageConditionUtil {
* @param <R> 需要转换的对象类型
* @return 转换后的对象
*/
public static <T, R> TableDataInfo<T> convertDataTable(Page<R> page, Function<R, T> map) {
public static <T, R> TableDataInfo<T> convertDataTable(IPage<R> page, Function<R, T> map) {
List<T> convertList = page.getRecords().stream().map(map).collect(Collectors.toList());
return convertDataTable(convertList, page.getTotal());
}
/**
* 转换为TableDataInfo对象
*
* @param page 源对象
* @return 转换后的对象
*/
public static <T> TableDataInfo<T> convertDataTable(IPage<T> page) {
return convertDataTable(page.getRecords(), page.getTotal());
}
/**
* 转换为TableDataInfo对象
@@ -50,7 +61,7 @@ public class PageConditionUtil {
return tableDataInfo;
}
public static <T> Page<T> getPage(){
public static <T> IPage<T> getPage() {
PageInfo pageInfo = TableSupport.getPageInfo();
return new Page<>(pageInfo.getPageNum(), pageInfo.getPageSize());
}

View File

@@ -1,68 +0,0 @@
package cn.fateverse.common.mybatisplus.utils;
import cn.fateverse.common.core.entity.PageInfo;
import cn.fateverse.common.core.result.page.TableDataInfo;
import cn.fateverse.common.core.utils.TableSupport;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author Clay
* @date 2023-05-25
*/
public class PageUtils {
/**
* 转换为TableDataInfo对象
*
* @param page 源对象
* @param map 转换方法
* @param <T> 转换后的对象类型
* @param <R> 需要转换的对象类型
* @return 转换后的对象
*/
public static <T, R> TableDataInfo<T> convertDataTable(IPage<R> page, Function<R, T> map) {
List<T> convertList = page.getRecords().stream().map(map).collect(Collectors.toList());
return convertDataTable(convertList, page.getTotal());
}
public static <T> TableDataInfo<T> convertDataTable(IPage<T> page) {
return convertDataTable(page.getRecords(), page.getTotal());
}
public static <T> TableDataInfo<T> emptyTable() {
return convertDataTable(new ArrayList<>(), 0L);
}
/**
* 转换为TableDataInfo对象
*
* @param list
* @param count
* @param <T>
* @return
*/
public static <T> TableDataInfo<T> convertDataTable(List<T> list, Long count) {
if (null == list) {
return new TableDataInfo<>(new ArrayList<>(), 0);
}
TableDataInfo<T> tableDataInfo = new TableDataInfo<>();
tableDataInfo.setRows(list);
tableDataInfo.setTotal(count);
return tableDataInfo;
}
public static <T> Page<T> getPage() {
PageInfo pageInfo = TableSupport.getPageInfo();
return new Page<>(pageInfo.getPageNum(), pageInfo.getPageSize());
}
}

View File

@@ -1,13 +0,0 @@
package cn.fateverse.common.security.dubbo;
import cn.fateverse.common.core.entity.User;
public interface DubboUserSearchService {
/**
* 通过用户名查询用户信息
*
* @param username 用户名称
* @return 用户信息
*/
User getUserByUsername(String username);
}

Some files were not shown because too many files have changed in this diff Show More