Skip to content

Commit

Permalink
style: 完善部分代码格式
Browse files Browse the repository at this point in the history
  • Loading branch information
lerry903 committed May 1, 2019
1 parent cc02ae6 commit b9ac442
Show file tree
Hide file tree
Showing 59 changed files with 263 additions and 387 deletions.
21 changes: 12 additions & 9 deletions ruoyi-common/src/main/java/com/ruoyi/common/base/AjaxResult.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.ruoyi.common.base;

import cn.hutool.core.util.ObjectUtil;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.HashMap;
import java.util.Objects;
Expand Down Expand Up @@ -51,7 +49,7 @@ public int value() {
/**
* 状态类型
*/
private Type type;
private transient Type type;

/**
* 状态码
Expand All @@ -66,7 +64,7 @@ public int value() {
/**
* 数据对象
*/
private Object data;
private transient Object data;


/**
Expand Down Expand Up @@ -164,7 +162,7 @@ public static AjaxResult warn(String msg, Object data) {
/**
* 返回错误消息
*
* @return
* @return 默认错误信息
*/
public static AjaxResult error() {
return AjaxResult.error("操作失败");
Expand Down Expand Up @@ -192,9 +190,13 @@ public static AjaxResult error(String msg, Object data) {
}

@Override
public String toString(){
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("code", code)
.append("msg", msg).append("data", data).toString();
public String toString() {
return "AjaxResult{" +
"type=" + type +
", code=" + code +
", msg='" + msg + '\'' +
", data=" + data +
'}';
}

@Override
Expand All @@ -210,12 +212,13 @@ public boolean equals(Object o) {
}
AjaxResult that = (AjaxResult) o;
return code == that.code &&
type == that.type &&
Objects.equals(msg, that.msg) &&
Objects.equals(data, that.data);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), code, msg, data);
return Objects.hash(super.hashCode(), type, code, msg, data);
}
}
16 changes: 8 additions & 8 deletions ruoyi-common/src/main/java/com/ruoyi/common/config/Global.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ruoyi.common.config;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.StringUtil;
import com.ruoyi.common.utils.YamlUtil;
import lombok.extern.slf4j.Slf4j;

