feat 调整role,admin 保持和其他语言一样的DB结构和逻辑

feat 调整错误和正确信息返回的格式问题
This commit is contained in:
damonyuan
2024-08-30 00:51:21 +08:00
parent 7badc8ae0f
commit 54d5dbd5b8
50 changed files with 1191 additions and 1202 deletions

View File

@@ -17,6 +17,9 @@ public class AjaxResult<T> {
/** 响应数据 **/
private T data;
/** 是否显示错误信息 **/
private Integer show;
/** 无参构造 **/
protected AjaxResult() {}
@@ -28,10 +31,11 @@ public class AjaxResult<T> {
* @param msg 提示信息
* @param data 响应数据
*/
public AjaxResult(Integer code, String msg, T data) {
public AjaxResult(Integer code, String msg, T data, Integer show) {
this.code = code;
this.msg = msg;
this.data = data;
this.show = show;
}
/**
@@ -41,7 +45,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static AjaxResult<Object> success() {
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), new ArrayList<>());
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), new ArrayList<>(), ErrorEnum.HIDE_MSG.getCode());
}
/**
@@ -52,7 +56,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static AjaxResult<Object> success(Integer code) {
return new AjaxResult<>(code, ErrorEnum.SUCCESS.getMsg(), new ArrayList<>());
return new AjaxResult<>(code, ErrorEnum.SUCCESS.getMsg(), new ArrayList<>(), ErrorEnum.HIDE_MSG.getCode());
}
/**
@@ -63,7 +67,18 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static AjaxResult<Object> success(String msg) {
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, new ArrayList<>());
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
}
/**
* 成功返回结果
*
* @author fzr
* @param msg 提示信息
* @return AjaxResult
*/
public static AjaxResult<Object> success(String msg, Integer show) {
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, new ArrayList<>(), show);
}
/**
@@ -74,7 +89,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static <T> AjaxResult<T> success(T data) {
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), data);
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), ErrorEnum.SUCCESS.getMsg(), data, ErrorEnum.HIDE_MSG.getCode());
}
/**
@@ -86,7 +101,19 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static AjaxResult<Object> success(Integer code, String msg) {
return new AjaxResult<>(code, msg, new ArrayList<>());
return new AjaxResult<>(code, msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
}
/**
* 成功返回结果
*
* @author fzr
* @param code 状态码
* @param msg 提示信息
* @return AjaxResult
*/
public static AjaxResult<Object> success(Integer code, String msg, Integer show) {
return new AjaxResult<>(code, msg, new ArrayList<>(), show);
}
/**
@@ -98,7 +125,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static <T> AjaxResult <T> success(String msg, T data) {
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, data);
return new AjaxResult<>(ErrorEnum.SUCCESS.getCode(), msg, data, ErrorEnum.SHOW_MSG.getCode());
}
/**
@@ -111,7 +138,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static <T> AjaxResult<T> success(Integer code, String msg, T data) {
return new AjaxResult<>(code, msg, data);
return new AjaxResult<>(code, msg, data, ErrorEnum.SHOW_MSG.getCode());
}
/**
@@ -122,7 +149,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static AjaxResult<Object> failed(Integer code) {
return new AjaxResult<>(code, ErrorEnum.FAILED.getMsg(), new ArrayList<>());
return new AjaxResult<>(code, ErrorEnum.FAILED.getMsg(), new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
}
/**
@@ -133,7 +160,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static AjaxResult<Object> failed(String msg) {
return new AjaxResult<>(ErrorEnum.FAILED.getCode(), msg, new ArrayList<>());
return new AjaxResult<>(ErrorEnum.FAILED.getCode(), msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
}
/**
@@ -144,7 +171,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static <T> AjaxResult<T> failed(T data) {
return new AjaxResult<T>(ErrorEnum.FAILED.getCode(), ErrorEnum.FAILED.getMsg(), data);
return new AjaxResult<T>(ErrorEnum.FAILED.getCode(), ErrorEnum.FAILED.getMsg(), data, ErrorEnum.SHOW_MSG.getCode());
}
/**
@@ -156,7 +183,7 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static AjaxResult<Object> failed(Integer code, String msg) {
return new AjaxResult<>(code, msg, new ArrayList<>());
return new AjaxResult<>(code, msg, new ArrayList<>(), ErrorEnum.SHOW_MSG.getCode());
}
/**
@@ -169,7 +196,19 @@ public class AjaxResult<T> {
* @return AjaxResult
*/
public static <T> AjaxResult<T> failed(Integer code, String msg, T data) {
return new AjaxResult<>(code, msg, data);
return new AjaxResult<>(code, msg, data, ErrorEnum.SHOW_MSG.getCode());
}
/**
* 响应失败结果
*
* @author fzr
* @param code 状态码
* @param msg 提示信息
* @param data 响应数据
* @return AjaxResult
*/
public static <T> AjaxResult<T> failed(Integer code, String msg, T data, Integer show) {
return new AjaxResult<>(code, msg, data, show);
}
}

View File

@@ -1,4 +1,4 @@
package com.mdd.common.entity.system;
package com.mdd.common.entity.admin;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -10,7 +10,7 @@ import java.io.Serializable;
@Data
@ApiModel("系统管理员实体")
public class SystemAuthAdmin implements Serializable {
public class Admin implements Serializable {
private static final long serialVersionUID = 1L;
@@ -18,47 +18,32 @@ public class SystemAuthAdmin implements Serializable {
@ApiModelProperty("ID")
private Integer id;
@ApiModelProperty("是否超级管理员 0-否 1-是")
private Integer root;
@ApiModelProperty("用户账号")
private String nickname;
@ApiModelProperty("用户昵称")
private String username;
@ApiModelProperty("用户密码")
private String password;
private String name;
@ApiModelProperty("用户头像")
private String avatar;
@ApiModelProperty("加密盐巴")
private String salt;
@ApiModelProperty("用户昵称")
private String account;
@ApiModelProperty("角色主键")
private String roleIds;
@ApiModelProperty("部门主键")
private String deptIds;
@ApiModelProperty("岗位主键")
private String postIds;
@ApiModelProperty("排序编号")
private Integer sort;
@ApiModelProperty("用户密码")
private String password;
@ApiModelProperty("多端登录: [0=否, 1=是]")
private Integer isMultipoint;
private Integer multipointLogin;
@ApiModelProperty("是否禁用: [0=否, 1=是]")
private Integer isDisable;
@ApiModelProperty("是否删除: [0=否, 1=是]")
private Integer isDelete;
private Integer disable;
@ApiModelProperty("最后登录IP")
private String lastLoginIp;
private String loginIp;
@ApiModelProperty("最后登录时间")
private Long lastLoginTime;
private Long loginTime;
@ApiModelProperty("创建时间")
private Long createTime;

View File

@@ -0,0 +1,24 @@
package com.mdd.common.entity.admin;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("角色关联表实体")
public class AdminRole implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("管理员id")
private Integer adminId;
@ApiModelProperty("角色id")
private Integer roleId;
}

View File

@@ -10,7 +10,7 @@ import java.io.Serializable;
@Data
@ApiModel("系统角色实体")
public class SystemAuthRole implements Serializable {
public class SystemRole implements Serializable {
private static final long serialVersionUID = 1L;
@@ -21,19 +21,18 @@ public class SystemAuthRole implements Serializable {
@ApiModelProperty("角色名称")
private String name;
@ApiModelProperty("备注信息")
private String remark;
@ApiModelProperty("描述")
private String desc;
@ApiModelProperty("角色排序")
private Integer sort;
@ApiModelProperty("是否禁用: [0=否, 1=是]")
private Integer isDisable;
@ApiModelProperty("创建时间")
private Long createTime;
@ApiModelProperty("更新时间")
private Long updateTime;
private Long updateTime;
@ApiModelProperty("删除时间")
private Long deleteTime;
}

View File

@@ -2,8 +2,10 @@ package com.mdd.common.enums;
public enum ErrorEnum {
SUCCESS(200, "成功"),
FAILED(300, "失败"),
SHOW_MSG(1, "显示信息"),
HIDE_MSG(0, "隐藏信息"),
SUCCESS(1, "成功"),
FAILED(0, "失败"),
PARAMS_VALID_ERROR(310, "参数校验错误"),
PARAMS_TYPE_ERROR(311, "参数类型错误"),
REQUEST_METHOD_ERROR(312, "请求方法错误"),

View File

@@ -12,10 +12,11 @@ public class BaseException extends RuntimeException {
private Integer code;
private String msg;
private Integer show;
public BaseException(Integer code, String msg) {
public BaseException(Integer code, String msg, Integer show) {
this.code = code;
this.msg = msg;
this.show = show;
}
}

View File

@@ -57,6 +57,7 @@ public class GlobalException {
public AjaxResult<Object> handleException(BaseException e) {
int code = e.getCode();
String msg = e.getMsg();
int show = e.getShow();
return AjaxResult.failed(code, msg);
}

View File

@@ -1,12 +1,18 @@
package com.mdd.common.exception;
import com.mdd.common.enums.ErrorEnum;
/**
* 登录异常类
*/
public class LoginException extends BaseException {
public LoginException(Integer code, String msg) {
super(code, msg);
super(code, msg, ErrorEnum.SHOW_MSG.getCode());
}
public LoginException(Integer code, String msg, Integer show) {
super(code, msg, show);
}
}

View File

@@ -8,11 +8,11 @@ import com.mdd.common.enums.ErrorEnum;
public class OperateException extends BaseException {
public OperateException(String msg) {
super(ErrorEnum.FAILED.getCode(), msg);
super(ErrorEnum.FAILED.getCode(), msg, ErrorEnum.SHOW_MSG.getCode());
}
public OperateException(String msg, Integer errCode) {
super(errCode, msg);
super(errCode, msg, ErrorEnum.SHOW_MSG.getCode());
}
}

View File

@@ -8,11 +8,11 @@ import com.mdd.common.enums.ErrorEnum;
public class PaymentException extends BaseException {
public PaymentException(String msg) {
super(ErrorEnum.PAYMENT_ERROR.getCode(), msg);
super(ErrorEnum.FAILED.getCode(), msg, ErrorEnum.SHOW_MSG.getCode());
}
public PaymentException(String msg, Integer errCode) {
super(errCode, msg);
super(errCode, msg, ErrorEnum.SHOW_MSG.getCode());
}
}

View File

@@ -0,0 +1,16 @@
package com.mdd.common.mapper.admin;
import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.admin.Admin;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 系统管理员Mapper
*/
@Mapper
public interface AdminMapper extends IBaseMapper<Admin> {
}

View File

@@ -0,0 +1,14 @@
package com.mdd.common.mapper.admin;
import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.admin.Admin;
import com.mdd.common.entity.admin.AdminRole;
import org.apache.ibatis.annotations.Mapper;
/**
* 角色关联表Mapper
*/
@Mapper
public interface AdminRoleMapper extends IBaseMapper<AdminRole> {
}

View File

@@ -1,26 +0,0 @@
package com.mdd.common.mapper.system;
import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.system.SystemAuthAdmin;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 系统管理员Mapper
*/
@Mapper
public interface SystemAuthAdminMapper extends IBaseMapper<SystemAuthAdmin> {
/**
* 获取角色管理员
*
* @author fzr
* @param id 文件夹ID
* @return List<Integer>
*/
@Select("SELECT id FROM ${prefix}system_auth_admin WHERE is_delete=0 AND FIND_IN_SET(#{id}, role_ids)")
List<Integer> selectChildrenById(Integer id);
}

View File

@@ -1,12 +1,12 @@
package com.mdd.common.mapper.system;
import com.mdd.common.core.basics.IBaseMapper;
import com.mdd.common.entity.system.SystemAuthRole;
import com.mdd.common.entity.system.SystemRole;
import org.apache.ibatis.annotations.Mapper;
/**
* 系统角色Mapper
*/
@Mapper
public interface SystemAuthRoleMapper extends IBaseMapper<SystemAuthRole> {
public interface SystemRoleMapper extends IBaseMapper<SystemRole> {
}

View File

@@ -47,6 +47,19 @@ public class ToolUtils {
return "";
}
/**
* 制作MD5
*
* @author fzr
* @param data 需加密的数据
* @return String
*/
public static String makePassword(String password){
String newPWd = password + YmlUtils.get("like.unique-identification");
String md5Pwd = ToolUtils.makeMd5(ToolUtils.makeMd5(newPWd));
return md5Pwd;
}
/**
* 生成唯一Token
*