mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
5.0
This commit is contained in:
@@ -2,7 +2,7 @@ package com.gitee.sop.adminbackend.service;
|
||||
|
||||
import com.gitee.sop.adminbackend.BaseTest;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysAdminUser;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysAdminUserService;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysUserService;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
@@ -16,7 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
public class PasswordTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
SysAdminUserService sysAdminUserService;
|
||||
SysUserService sysAdminUserService;
|
||||
|
||||
/**
|
||||
* 重置admin密码
|
||||
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class IdsDTO {
|
||||
private List<Long> ids;
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.gitee.sop.adminbackend.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class StatusUpdateBatchDTO extends IdsDTO {
|
||||
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.gitee.sop.adminbackend.common.jackson.convert.annotation;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.gitee.sop.adminbackend.common.jackson.convert.serde.BoolDeserializer;
|
||||
import com.gitee.sop.adminbackend.common.jackson.convert.serde.BoolSerializer;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 序列化自动转换成boolean值,反序列化转换成数字
|
||||
* @author 六如
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@JacksonAnnotationsInside
|
||||
@JsonSerialize(using = BoolSerializer.class)
|
||||
@JsonDeserialize(using = BoolDeserializer.class)
|
||||
public @interface Bool {
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package com.gitee.sop.adminbackend.common.jackson.convert.serde;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* {@literal
|
||||
* 将布尔值类型转换成数字
|
||||
*
|
||||
* @IntBool
|
||||
* private Integer isLoading;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Slf4j
|
||||
public class BoolDeserializer extends StdDeserializer<Object> {
|
||||
private static final long serialVersionUID = -4993230470571124275L;
|
||||
|
||||
private static final String TRUE = "true";
|
||||
|
||||
|
||||
public BoolDeserializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
protected BoolDeserializer(final Class<?> vc) {
|
||||
super(vc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
|
||||
String text = p.getText();
|
||||
return Objects.equals(TRUE, text) ? 1 : 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.gitee.sop.adminbackend.common.jackson.convert.serde;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* {@literal
|
||||
* 将数字类型转换成布尔
|
||||
*
|
||||
* @Bool
|
||||
* private Integer isLoading; // 返回给前端: "isLoading": true/false
|
||||
*
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Slf4j
|
||||
public class BoolSerializer extends JsonSerializer<Object> {
|
||||
|
||||
private static final String TRUE_VALUE = "1";
|
||||
|
||||
@Override
|
||||
public void serialize(Object value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
|
||||
if (value == null) {
|
||||
jsonGenerator.writeNull();
|
||||
return;
|
||||
}
|
||||
jsonGenerator.writeBoolean(Objects.equals(TRUE_VALUE, String.valueOf(value)));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package com.gitee.sop.adminbackend.common.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class IdsParam {
|
||||
@NotEmpty(message = "id不能为空")
|
||||
private List<Long> ids;
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.gitee.sop.adminbackend.common.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class StatusUpdateBatchParam extends IdsParam {
|
||||
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -1,12 +1,14 @@
|
||||
package com.gitee.sop.adminbackend.common.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class StatusUpdateParam extends IdParam {
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.gitee.sop.adminbackend.common.util;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
@@ -337,6 +338,21 @@ public class CopyUtil extends BeanUtils {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static <R, T> PageInfo<R> copyPageInfo(PageInfo<T> srcPageInfo, Function<List<T>, List<R>> function) {
|
||||
PageInfo<R> pageInfo = new PageInfo<>();
|
||||
List<T> list = srcPageInfo.getList();
|
||||
if (list != null && !list.isEmpty()) {
|
||||
pageInfo.setList(function.apply(list));
|
||||
} else {
|
||||
pageInfo.setList(new ArrayList<>(0));
|
||||
}
|
||||
pageInfo.setPageCount(srcPageInfo.getPageCount());
|
||||
pageInfo.setPageIndex(srcPageInfo.getPageIndex());
|
||||
pageInfo.setPageSize(srcPageInfo.getPageSize());
|
||||
pageInfo.setTotal(srcPageInfo.getTotal());
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
public interface CopyConsumer<F, T> {
|
||||
void apply(F from, T to);
|
||||
}
|
||||
|
@@ -0,0 +1,73 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_dept
|
||||
* 备注:部门表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "sys_dept", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class SysDept {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,159 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_resource
|
||||
* 备注:菜单资源表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "sys_resource", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class SysResource {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 菜单类型(0代表菜单、1代表iframe、2代表外链、3代表按钮)
|
||||
*/
|
||||
private Integer menuType;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 路由名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer rank;
|
||||
|
||||
/**
|
||||
* 路由重定向
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 路由重定向
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 右侧图标
|
||||
*/
|
||||
private String extraIcon;
|
||||
|
||||
/**
|
||||
* 进场动画(页面加载动画)
|
||||
*/
|
||||
private String enterTransition;
|
||||
|
||||
/**
|
||||
* 离场动画(页面加载动画)
|
||||
*/
|
||||
private String leaveTransition;
|
||||
|
||||
/**
|
||||
* 菜单激活
|
||||
*/
|
||||
private String activePath;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
private String auths;
|
||||
|
||||
/**
|
||||
* 链接地址(需要内嵌的`iframe`链接地址)
|
||||
*/
|
||||
private String frameSrc;
|
||||
|
||||
/**
|
||||
* 加载动画(内嵌的`iframe`页面是否开启首次加载动画)
|
||||
*/
|
||||
private Integer frameLoading;
|
||||
|
||||
/**
|
||||
* 缓存页面
|
||||
*/
|
||||
private Integer keepAlive;
|
||||
|
||||
/**
|
||||
* 标签页(当前菜单名称或自定义信息禁止添加到标签页)
|
||||
*/
|
||||
private Integer hiddenTag;
|
||||
|
||||
/**
|
||||
* 固定标签页(当前菜单名称是否固定显示在标签页且不可关闭)
|
||||
*/
|
||||
private Integer fixedTag;
|
||||
|
||||
/**
|
||||
* 菜单(是否显示该菜单)
|
||||
*/
|
||||
private Integer showLink;
|
||||
|
||||
/**
|
||||
* 父级菜单(是否显示父级菜单
|
||||
*/
|
||||
private Integer showParent;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@com.gitee.fastmybatis.annotation.Column(logicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_role_resource
|
||||
* 备注:角色资源关联表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "sys_role_resource", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class SysRoleResource {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* sys_role.id
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* sys_resource.id
|
||||
*/
|
||||
private Long resourceId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_user
|
||||
* 备注:系统用户表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "sys_user", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class SysUser {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别,0-未知,1-男,2-女
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 注册类型,1-系统,2-手动
|
||||
*/
|
||||
private String regType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_user_dept
|
||||
* 备注:用户部门关联表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "sys_user_dept", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class SysUserDept {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* sys_user.id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* sys_dept.id
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.gitee.sop.adminbackend.dao.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.fastmybatis.annotation.Pk;
|
||||
import com.gitee.fastmybatis.annotation.PkStrategy;
|
||||
import com.gitee.fastmybatis.annotation.Table;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_user_role
|
||||
* 备注:用户角色关联表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Table(name = "sys_user_role", pk = @Pk(name = "id", strategy = PkStrategy.INCREMENT))
|
||||
@Data
|
||||
public class SysUserRole {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* sys_role.id
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* sys_user.id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysDept;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysResource;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysResourceMapper extends BaseMapper<SysResource> {
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysRoleResource;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleResourceMapper extends BaseMapper<SysRoleResource> {
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUserDept;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserDeptMapper extends BaseMapper<SysUserDept> {
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.gitee.sop.adminbackend.dao.mapper;
|
||||
|
||||
import com.gitee.fastmybatis.core.mapper.BaseMapper;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUserRole;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
|
||||
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.common.enums.ConfigKeyEnum;
|
||||
import com.gitee.sop.adminbackend.common.config.Configs;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysAdminUser;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysAdminUserMapper;
|
||||
import com.gitee.sop.adminbackend.common.util.GenerateUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysAdminUserService implements LambdaService<SysAdminUser, SysAdminUserMapper> {
|
||||
|
||||
|
||||
public SysAdminUser getByUsername(String username) {
|
||||
return this.get(SysAdminUser::getUsername, username);
|
||||
}
|
||||
|
||||
public String getDbPassword(String username, String password) {
|
||||
return getDbPassword(username, password, getPasswordSalt());
|
||||
}
|
||||
|
||||
public String getDbPassword(String username) {
|
||||
return this.query().eq(SysAdminUser::getUsername, username).getValue(SysAdminUser::getPassword);
|
||||
}
|
||||
|
||||
public String getDbPassword(String username, String password, String salt) {
|
||||
return GenerateUtil.getUserPassword(username, password, salt);
|
||||
}
|
||||
|
||||
private String getPasswordSalt() {
|
||||
return Configs.getValue(ConfigKeyEnum.PASSWORD_SALT);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.fastmybatis.core.util.TreeUtil;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.common.exception.BizException;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysDept;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysDeptMapper;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysDeptDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysDeptService implements LambdaService<SysDept, SysDeptMapper> {
|
||||
|
||||
public Long addDept(SysDept sysDept) {
|
||||
long count = this.query()
|
||||
.eq(SysDept::getParentId, 0)
|
||||
.getCount();
|
||||
if (count > 0 && Objects.equals(sysDept.getParentId(), 0L)) {
|
||||
throw new BizException("只能有一个根节点");
|
||||
}
|
||||
this.save(sysDept);
|
||||
return sysDept.getId();
|
||||
}
|
||||
|
||||
public List<SysDeptDTO> listTree(LambdaQuery<SysDept> query) {
|
||||
List<SysDept> list = this.list(query);
|
||||
List<SysDeptDTO> sysDeptList = CopyUtil.copyList(list, SysDeptDTO::new);
|
||||
return TreeUtil.convertTree(sysDeptList, 0L);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*
|
||||
* @param statusUpdateDTO 修改值
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
public int updateStatus(StatusUpdateDTO statusUpdateDTO) {
|
||||
return this.query()
|
||||
.eq(SysDept::getId, statusUpdateDTO.getId())
|
||||
.set(SysDept::getStatus, statusUpdateDTO.getStatus())
|
||||
.update();
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysResource;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysResourceMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysResourceService implements LambdaService<SysResource, SysResourceMapper> {
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysRoleResource;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysRoleResourceMapper;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysRoleResourceDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysRoleResourceService implements LambdaService<SysRoleResource, SysRoleResourceMapper> {
|
||||
|
||||
|
||||
/**
|
||||
* 保存角色菜单配置
|
||||
*
|
||||
* @param sysRoleResourceDTO 入参
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int saveRoleResource(SysRoleResourceDTO sysRoleResourceDTO) {
|
||||
Long roleId = sysRoleResourceDTO.getRoleId();
|
||||
// 删除之前的
|
||||
this.deleteByColumn(SysRoleResource::getRoleId, roleId);
|
||||
|
||||
List<SysRoleResource> saveList = sysRoleResourceDTO.getResourceIds().stream()
|
||||
.map(resourceId -> {
|
||||
SysRoleResource sysRoleResource = new SysRoleResource();
|
||||
sysRoleResource.setRoleId(roleId);
|
||||
sysRoleResource.setResourceId(resourceId);
|
||||
sysRoleResource.setAddBy(sysRoleResourceDTO.getAddBy());
|
||||
sysRoleResource.setUpdateBy(sysRoleResourceDTO.getAddBy());
|
||||
return sysRoleResource;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return this.saveBatch(saveList);
|
||||
}
|
||||
|
||||
public List<Long> listRoleResource(Long roleId) {
|
||||
return this.query()
|
||||
.eq(SysRoleResource::getRoleId, roleId)
|
||||
.listUniqueValue(SysRoleResource::getResourceId);
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysRole;
|
||||
@@ -15,16 +13,6 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class SysRoleService implements LambdaService<SysRole, SysRoleMapper> {
|
||||
|
||||
public PageInfo<SysRole> doPage(LambdaQuery<SysRole> query) {
|
||||
query.orderByDesc(SysRole::getId);
|
||||
PageInfo<SysRole> page = this.page(query);
|
||||
|
||||
// 格式转换
|
||||
return page.convert(isvInfo -> {
|
||||
|
||||
return isvInfo;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
@@ -40,4 +28,5 @@ public class SysRoleService implements LambdaService<SysRole, SysRoleMapper> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,116 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysDept;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUserDept;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysDeptMapper;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysUserDeptMapper;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.DeptUserResultDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysDeptDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysUserDeptService implements LambdaService<SysUserDept, SysUserDeptMapper> {
|
||||
|
||||
@Autowired
|
||||
SysDeptMapper sysDeptMapper;
|
||||
|
||||
public Map<Long, SysDeptDTO> getUserDeptId(Collection<Long> userIds) {
|
||||
Map<Long, SysDept> deptIdMap = sysDeptMapper.query()
|
||||
.map(SysDept::getId, Function.identity());
|
||||
return this.query()
|
||||
.in(SysUserDept::getUserId, userIds)
|
||||
.map(SysUserDept::getUserId, sysUserDept -> {
|
||||
SysDept sysDept = deptIdMap.get(sysUserDept.getDeptId());
|
||||
return CopyUtil.copyBean(sysDept, SysDeptDTO::new);
|
||||
}, (v1, v2) -> v2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找部门及子部门下所有用户
|
||||
*
|
||||
* @param deptId 部门
|
||||
* @return 返回空表示选中了根节点或没有选
|
||||
*/
|
||||
public DeptUserResultDTO listDeptUserIdsDeep(Long deptId) {
|
||||
if (deptId == null) {
|
||||
return new DeptUserResultDTO(false, null);
|
||||
}
|
||||
SysDept sysDept = sysDeptMapper.getById(deptId);
|
||||
// 选中了根节点或没有选
|
||||
if (sysDept == null || Objects.equals(sysDept.getParentId(), 0L)) {
|
||||
return new DeptUserResultDTO(false, null);
|
||||
}
|
||||
List<Long> userIdsAll = new ArrayList<>();
|
||||
List<Long> userIds = this.query()
|
||||
.eq(SysUserDept::getDeptId, deptId)
|
||||
.listUniqueValue(SysUserDept::getUserId);
|
||||
|
||||
appendChildren(userIdsAll, deptId);
|
||||
|
||||
userIdsAll.addAll(userIds);
|
||||
return new DeptUserResultDTO(true, userIdsAll);
|
||||
}
|
||||
|
||||
private void appendChildren(List<Long> userIdsAll, Long deptId) {
|
||||
List<Long> deptIds = sysDeptMapper.query()
|
||||
.eq(SysDept::getParentId, deptId)
|
||||
.listUniqueValue(SysDept::getId);
|
||||
if (deptIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Long> userIds = this.query()
|
||||
.in(SysUserDept::getDeptId, deptIds)
|
||||
.listUniqueValue(SysUserDept::getUserId);
|
||||
userIdsAll.addAll(userIds);
|
||||
|
||||
for (Long childDeptId : deptIds) {
|
||||
appendChildren(userIdsAll, childDeptId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户部门
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param deptIds 部门id
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
public int saveUserDept(Long userId, List<Long> deptIds) {
|
||||
this.query()
|
||||
.eq(SysUserDept::getUserId, userId)
|
||||
.delete();
|
||||
|
||||
if (CollectionUtils.isEmpty(deptIds)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<SysUserDept> saveList = deptIds.stream()
|
||||
.map(deptId -> {
|
||||
SysUserDept sysUserDept = new SysUserDept();
|
||||
sysUserDept.setUserId(userId);
|
||||
sysUserDept.setDeptId(deptId);
|
||||
return sysUserDept;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return this.saveBatch(saveList);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.common.user.User;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUserRole;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysUserRoleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysUserRoleService implements LambdaService<SysUserRole, SysUserRoleMapper> {
|
||||
|
||||
/**
|
||||
* 设置用户角色
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param roleIds 角色id
|
||||
* @param operator 操作人
|
||||
*/
|
||||
public void setUserRole(Long userId, List<Long> roleIds, User operator) {
|
||||
this.query()
|
||||
.eq(SysUserRole::getUserId, userId)
|
||||
.delete();
|
||||
|
||||
if (CollectionUtils.isEmpty(roleIds)) {
|
||||
return;
|
||||
}
|
||||
List<SysUserRole> saveList = new LinkedHashSet<>(roleIds).stream()
|
||||
.map(roleId -> {
|
||||
SysUserRole sysUserRole = new SysUserRole();
|
||||
sysUserRole.setRoleId(roleId);
|
||||
sysUserRole.setUserId(userId);
|
||||
sysUserRole.setAddBy(operator.getUserId());
|
||||
return sysUserRole;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
this.saveBatch(saveList);
|
||||
}
|
||||
|
||||
public List<Long> listUserRoleIds(Long userId) {
|
||||
return this.query()
|
||||
.eq(SysUserRole::getUserId, userId)
|
||||
.listUniqueValue(SysUserRole::getRoleId);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,149 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.LambdaQuery;
|
||||
import com.gitee.fastmybatis.core.support.LambdaService;
|
||||
import com.gitee.sop.adminbackend.common.config.Configs;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateBatchDTO;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.common.enums.ConfigKeyEnum;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.common.util.GenerateUtil;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUser;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.SysUserMapper;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.DeptUserResultDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysDeptDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserAddDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserSearchDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.enums.RegTypeEnum;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Service
|
||||
public class SysUserService implements LambdaService<SysUser, SysUserMapper> {
|
||||
|
||||
@Autowired
|
||||
SysUserDeptService sysUserDeptService;
|
||||
|
||||
public PageInfo<SysUserDTO> doPage(SysUserSearchDTO sysUserSearchDTO) {
|
||||
LambdaQuery<SysUser> query = sysUserSearchDTO.toLambdaQuery(SysUser.class);
|
||||
Long deptId = sysUserSearchDTO.getDeptId();
|
||||
DeptUserResultDTO deptUserResultDTO = sysUserDeptService.listDeptUserIdsDeep(deptId);
|
||||
if (deptUserResultDTO.getSelect()) {
|
||||
List<Long> userIds = deptUserResultDTO.getUserIds();
|
||||
// 查不到返回空
|
||||
if (CollectionUtils.isEmpty(userIds)) {
|
||||
return new PageInfo<>();
|
||||
}
|
||||
query.in(SysUser::getId, userIds);
|
||||
}
|
||||
|
||||
query.orderByDesc(SysUser::getId);
|
||||
|
||||
// 格式转换
|
||||
return this.pageAndConvert(query, records -> {
|
||||
if (records.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Set<Long> userIds = records.stream().map(SysUser::getId).collect(Collectors.toSet());
|
||||
Map<Long, SysDeptDTO> userIdDeptMap = sysUserDeptService.getUserDeptId(userIds);
|
||||
|
||||
return CopyUtil.copyList(records, SysUserDTO::new, after -> {
|
||||
SysDeptDTO sysDeptDTO = userIdDeptMap.get(after.getId());
|
||||
after.setDept(sysDeptDTO);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public Long addUser(SysUserAddDTO sysUserAddDTO) {
|
||||
SysUser sysUser = CopyUtil.copyBean(sysUserAddDTO, SysUser::new);
|
||||
String encodedPassword = BCrypt.hashpw(sysUserAddDTO.getPassword(), BCrypt.gensalt());
|
||||
sysUser.setPassword(encodedPassword);
|
||||
sysUser.setRegType(RegTypeEnum.BACKEND.getValue());
|
||||
this.save(sysUser);
|
||||
|
||||
// 添加部门
|
||||
Long deptId = sysUserAddDTO.getParentId();
|
||||
if (deptId != null && deptId > 0) {
|
||||
sysUserDeptService.saveUserDept(sysUser.getId(), Lists.newArrayList(deptId));
|
||||
}
|
||||
|
||||
return sysUser.getId();
|
||||
}
|
||||
|
||||
public int updateUser(SysUserUpdateDTO sysUserUpdateDTO) {
|
||||
SysUser sysUser = CopyUtil.copyBean(sysUserUpdateDTO, SysUser::new);
|
||||
int cnt = this.update(sysUser);
|
||||
|
||||
// 添加部门
|
||||
Long deptId = sysUserUpdateDTO.getParentId();
|
||||
if (deptId != null && deptId > 0) {
|
||||
sysUserDeptService.saveUserDept(sysUser.getId(), Lists.newArrayList(deptId));
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*
|
||||
* @param statusUpdateDTO 修改值
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
public int updateStatus(StatusUpdateDTO statusUpdateDTO) {
|
||||
return this.query()
|
||||
.eq(SysUser::getId, statusUpdateDTO.getId())
|
||||
.set(SysUser::getStatus, statusUpdateDTO.getStatus())
|
||||
.update();
|
||||
}
|
||||
|
||||
public int updateStatus(StatusUpdateBatchDTO statusUpdateDTO) {
|
||||
return this.query()
|
||||
.in(SysUser::getId, statusUpdateDTO.getIds())
|
||||
.set(SysUser::getStatus, statusUpdateDTO.getStatus())
|
||||
.update();
|
||||
}
|
||||
|
||||
public void resetUserPassword(Long userId, String passwordHash) {
|
||||
String encodedPassword = BCrypt.hashpw(passwordHash, BCrypt.gensalt());
|
||||
this.query()
|
||||
.eq(SysUser::getId, userId)
|
||||
.set(SysUser::getPassword, encodedPassword)
|
||||
.update();
|
||||
}
|
||||
|
||||
public SysUser getByUsername(String username) {
|
||||
return this.get(SysUser::getUsername, username);
|
||||
}
|
||||
|
||||
public String getDbPassword(String username, String password) {
|
||||
return getDbPassword(username, password, getPasswordSalt());
|
||||
}
|
||||
|
||||
public String getDbPassword(String username) {
|
||||
return this.query().eq(SysUser::getUsername, username).getValue(SysUser::getPassword);
|
||||
}
|
||||
|
||||
public String getDbPassword(String username, String password, String salt) {
|
||||
return GenerateUtil.getUserPassword(username, password, salt);
|
||||
}
|
||||
|
||||
private String getPasswordSalt() {
|
||||
return Configs.getValue(ConfigKeyEnum.PASSWORD_SALT);
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package com.gitee.sop.adminbackend.service.sys;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.enums.ConfigKeyEnum;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysAdminUser;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUser;
|
||||
import com.gitee.sop.adminbackend.dao.mapper.UpgradeMapper;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.enums.RegTypeEnum;
|
||||
import com.gitee.sop.adminbackend.common.util.PasswordUtil;
|
||||
@@ -23,7 +23,7 @@ public class UpgradeService {
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
@Autowired
|
||||
private SysAdminUserService sysAdminUserService;
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private UpgradeMapper upgradeMapper;
|
||||
@@ -45,12 +45,12 @@ public class UpgradeService {
|
||||
|
||||
|
||||
public void insertAdmin() {
|
||||
SysAdminUser userInfo = sysAdminUserService.getByUsername("admin");
|
||||
SysUser userInfo = sysUserService.getByUsername("admin");
|
||||
if (userInfo != null) {
|
||||
return;
|
||||
}
|
||||
String username = "admin";
|
||||
String tpl = "INSERT INTO `sys_admin_user` ( `username`, `password`, `nickname`, `reg_type`) VALUES \n" +
|
||||
String tpl = "INSERT INTO `sys_user` ( `username`, `password`, `nickname`, `reg_type`) VALUES \n" +
|
||||
"\t('%s','%s','%s','%s');";
|
||||
// 初始密码
|
||||
String defPassword = "123456";
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DeptUserResultDTO {
|
||||
|
||||
private Boolean select = true;
|
||||
|
||||
private List<Long> userIds;
|
||||
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.dto;
|
||||
|
||||
import com.gitee.fastmybatis.core.support.TreeNode;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 备注:部门表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysDeptDTO implements TreeNode<SysDeptDTO, Long> {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
private List<SysDeptDTO> children;
|
||||
|
||||
|
||||
@Override
|
||||
public Long takeId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long takeParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleResourceDTO {
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 资源id
|
||||
*/
|
||||
private List<Long> resourceIds;
|
||||
|
||||
/**
|
||||
* 添加人
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysUserAddDTO {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别,0-未知,1-男,2-女
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 注册类型,1-系统,2-手动
|
||||
*/
|
||||
private String regType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysUserDTO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别,0-未知,1-男,2-女
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 注册类型,1-系统,2-手动
|
||||
*/
|
||||
private String regType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
private SysDeptDTO dept;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.dto;
|
||||
|
||||
import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 备注:角色表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysUserSearchDTO extends PageParam {
|
||||
private static final long serialVersionUID = 7794265174728302379L;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String phone;
|
||||
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
@Condition
|
||||
private Integer status;
|
||||
|
||||
@Condition(ignore = true)
|
||||
private Long deptId;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysUserUpdateDTO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@NotNull(message = "id必填")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别,0-未知,1-男,2-女
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 注册类型,1-系统,2-手动
|
||||
*/
|
||||
private String regType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
}
|
@@ -1,20 +1,20 @@
|
||||
package com.gitee.sop.adminbackend.service.sys.login;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.config.Configs;
|
||||
import com.gitee.sop.adminbackend.common.enums.ConfigKeyEnum;
|
||||
import com.gitee.sop.adminbackend.common.enums.StatusEnum;
|
||||
import com.gitee.sop.adminbackend.common.exception.BizException;
|
||||
import com.gitee.sop.adminbackend.common.config.Configs;
|
||||
import com.gitee.sop.adminbackend.common.manager.UserCacheManager;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysAdminUser;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysAdminUserService;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.common.util.GenerateUtil;
|
||||
import com.gitee.sop.adminbackend.common.util.JwtUtil;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUser;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysUserService;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.dto.LoginDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.dto.LoginForm;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.dto.LoginResult;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.dto.LoginUser;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.enums.RegTypeEnum;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.common.util.GenerateUtil;
|
||||
import com.gitee.sop.adminbackend.common.util.JwtUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
@@ -38,7 +38,7 @@ import java.util.Objects;
|
||||
public class LoginService {
|
||||
|
||||
@Autowired
|
||||
private SysAdminUserService sysAdminUserService;
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private UserCacheManager userCacheManager;
|
||||
@@ -48,7 +48,7 @@ public class LoginService {
|
||||
String username = loginDTO.getUsername();
|
||||
String password = loginDTO.getPassword();
|
||||
RegTypeEnum regType = loginDTO.getRegType();
|
||||
SysAdminUser userInfo;
|
||||
SysUser userInfo;
|
||||
switch (regType) {
|
||||
case FORM:
|
||||
throw new UnsupportedOperationException("第三方登录暂未支持");
|
||||
@@ -65,16 +65,16 @@ public class LoginService {
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
private LoginUser buildLoginUser(SysAdminUser userInfo) {
|
||||
if (StatusEnum.of(userInfo.getStatus()) == StatusEnum.DISABLED) {
|
||||
private LoginUser buildLoginUser(SysUser sysUser) {
|
||||
if (StatusEnum.of(sysUser.getStatus()) == StatusEnum.DISABLED) {
|
||||
throw new BizException("账号已禁用,请联系管理员");
|
||||
}
|
||||
// 登录成功
|
||||
LoginUser loginUser = CopyUtil.copyBean(userInfo, LoginUser::new);
|
||||
LoginUser loginUser = CopyUtil.copyBean(sysUser, LoginUser::new);
|
||||
// 创建token
|
||||
String token = this.createToken(userInfo.getId());
|
||||
String token = this.createToken(sysUser.getId());
|
||||
loginUser.setAccessToken(token);
|
||||
if ("admin".equals(userInfo.getUsername())) {
|
||||
if ("admin".equals(sysUser.getUsername())) {
|
||||
// ROLE
|
||||
loginUser.setRoles(Sets.newHashSet("admin"));
|
||||
// *:*:* 表示所有权限
|
||||
@@ -102,7 +102,7 @@ public class LoginService {
|
||||
return Configs.getValue(ConfigKeyEnum.JWT_SECRET);
|
||||
}
|
||||
|
||||
private SysAdminUser doThirdPartyLogin(ThirdPartyLoginManager thirdPartyLoginManager, String username, String password) {
|
||||
private SysUser doThirdPartyLogin(ThirdPartyLoginManager thirdPartyLoginManager, String username, String password) {
|
||||
LoginForm loginForm = new LoginForm();
|
||||
loginForm.setUsername(username);
|
||||
loginForm.setPassword(password);
|
||||
@@ -114,11 +114,11 @@ public class LoginService {
|
||||
throw new BizException(e.getMessage());
|
||||
}
|
||||
|
||||
SysAdminUser userInfo = sysAdminUserService.getByUsername(username);
|
||||
SysUser userInfo = sysUserService.getByUsername(username);
|
||||
|
||||
// 用户第一次登录则插入到user_info表
|
||||
if (userInfo == null) {
|
||||
userInfo = new SysAdminUser();
|
||||
userInfo = new SysUser();
|
||||
userInfo.setUsername(username);
|
||||
userInfo.setPassword(GenerateUtil.getUUID());
|
||||
userInfo.setNickname(loginResult.getNickname());
|
||||
@@ -126,26 +126,27 @@ public class LoginService {
|
||||
userInfo.setStatus(StatusEnum.ENABLE.getValue());
|
||||
userInfo.setRegType(loginResult.getRegTypeEnum().getValue());
|
||||
userInfo.setEmail(loginResult.getEmail());
|
||||
sysAdminUserService.save(userInfo);
|
||||
sysUserService.save(userInfo);
|
||||
} else {
|
||||
String email = loginResult.getEmail();
|
||||
// 如果更改了邮箱
|
||||
if (StringUtils.hasText(email) && !Objects.equals(email, userInfo.getEmail())) {
|
||||
userInfo.setEmail(email);
|
||||
sysAdminUserService.update(userInfo);
|
||||
sysUserService.update(userInfo);
|
||||
}
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
private SysAdminUser doDatabaseLogin(String username, String password) {
|
||||
SysAdminUser sysAdminUser = sysAdminUserService.getByUsername(username);
|
||||
Assert.notNull(sysAdminUser, () -> "用户名密码不正确");
|
||||
String encodedPasswordDb = sysAdminUser.getPassword();
|
||||
private SysUser doDatabaseLogin(String username, String password) {
|
||||
SysUser sysUser = sysUserService.getByUsername(username);
|
||||
Assert.notNull(sysUser, () -> "用户名密码不正确");
|
||||
String encodedPasswordDb = sysUser.getPassword();
|
||||
// 校验
|
||||
boolean flag = BCrypt.checkpw(password, encodedPasswordDb);
|
||||
Assert.isTrue(flag, () -> "用户名密码不正确");
|
||||
return sysAdminUser;
|
||||
Assert.isTrue(Objects.equals(sysUser.getStatus(), StatusEnum.ENABLE.getValue()), () -> "用户已禁用");
|
||||
return sysUser;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,8 +2,8 @@ package com.gitee.sop.adminbackend.service.sys.login.impl;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.user.User;
|
||||
import com.gitee.sop.adminbackend.common.enums.StatusEnum;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysAdminUser;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysAdminUserService;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysUser;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysUserService;
|
||||
import com.gitee.sop.adminbackend.common.manager.UserCacheManager;
|
||||
import com.gitee.sop.adminbackend.service.sys.login.dto.LoginUser;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
@@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class DefaultUserCacheManager implements UserCacheManager, InitializingBean {
|
||||
|
||||
@Autowired
|
||||
private SysAdminUserService sysAdminUserService;
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Value("${admin.user-cache-timeout-minutes:15}")
|
||||
private int timeoutMinutes;
|
||||
@@ -70,7 +70,7 @@ public class DefaultUserCacheManager implements UserCacheManager, InitializingBe
|
||||
* @return
|
||||
*/
|
||||
private User getLoginUser(long id) {
|
||||
SysAdminUser userInfo = sysAdminUserService.getById(id);
|
||||
SysUser userInfo = sysUserService.getById(id);
|
||||
if (userInfo == null) {
|
||||
log.warn("登录用户不存在,userId:{}", id);
|
||||
return null;
|
||||
|
@@ -32,9 +32,8 @@ public class ExceptionHandlerController {
|
||||
log.error("报错,code:{}, msg:{}", errorCode.getCode(), errorCode.getMsg(), e);
|
||||
return Result.err(errorCode.getCode(), errorCode.getMsg());
|
||||
}
|
||||
if (e instanceof BizException) {
|
||||
RuntimeException bizException = (RuntimeException) e;
|
||||
return Result.err(bizException.getMessage());
|
||||
if (e instanceof BizException || e instanceof IllegalArgumentException) {
|
||||
return Result.err(e.getMessage());
|
||||
}
|
||||
// 处理JSR-303错误
|
||||
if (e instanceof MethodArgumentNotValidException) {
|
||||
|
@@ -1,66 +0,0 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.fastmybatis.core.query.Query;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysAdminUser;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysAdminUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/adminuser")
|
||||
public class SysAdminUserController {
|
||||
|
||||
@Autowired
|
||||
private SysAdminUserService sysAdminUserService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result<PageInfo<SysAdminUser>> page(PageParam param) {
|
||||
Query query = param.toQuery();
|
||||
PageInfo<SysAdminUser> pageInfo = sysAdminUserService.page(query);
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param sysAdminUser 表单参数
|
||||
* @return 返回添加后的主键值
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result<Long> add(@Validated @RequestBody SysAdminUser sysAdminUser) {
|
||||
sysAdminUserService.save(sysAdminUser);
|
||||
// 返回添加后的主键值
|
||||
return Result.ok(sysAdminUser.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改记录
|
||||
*
|
||||
* @param sysAdminUser 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Result<Integer> update(@Validated @RequestBody SysAdminUser sysAdminUser) {
|
||||
return Result.ok(sysAdminUserService.update(sysAdminUser));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.common.exception.BizException;
|
||||
import com.gitee.sop.adminbackend.common.req.StatusUpdateParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysDept;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/dept")
|
||||
public class SysDeptController {
|
||||
|
||||
@Autowired
|
||||
private SysDeptService sysDeptService;
|
||||
|
||||
/**
|
||||
* listAll
|
||||
*
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
public Result<List<SysDept>> listAll() {
|
||||
List<SysDept> sysDepts = sysDeptService.listAll();
|
||||
return Result.ok(sysDepts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param sysDept 表单参数
|
||||
* @return 返回添加后的主键值
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result<Long> add(@Validated @RequestBody SysDept sysDept) {
|
||||
Long id = sysDeptService.addDept(sysDept);
|
||||
// 返回添加后的主键值
|
||||
return Result.ok(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改记录
|
||||
*
|
||||
* @param sysDept 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Result<Integer> update(@Validated @RequestBody SysDept sysDept) {
|
||||
if (Objects.equals(sysDept.getParentId(), sysDept.getId())) {
|
||||
throw new BizException("父级不能选自己");
|
||||
}
|
||||
return Result.ok(sysDeptService.update(sysDept));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/updateStatus")
|
||||
public Result<Integer> updateStatus(@Validated @RequestBody StatusUpdateParam param) {
|
||||
StatusUpdateDTO statusUpdateDTO = CopyUtil.copyBean(param, StatusUpdateDTO::new);
|
||||
return Result.ok(sysDeptService.updateStatus(statusUpdateDTO));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.context.UserContext;
|
||||
import com.gitee.sop.adminbackend.common.req.IdParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysResourceAddParam;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysResourceUpdateParam;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysRoleResourceSaveParam;
|
||||
import com.gitee.sop.adminbackend.controller.sys.vo.SysResourceVO;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysResource;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysResourceService;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysRoleResourceService;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysRoleResourceDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资源菜单
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/resource")
|
||||
public class SysResourceController {
|
||||
|
||||
@Autowired
|
||||
private SysResourceService sysResourceService;
|
||||
@Autowired
|
||||
private SysRoleResourceService sysRoleResourceService;
|
||||
|
||||
/**
|
||||
* 查询全部资源
|
||||
*
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/listAll")
|
||||
public Result<List<SysResourceVO>> tree() {
|
||||
List<SysResource> list = sysResourceService.listAll();
|
||||
List<SysResourceVO> retList = CopyUtil.copyList(list, SysResourceVO::new);
|
||||
return Result.ok(retList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param param 表单参数
|
||||
* @return 返回添加后的主键值
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result<Long> add(@Validated @RequestBody SysResourceAddParam param) {
|
||||
SysResource sysResource = CopyUtil.copyBean(param, SysResource::new);
|
||||
sysResourceService.save(sysResource);
|
||||
// 返回添加后的主键值
|
||||
return Result.ok(sysResource.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改记录
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Result<Integer> update(@Validated @RequestBody SysResourceUpdateParam param) {
|
||||
SysResource sysResource = CopyUtil.copyBean(param, SysResource::new);
|
||||
return Result.ok(sysResourceService.update(sysResource));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public Result<Integer> delete(@Validated @RequestBody IdParam param) {
|
||||
return Result.ok(sysResourceService.deleteById(param.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色资源
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/saveRoleResource")
|
||||
public Result<Integer> saveRoleResource(@Validated @RequestBody SysRoleResourceSaveParam param) {
|
||||
SysRoleResourceDTO sysRoleResourceDTO = CopyUtil.copyBean(param, SysRoleResourceDTO::new);
|
||||
sysRoleResourceDTO.setAddBy(UserContext.getUser().getUserId());
|
||||
int cnt = sysRoleResourceService.saveRoleResource(sysRoleResourceDTO);
|
||||
return Result.ok(cnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色资源
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@GetMapping("/listRoleResource")
|
||||
public Result<List<Long>> listRoleResource(@Validated IdParam param) {
|
||||
List<Long> resourceIds = sysRoleResourceService.listRoleResource(param.getId());
|
||||
return Result.ok(resourceIds);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -10,6 +10,7 @@ import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysRoleParam;
|
||||
import com.gitee.sop.adminbackend.dao.entity.SysRole;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysRoleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -17,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
@@ -26,7 +27,7 @@ import javax.annotation.Resource;
|
||||
@RequestMapping("sys/role")
|
||||
public class SysRoleController {
|
||||
|
||||
@Resource
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
|
||||
/**
|
||||
@@ -38,10 +39,21 @@ public class SysRoleController {
|
||||
@GetMapping("/page")
|
||||
public Result<PageInfo<SysRole>> page(SysRoleParam param) {
|
||||
LambdaQuery<SysRole> query = param.toLambdaQuery(SysRole.class);
|
||||
PageInfo<SysRole> pageInfo = sysRoleService.doPage(query);
|
||||
PageInfo<SysRole> pageInfo = sysRoleService.page(query);
|
||||
return Result.ok(pageInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有角色
|
||||
*
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/all")
|
||||
public Result<List<SysRole>> all() {
|
||||
List<SysRole> list = sysRoleService.listAll();
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
|
@@ -0,0 +1,120 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys;
|
||||
|
||||
import com.gitee.fastmybatis.core.PageInfo;
|
||||
import com.gitee.sop.adminbackend.common.context.UserContext;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateBatchDTO;
|
||||
import com.gitee.sop.adminbackend.common.dto.StatusUpdateDTO;
|
||||
import com.gitee.sop.adminbackend.common.req.StatusUpdateBatchParam;
|
||||
import com.gitee.sop.adminbackend.common.req.StatusUpdateParam;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.common.util.CopyUtil;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.RestPasswordParam;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysUserAddParam;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysUserParam;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysUserUpdateParam;
|
||||
import com.gitee.sop.adminbackend.controller.sys.vo.SysUserVO;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysUserService;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserAddDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserSearchDTO;
|
||||
import com.gitee.sop.adminbackend.service.sys.dto.SysUserUpdateDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/user")
|
||||
public class SysUserController {
|
||||
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public Result<PageInfo<SysUserVO>> page(SysUserParam param) {
|
||||
SysUserSearchDTO sysUserSearchDTO = CopyUtil.copyBean(param, SysUserSearchDTO::new);
|
||||
PageInfo<SysUserDTO> pageInfo = sysUserService.doPage(sysUserSearchDTO);
|
||||
PageInfo<SysUserVO> ret = CopyUtil.copyPageInfo(pageInfo, records -> CopyUtil.deepCopyList(records, SysUserVO.class));
|
||||
return Result.ok(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param param 表单参数
|
||||
* @return 返回添加后的主键值
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public Result<Long> add(@Validated @RequestBody SysUserAddParam param) {
|
||||
SysUserAddDTO sysUser = CopyUtil.copyBean(param, SysUserAddDTO::new);
|
||||
sysUser.setUpdateBy(UserContext.getUser().getUserId());
|
||||
Long id = sysUserService.addUser(sysUser);
|
||||
// 返回添加后的主键值
|
||||
return Result.ok(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改记录
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public Result<Integer> update(@Validated @RequestBody SysUserUpdateParam param) {
|
||||
SysUserUpdateDTO sysUser = CopyUtil.copyBean(param, SysUserUpdateDTO::new);
|
||||
sysUser.setUpdateBy(UserContext.getUser().getUserId());
|
||||
int cnt = sysUserService.updateUser(sysUser);
|
||||
return Result.ok(cnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/updateStatus")
|
||||
public Result<Integer> updateStatus(@Validated @RequestBody StatusUpdateParam param) {
|
||||
StatusUpdateDTO statusUpdateDTO = CopyUtil.copyBean(param, StatusUpdateDTO::new);
|
||||
return Result.ok(sysUserService.updateStatus(statusUpdateDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态批量
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/updateStatusBatch")
|
||||
public Result<Integer> updateStatus(@Validated @RequestBody StatusUpdateBatchParam param) {
|
||||
StatusUpdateBatchDTO statusUpdateBatchDTO = CopyUtil.copyBean(param, StatusUpdateBatchDTO::new);
|
||||
return Result.ok(sysUserService.updateStatus(statusUpdateBatchDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/resetPassword")
|
||||
public Result<Integer> resetPassword(@Validated @RequestBody RestPasswordParam param) {
|
||||
sysUserService.resetUserPassword(param.getUserId(), param.getPasswordHash());
|
||||
return Result.ok(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.context.UserContext;
|
||||
import com.gitee.sop.adminbackend.common.resp.Result;
|
||||
import com.gitee.sop.adminbackend.controller.sys.param.SysUserRoleSettingParam;
|
||||
import com.gitee.sop.adminbackend.service.sys.SysUserRoleService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sys/userrole")
|
||||
public class SysUserRoleController {
|
||||
|
||||
@Resource
|
||||
private SysUserRoleService sysUserRoleService;
|
||||
|
||||
/**
|
||||
* 获取用户角色id
|
||||
*
|
||||
* @return 返回角色id
|
||||
*/
|
||||
@GetMapping("/getUserRoleIds")
|
||||
public Result<List<Long>> getUserRoleIds(Long userId) {
|
||||
List<Long> roleIds = sysUserRoleService.listUserRoleIds(userId);
|
||||
return Result.ok(roleIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置用户角色
|
||||
*
|
||||
* @param param 表单数据
|
||||
* @return 返回影响行数
|
||||
*/
|
||||
@PostMapping("/setUserRole")
|
||||
public Result<Integer> setUserRole(@Validated @RequestBody SysUserRoleSettingParam param) {
|
||||
sysUserRoleService.setUserRole(param.getUserId(), param.getRoleIds(), UserContext.getUser());
|
||||
return Result.ok(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class RestPasswordParam {
|
||||
|
||||
@NotNull
|
||||
private Long userId;
|
||||
|
||||
@NotBlank
|
||||
private String passwordHash;
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 备注:部门表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysDeptParam extends PageParam {
|
||||
private static final long serialVersionUID = 7104037961585738100L;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
@Condition
|
||||
private Integer status;
|
||||
|
||||
}
|
@@ -0,0 +1,160 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.jackson.convert.annotation.Bool;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysResourceAddParam {
|
||||
|
||||
/**
|
||||
* 菜单类型(0代表菜单、1代表iframe、2代表外链、3代表按钮)
|
||||
*/
|
||||
@NotNull
|
||||
private Integer menuType;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 路由名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
@NotBlank
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer rank;
|
||||
|
||||
/**
|
||||
* 路由重定向
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 路由重定向
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 右侧图标
|
||||
*/
|
||||
private String extraIcon;
|
||||
|
||||
/**
|
||||
* 进场动画(页面加载动画)
|
||||
*/
|
||||
private String enterTransition;
|
||||
|
||||
/**
|
||||
* 离场动画(页面加载动画)
|
||||
*/
|
||||
private String leaveTransition;
|
||||
|
||||
/**
|
||||
* 菜单激活
|
||||
*/
|
||||
private String activePath;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
private String auths;
|
||||
|
||||
/**
|
||||
* 链接地址(需要内嵌的`iframe`链接地址)
|
||||
*/
|
||||
private String frameSrc;
|
||||
|
||||
/**
|
||||
* 加载动画(内嵌的`iframe`页面是否开启首次加载动画)
|
||||
*/
|
||||
@Bool
|
||||
private Integer frameLoading;
|
||||
|
||||
/**
|
||||
* 缓存页面
|
||||
*/
|
||||
@Bool
|
||||
private Integer keepAlive;
|
||||
|
||||
/**
|
||||
* 标签页(当前菜单名称或自定义信息禁止添加到标签页)
|
||||
*/
|
||||
@Bool
|
||||
private Integer hiddenTag;
|
||||
|
||||
/**
|
||||
* 固定标签页(当前菜单名称是否固定显示在标签页且不可关闭)
|
||||
*/
|
||||
@Bool
|
||||
private Integer fixedTag;
|
||||
|
||||
/**
|
||||
* 菜单(是否显示该菜单)
|
||||
*/
|
||||
@Bool
|
||||
private Integer showLink;
|
||||
|
||||
/**
|
||||
* 父级菜单(是否显示父级菜单
|
||||
*/
|
||||
@Bool
|
||||
private Integer showParent;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysResourceUpdateParam extends SysResourceAddParam {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@NotNull(message = "id必填")
|
||||
private Long id;
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleResourceSaveParam {
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
@NotNull
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 资源id
|
||||
*/
|
||||
@NotEmpty
|
||||
private List<Long> resourceIds;
|
||||
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysUserAddParam {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别,0-未知,1-男,2-女
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 注册类型,1-系统,2-手动
|
||||
*/
|
||||
private String regType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 部门id
|
||||
*/
|
||||
@NotNull(message = "请选择部门")
|
||||
@Min(value = 1, message = "请选择部门")
|
||||
private Long parentId;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import com.gitee.fastmybatis.core.query.Operator;
|
||||
import com.gitee.fastmybatis.core.query.annotation.Condition;
|
||||
import com.gitee.fastmybatis.core.query.param.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 备注:系统用户表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysUserParam extends PageParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
@Condition(operator = Operator.like)
|
||||
private String phone;
|
||||
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
@Condition
|
||||
private Integer status;
|
||||
|
||||
@Condition(ignore = true)
|
||||
private Long deptId;
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysUserRoleSettingParam {
|
||||
|
||||
/**
|
||||
* sys_role.id
|
||||
*/
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* sys_user.id
|
||||
*/
|
||||
@NotNull
|
||||
private Long userId;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.param;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysUserUpdateParam extends SysUserAddParam {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@NotNull(message = "id必填")
|
||||
private Long id;
|
||||
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 表名:sys_dept
|
||||
* 备注:部门表
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysDeptVO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
private List<SysDeptVO> children;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,163 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.vo;
|
||||
|
||||
import com.gitee.sop.adminbackend.common.jackson.convert.annotation.Bool;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysResourceVO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 菜单类型(0代表菜单、1代表iframe、2代表外链、3代表按钮)
|
||||
*/
|
||||
@NotNull
|
||||
private Integer menuType;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 路由名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
@NotBlank
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 路由路径
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer rank;
|
||||
|
||||
/**
|
||||
* 路由重定向
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 路由重定向
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 右侧图标
|
||||
*/
|
||||
private String extraIcon;
|
||||
|
||||
/**
|
||||
* 进场动画(页面加载动画)
|
||||
*/
|
||||
private String enterTransition;
|
||||
|
||||
/**
|
||||
* 离场动画(页面加载动画)
|
||||
*/
|
||||
private String leaveTransition;
|
||||
|
||||
/**
|
||||
* 菜单激活
|
||||
*/
|
||||
private String activePath;
|
||||
|
||||
/**
|
||||
* 权限标识
|
||||
*/
|
||||
private String auths;
|
||||
|
||||
/**
|
||||
* 链接地址(需要内嵌的`iframe`链接地址)
|
||||
*/
|
||||
private String frameSrc;
|
||||
|
||||
/**
|
||||
* 加载动画(内嵌的`iframe`页面是否开启首次加载动画)
|
||||
*/
|
||||
@Bool
|
||||
private Integer frameLoading;
|
||||
|
||||
/**
|
||||
* 缓存页面
|
||||
*/
|
||||
@Bool
|
||||
private Integer keepAlive;
|
||||
|
||||
/**
|
||||
* 标签页(当前菜单名称或自定义信息禁止添加到标签页)
|
||||
*/
|
||||
@Bool
|
||||
private Integer hiddenTag;
|
||||
|
||||
/**
|
||||
* 固定标签页(当前菜单名称是否固定显示在标签页且不可关闭)
|
||||
*/
|
||||
@Bool
|
||||
private Integer fixedTag;
|
||||
|
||||
/**
|
||||
* 菜单(是否显示该菜单)
|
||||
*/
|
||||
@Bool
|
||||
private Integer showLink;
|
||||
|
||||
/**
|
||||
* 父级菜单(是否显示父级菜单
|
||||
*/
|
||||
@Bool
|
||||
private Integer showParent;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
package com.gitee.sop.adminbackend.controller.sys.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 六如
|
||||
*/
|
||||
@Data
|
||||
public class SysUserVO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别,0-未知,1-男,2-女
|
||||
*/
|
||||
private Integer gender;
|
||||
|
||||
/**
|
||||
* 状态,1:启用,2:禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 注册类型,1-系统,2-手动
|
||||
*/
|
||||
private String regType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 添加时间
|
||||
*/
|
||||
private LocalDateTime addTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long addBy;
|
||||
|
||||
/**
|
||||
* 修改人id
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
private SysDeptVO dept;
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user