Expand Down Expand Up @@ -58,7 +58,7 @@ private static String getConfig(String key) {
try {
yamlMap = YamlUtil.loadYaml(NAME);
value = String.valueOf(YamlUtil.getProperty(yamlMap, key));
map.put(key, value != null ? value : StringUtils.EMPTY);
map.put(key, value != null ? value : StringUtil.EMPTY);
} catch (Exception e) {
log.error("获取全局配置异常 {}" , key);
}
Expand All @@ -70,14 +70,14 @@ private static String getConfig(String key) {
* 获取项目名称
*/
public static String getName() {
return StringUtils.nvl(getConfig("ruoyi.name"), "RuoYi");
return StringUtil.nvl(getConfig("ruoyi.name"), "RuoYi");
}

/**
* 获取项目版本
*/
public static String getVersion() {
return StringUtils.nvl(getConfig("ruoyi.version"), "3.3.0");
return StringUtil.nvl(getConfig("ruoyi.version"), "3.3.0");
}

/**
Expand Down Expand Up @@ -127,27 +127,27 @@ public static String getUploadPath(){
* 获取作者
*/
public static String getAuthor() {
return StringUtils.nvl(getConfig("gen.author"), "ruoyi");
return StringUtil.nvl(getConfig("gen.author"), "ruoyi");
}

/**
* 生成包路径
*/
public static String getPackageName() {
return StringUtils.nvl(getConfig("gen.packageName"), "com.ruoyi.project.module");
return StringUtil.nvl(getConfig("gen.packageName"), "com.ruoyi.project.module");
}

/**
* 是否自动去除表前缀
*/
public static String getAutoRemovePre() {
return StringUtils.nvl(getConfig("gen.autoRemovePre"), "true");
return StringUtil.nvl(getConfig("gen.autoRemovePre"), "true");
}

/**
* 表前缀(类名不会包含表前缀)
*/
public static String getTablePrefix() {
return StringUtils.nvl(getConfig("gen.tablePrefix"), "sys_");
return StringUtil.nvl(getConfig("gen.tablePrefix"), "sys_");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,68 +45,68 @@ private UserConstants(){
/**
* 登录名称是否唯一的返回结果码
*/
public final static String USER_NAME_UNIQUE = "0" ;
public final static String USER_NAME_NOT_UNIQUE = "1" ;
public static final String USER_NAME_UNIQUE = "0" ;
public static final String USER_NAME_NOT_UNIQUE = "1" ;

/**
* 手机号码是否唯一的返回结果
*/
public final static String USER_PHONE_UNIQUE = "0" ;
public final static String USER_PHONE_NOT_UNIQUE = "1" ;
public static final String USER_PHONE_UNIQUE = "0" ;
public static final String USER_PHONE_NOT_UNIQUE = "1" ;

/**
* e-mail 是否唯一的返回结果
*/
public final static String USER_EMAIL_UNIQUE = "0" ;
public final static String USER_EMAIL_NOT_UNIQUE = "1" ;
public static final String USER_EMAIL_UNIQUE = "0" ;
public static final String USER_EMAIL_NOT_UNIQUE = "1" ;

/**
* 部门名称是否唯一的返回结果码
*/
public final static String DEPT_NAME_UNIQUE = "0" ;
public final static String DEPT_NAME_NOT_UNIQUE = "1" ;
public static final String DEPT_NAME_UNIQUE = "0" ;
public static final String DEPT_NAME_NOT_UNIQUE = "1" ;

/**
* 角色名称是否唯一的返回结果码
*/
public final static String ROLE_NAME_UNIQUE = "0" ;
public final static String ROLE_NAME_NOT_UNIQUE = "1" ;
public static final String ROLE_NAME_UNIQUE = "0" ;
public static final String ROLE_NAME_NOT_UNIQUE = "1" ;

/**
* 岗位名称是否唯一的返回结果码
*/
public final static String POST_NAME_UNIQUE = "0" ;
public final static String POST_NAME_NOT_UNIQUE = "1" ;
public static final String POST_NAME_UNIQUE = "0" ;
public static final String POST_NAME_NOT_UNIQUE = "1" ;

/**
* 角色权限是否唯一的返回结果码
*/
public final static String ROLE_KEY_UNIQUE = "0" ;
public final static String ROLE_KEY_NOT_UNIQUE = "1" ;
public static final String ROLE_KEY_UNIQUE = "0" ;
public static final String ROLE_KEY_NOT_UNIQUE = "1" ;

/**
* 岗位编码是否唯一的返回结果码
*/
public final static String POST_CODE_UNIQUE = "0" ;
public final static String POST_CODE_NOT_UNIQUE = "1" ;
public static final String POST_CODE_UNIQUE = "0" ;
public static final String POST_CODE_NOT_UNIQUE = "1" ;

/**
* 菜单名称是否唯一的返回结果码
*/
public final static String MENU_NAME_UNIQUE = "0" ;
public final static String MENU_NAME_NOT_UNIQUE = "1" ;
public static final String MENU_NAME_UNIQUE = "0" ;
public static final String MENU_NAME_NOT_UNIQUE = "1" ;

/**
* 字典类型是否唯一的返回结果码
*/
public final static String DICT_TYPE_UNIQUE = "0" ;
public final static String DICT_TYPE_NOT_UNIQUE = "1" ;
public static final String DICT_TYPE_UNIQUE = "0" ;
public static final String DICT_TYPE_NOT_UNIQUE = "1" ;

/**
* 参数键名是否唯一的返回结果码
*/
public final static String CONFIG_KEY_UNIQUE = "0" ;
public final static String CONFIG_KEY_NOT_UNIQUE = "1" ;
public static final String CONFIG_KEY_UNIQUE = "0" ;
public static final String CONFIG_KEY_NOT_UNIQUE = "1" ;

/**
* 密码长度限制
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public enum OnlineStatus {
/**
* 用户状态
*/
on_line("在线"), off_line("离线");
ON_LINE("在线"), OFF_LINE("离线");

private final String info;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
public class DemoModeException extends RuntimeException {
private static final long serialVersionUID = 1L;

public DemoModeException() {
}

@Override
public String getMessage(){
return "演示模式,禁止操作";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ruoyi.common.exception.base;

import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.StringUtil;

/**
* 基础异常
Expand All @@ -14,22 +14,22 @@ public class BaseException extends RuntimeException {
/**
* 所属模块
*/
private String module;
private final String module;

/**
* 错误码
*/
private String code;
private final String code;

/**
* 错误码对应的参数
*/
private Object[] args;
private final transient Object[] args;

/**
* 错误消息
*/
private String defaultMessage;
private final String defaultMessage;

public BaseException(String module, String code, Object[] args, String defaultMessage) {
this.module = module;
Expand Down Expand Up @@ -57,7 +57,7 @@ public BaseException(String defaultMessage) {
@Override
public String getMessage() {
String message = null;
if (!StringUtils.isEmpty(code)) {
if (!StringUtil.isEmpty(code)) {
message = MessageUtils.message(code, args);
}
if (message == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
public class InvalidExtensionException extends FileUploadException {
private static final long serialVersionUID = 1L;

private String[] allowedExtension;
private String extension;
private String filename;
private final String[] allowedExtension;
private final String extension;
private final String filename;

public InvalidExtensionException(String[] allowedExtension, String extension, String filename) {
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.ruoyi.common.exception.user;

import com.ruoyi.common.exception.base.BaseException;

/**
* 验证码错误异常类
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.ruoyi.common.exception.user;

import com.ruoyi.common.exception.base.BaseException;

/**
* 角色锁定异常类
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.ruoyi.common.exception.user;

import com.ruoyi.common.exception.base.BaseException;

/**
* 用户不存在异常类
*
Expand Down
Loading

0 comments on commit b9ac442

Please sign in to comment.