准备开始迁移管理员相关模块

This commit is contained in:
YunaiV 2020-07-04 10:29:25 +08:00
parent 20d8db6ce8
commit ee6fa2b805
27 changed files with 71 additions and 401 deletions

View File

@ -1,9 +1,12 @@
package cn.iocoder.mall.system.biz.enums.admin;
package cn.iocoder.mall.systemservice.enums.admin;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* 管理员的状态枚举
*/
public enum AdminStatusEnum implements IntArrayValuable {
ACTIVE(1, "在职"),

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.enums.authorization;
package cn.iocoder.mall.systemservice.enums.permission;
/**
* Resource 编号枚举

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.enums.authorization;
package cn.iocoder.mall.systemservice.enums.permission;
import cn.iocoder.common.framework.core.IntArrayValuable;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.enums.authorization;
package cn.iocoder.mall.systemservice.enums.permission;
public enum RoleCodeEnum {

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.enums.authorization;
package cn.iocoder.mall.systemservice.enums.permission;
public enum RoleTypeEnum {

View File

@ -1,8 +1,7 @@
package cn.iocoder.mall.system.biz.dataobject.admin;
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.dataobject.account.AccountDO;
import cn.iocoder.mall.system.biz.enums.admin.AdminStatusEnum;
import cn.iocoder.mall.mybatis.dataobject.BaseDO;
import cn.iocoder.mall.systemservice.enums.admin.AdminStatusEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -15,18 +14,12 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AdminDO extends DeletableDO {
public class AdminDO extends BaseDO {
/**
* 管理员编号
*/
private Integer id;
/**
* 账号编号
*
* 关联 {@link AccountDO#getId()}
*/
private Integer accountId;
/**
* 真实名字
*/
@ -44,4 +37,17 @@ public class AdminDO extends DeletableDO {
*/
private Integer status;
/**
* 登陆账号
*/
private String username;
/**
* 经过加密的密码串
*/
private String password;
/**
* {@link #password} 的盐
*/
private String passwordSalt;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.dataobject.admin;
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
@ -29,6 +29,8 @@ public class DepartmentDO extends DeletableDO {
private Integer sort;
/**
* 父级部门编号
*
* 外键 {@link #id}
*/
private Integer pid;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.dataobject.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.dataobject.account.AccountDO;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.dataobject.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.enums.authorization.ResourceTypeEnum;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.dataobject.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.enums.authorization.RoleCodeEnum;

View File

@ -1,4 +1,4 @@
package cn.iocoder.mall.system.biz.dataobject.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;

View File

@ -0,0 +1,23 @@
package cn.iocoder.mall.systemservice.dal.mysql.mapper.admin;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.admin.AdminDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface AdminMapper extends BaseMapper<AdminDO> {
default AdminDO selectByUsername(String username) {
return selectOne(new QueryWrapper<AdminDO>()
.eq("username", username)
);
}
// default IPage<AdminDO> selectPage(AdminPageDTO adminPageDTO) {
// return selectPage(new Page<>(adminPageDTO.getPageNo(), adminPageDTO.getPageSize()),
// new QueryWrapperX<AdminDO>().likeIfPresent("name", adminPageDTO.getName())
// .eqIfPresent("department_id", adminPageDTO.getDepartmentId()));
// }
}

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.system.biz.dao.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.system.biz.dataobject.authorization.AccountRoleDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.AccountRoleDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@ -12,7 +12,7 @@ import java.util.List;
@Repository
public interface AccountRoleMapper extends BaseMapper<AccountRoleDO> {
default List<AccountRoleDO> selectByAccountId( Integer accountId) {
default List<AccountRoleDO> selectByAccountId(Integer accountId) {
return selectList(new QueryWrapper<AccountRoleDO>().eq("account_id", accountId));
}

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.system.biz.dao.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.mybatis.query.QueryWrapperX;
import cn.iocoder.mall.system.biz.dataobject.authorization.ResourceDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.ResourceDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

View File

@ -1,11 +1,8 @@
package cn.iocoder.mall.system.biz.dao.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.mybatis.query.QueryWrapperX;
import cn.iocoder.mall.system.biz.dataobject.authorization.RoleDO;
import cn.iocoder.mall.system.biz.dto.authorization.RolePageDTO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
import java.util.Collection;
@ -14,10 +11,10 @@ import java.util.List;
@Repository
public interface RoleMapper extends BaseMapper<RoleDO> {
default IPage<RoleDO> selectPage(RolePageDTO rolePageDTO) {
return selectPage(new Page<>(rolePageDTO.getPageNo(), rolePageDTO.getPageSize()),
new QueryWrapperX<RoleDO>().likeIfPresent("name", rolePageDTO.getName()));
}
// default IPage<RoleDO> selectPage(RolePageDTO rolePageDTO) {
// return selectPage(new Page<>(rolePageDTO.getPageNo(), rolePageDTO.getPageSize()),
// new QueryWrapperX<RoleDO>().likeIfPresent("name", rolePageDTO.getName()));
// }
default List<RoleDO> selectListByIds(Collection<Integer> ids) {
return selectList(new QueryWrapperX<RoleDO>().inIfPresent("id", ids));

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.system.biz.dao.authorization;
package cn.iocoder.mall.systemservice.dal.mysql.mapper.permission;
import cn.iocoder.mall.system.biz.dataobject.authorization.RoleResourceDO;
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleResourceDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.system.biz.dao.authorization.AccountRoleMapper">
<mapper namespace="cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.AccountRoleMapper">
<insert id="insertList">
INSERT INTO account_role (

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.system.biz.dao.authorization.RoleResourceMapper">
<mapper namespace="cn.iocoder.mall.systemservice.dal.mysql.mapper.permission.RoleResourceMapper">
<insert id="insertList">
INSERT INTO role_resource (

View File

@ -1,128 +0,0 @@
package cn.iocoder.mall.system.biz.enums;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
/**
* 错误码枚举类
*
* system 系统使用 1-002-000-000
*/
public enum SystemErrorCodeEnum implements ServiceExceptionUtil.Enumerable<SystemErrorCodeEnum> {
// ========== OAUTH2 模块 ==========
OAUTH2_UNKNOWN(1001001000, "未知错误"), // 预留
// 预留 1001001001 ~ 1001001099 错误码方便前端
OAUTH2_ACCESS_TOKEN_NOT_FOUND(1001001001, "访问令牌不存在"),
OAUTH2_ACCESS_TOKEN_TOKEN_EXPIRED(1001001002, "访问令牌已过期"),
OAUTH2_ACCESS_TOKEN_INVALID(1001001003, "访问令牌已失效"),
OAUTH2_NOT_AUTHENTICATE(1001001004, "账号未登陆"),
OAUTH2_REFRESH_TOKEN_NOT_FOUND(1001001005, "刷新令牌不存在"),
OAUTH_REFRESH_TOKEN_EXPIRED(1001001006, "访问令牌已过期"),
OAUTH_REFRESH_TOKEN_INVALID(1001001007, "刷新令牌已失效"),
// 其它 1001001100 开始
OAUTH2_ACCOUNT_NOT_FOUND(1001001100, "账号不存在"),
OAUTH2_ACCOUNT_PASSWORD_ERROR(1001001101, "密码不正确"),
// ========== OAuth 手机验证码模块 ==========
OAUTH2_MOBILE_CODE_NOT_FOUND(1001001200, "验证码不存在"),
OAUTH2_MOBILE_CODE_EXPIRED(1001001201, "验证码已过期"),
OAUTH2_MOBILE_CODE_USED(1001001202, "验证码已使用"),
OAUTH2_MOBILE_CODE_NOT_CORRECT(1001001203, "验证码不正确"),
OAUTH2_MOBILE_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY(1001001204, "超过每日短信发送数量"),
OAUTH2_MOBILE_CODE_SEND_TOO_FAST(1001001205, "短信发送过于频率"),
// ========== 管理员模块 1002002000 ==========
ADMIN_NOT_FOUND(1002002000, "管理员不存在"),
// 废弃 ADMIN_USERNAME_NOT_REGISTERED(1002002000, "账号不存在"),
// 废弃 ADMIN_PASSWORD_ERROR(1002002001, "密码不正确"),
// ADMIN_IS_DISABLE(1002002002, "账号被禁用"),
// ADMIN_USERNAME_EXISTS(1002002002, "账号已经存在"),
// ADMIN_STATUS_EQUALS(1002002003, "账号已经是该状态"),
// ADMIN_DELETE_ONLY_DISABLE(1002002004, "只有关闭的账号才可以删除"),
// ADMIN_ADMIN_STATUS_CAN_NOT_UPDATE(1002002005, "管理员的账号状态不允许变更"),
// ADMIN_ASSIGN_ROLE_NOT_EXISTS(1002002006, "分配员工角色时,有角色不存在"),
// ADMIN_ADMIN_CAN_NOT_UPDATE(1002002008, "管理员的账号不允许变更"),
// ========== 资源模块 1002003000 ==========
RESOURCE_NAME_DUPLICATE(1002003000, "已经存在该名字的资源"),
RESOURCE_PARENT_NOT_EXISTS(1002003001, "父资源不存在"),
RESOURCE_PARENT_ERROR(1002003002, "不能设置自己为父资源"),
RESOURCE_NOT_EXISTS(1002003003, "资源不存在"),
RESOURCE_EXISTS_CHILDREN(1002003004, "存在子资源,无法删除"),
RESOURCE_PARENT_NOT_MENU(1002003005, "父资源的类型必须是菜单"),
// ========== 角色模块 1002004000 ==========
ROLE_NOT_EXISTS(1002004000, "角色不存在"),
ROLE_NAME_DUPLICATE(1002004001, "已经存在名为【{}}】的角色"),
ROLE_CODE_DUPLICATE(1002004002, "已经存在编码为【{}}】的角色"),
ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE(1002004004, "不能修改类型为系统内置的角色"),
ROLE_CAN_NOT_DELETE_SYSTEM_TYPE_ROLE(1002004005, "不能删除类型为系统内置的角色"),
// ========== 数据字典模块 1002005000 ==========
// DATA_DICT_EXISTS(1002005000, "该数据字典已经存在"),
// DATA_DICT_NOT_EXISTS(1002005001, "该数据字典不存在"),
// ========== 短信模板 1002006000 ==========
SMS_PLATFORM_FAIL(1002006000, "短信平台调用失败【具体错误会动态替换】"),
SMS_SIGN_NOT_EXISTENT(1002006001, "短信签名不存在"),
SMS_SIGN_IS_EXISTENT(1002006002, "短信签名已存在"),
SMS_TEMPLATE_NOT_EXISTENT(1002006020, "短信签名不存在"),
SMS_TEMPLATE_IS_EXISTENT(1002006021, "短信签名不存在"),
SMS_NOT_SEND_CLIENT(1002006030, "短信没有发送的client"),
// ========== 部门模块 1002007000 ==========
// DEPT_SAME_LEVEL_NAME_EXITS(1002007001,"当前级别部门名字已存在"),
// DEPT_PARENT_NOT_EXITS(1002007002,"父级部门不存在"),
// DEPT_NOT_EXITS(1002007003, "当前部门不存在"),
// DEPT_EXITS_CHILDREN(1002007004, "当前部门存在子部门"),
// DEPT_PARENT_NOT_LEGAL(1002007005, "父级部门不合法"),
// ========== 授权模块 1002008000 ==========
AUTHORIZATION_PERMISSION_DENY(1002008001, "没有该操作权限"),
AUTHORIZATION_DEMO_PERMISSION_DENY(1002008002, "演示账号暂不允许写操作。欢迎加入我们的交流群http://t.cn/EKEr5WE"),
AUTHORIZATION_ROLE_ASSIGN_RESOURCE_NOT_EXISTS(1002004001, "分配角色资源时,有资源不存在"),
// ========== 用户地址 ==========
USER_ADDRESS_NOT_EXISTENT(1001004000, "用户地址不存在!"),
USER_ADDRESS_IS_DELETED(1001004001, "用户地址已被删除!"),
USER_GET_ADDRESS_NOT_EXISTS(1001004002, "获取的地址不存在!"),
// ========== 用户信息模块 1004004100 ==========
USER_NOT_EXISTS(1004004100, "用户不存在"),
USER_STATUS_NOT_EXISTS(1004004101, "用户状态不存在"),
USER_STATUS_EQUALS(1004004101, "用户已经是该状态"),
// ========== 错误码模块 1002009000 ==========
ERROR_CODE_NOT_EXISTS(1002009000, "错误码不存在"),
ERROR_CODE_DUPLICATE(1002009001, "已经存在编码为【{}}】的错误码"),
ERROR_CAN_NOT_UPDATE_SYSTEM_TYPE_ERROR(1002004003, "不能修改类型为系统内置的错误码"),
;
private final int code;
private final String message;
SystemErrorCodeEnum(int code, String message) {
this.code = code;
this.message = message;
}
@Override
public int getCode() {
return code;
}
@Override
public String getMessage() {
return message;
}
// TODO: 2020-05-22 封装成start的时候直接在start中定义一个统一的枚举从中取值
@Override
public int getGroup() {
return 0;
}
}

View File

@ -1,46 +0,0 @@
package cn.iocoder.mall.system.biz.enums.user;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* @Author: jiangweifan
* @Date: 2020/5/12
* @Description: 用户状态枚举
*/
public enum UserStatusEnum implements IntArrayValuable {
ENABLED(1, "启用"),
DISABLED(2, "禁用");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(UserStatusEnum::getStatus).toArray();
/**
* 状态
*/
private final Integer status;
/**
* 描述
*/
private final String name;
UserStatusEnum(Integer status, String name) {
this.status = status;
this.name = name;
}
public Integer getStatus() {
return status;
}
public String getName() {
return name;
}
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.mall.system.biz.dao.account;
import cn.iocoder.mall.system.biz.dataobject.account.AccountDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface AccountMapper extends BaseMapper<AccountDO> {
default AccountDO selectByUsername(String username) {
return selectOne(new QueryWrapper<AccountDO>()
.eq("username", username)
);
}
default AccountDO selectByMobile(String mobile) {
return selectOne(new QueryWrapper<AccountDO>()
.eq("mobile", mobile)
);
}
}

View File

@ -1,27 +0,0 @@
package cn.iocoder.mall.system.biz.dao.admin;
import cn.iocoder.mall.mybatis.query.QueryWrapperX;
import cn.iocoder.mall.system.biz.dataobject.admin.AdminDO;
import cn.iocoder.mall.system.biz.dto.admin.AdminPageDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
@Repository
public interface AdminMapper extends BaseMapper<AdminDO> {
default AdminDO selectByAccountId(Integer accountId) {
return selectOne(new QueryWrapper<AdminDO>()
.eq("account_id", accountId)
);
}
default IPage<AdminDO> selectPage(AdminPageDTO adminPageDTO) {
return selectPage(new Page<>(adminPageDTO.getPageNo(), adminPageDTO.getPageSize()),
new QueryWrapperX<AdminDO>().likeIfPresent("name", adminPageDTO.getName())
.eqIfPresent("department_id", adminPageDTO.getDepartmentId()));
}
}

View File

@ -1,67 +0,0 @@
package cn.iocoder.mall.system.biz.dataobject.account;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 账号实体
*/
@TableName(value = "account")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class AccountDO extends DeletableDO {
/**
* 账号编号
*/
private Integer id;
/**
* 登陆账号
*/
private String username;
/**
* 手机号
*/
private String mobile;
/**
* 邮箱
*/
private String email;
/**
* 密码
*
* // TODO 芋艿 暂时明文
*/
private String password;
/**
* 账号状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
/**
* 创建 IP
*/
private String createIp;
/**
* 最后登陆时间
*/
private Date lastLoginTime;
/**
* 最后登陆 IP
*/
private String lastLoginIp;
/**
* 登陆次数
*/
private Integer loginTimes;
}

View File

@ -1,48 +0,0 @@
package cn.iocoder.mall.system.biz.dataobject.user;
import cn.iocoder.mall.mybatis.dataobject.DeletableDO;
import cn.iocoder.mall.system.biz.dataobject.account.AccountDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* 用户实体
*/
@TableName(value = "users")
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@Deprecated
public class UserDO extends DeletableDO {
/**
* 用户编号
*/
private Integer id;
/**
* 账号编号
*
* 关联 {@link AccountDO#getId()}
*/
private Integer accountId;
/**
* 昵称
*/
private String nickname;
/**
* 手机
*/
private String mobile;
/**
* 头像
*/
private String avatar;
/**
* 用户状态 1 - 开启2 - 禁用
*/
private Integer status;
}

View File

@ -1,4 +0,0 @@
##################### 业务模块 #####################
## OAuth2Service
modules.oauth2-code-service.access-token-expire-time-millis = 2880000
modules.oauth2-code-service.refresh-token-expire-time-millis = 43200000

View File

@ -1,19 +0,0 @@
spring:
# 数据源配置项
datasource:
url: jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name: com.mysql.jdbc.Driver
username: root
password: 3WLiVUBEwTbvAfsh
# MyBatis Plus 配置项
mybatis-plus:
configuration:
map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。
global-config:
db-config:
id-type: auto
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
mapper-locations: classpath*:mapper/*.xml
type-aliases-package: cn.iocoder.mall.system.biz.dataobject

View File

@ -36,6 +36,7 @@ public class UserDO extends BaseDO {
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
/**
* 手机
*/