mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 匿名访问不鉴权注解
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Anonymous {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 数据权限过滤注解
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DataScope {
|
||||
/**
|
||||
* 部门表的别名
|
||||
*/
|
||||
public String deptAlias() default "";
|
||||
|
||||
/**
|
||||
* 用户表的别名
|
||||
*/
|
||||
public String userAlias() default "";
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import com.jsowell.common.enums.DataSourceType;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 自定义多数据源切换注解
|
||||
* <p>
|
||||
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
public @interface DataSource {
|
||||
/**
|
||||
* 切换数据源名称
|
||||
*/
|
||||
public DataSourceType value() default DataSourceType.MASTER;
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import com.jsowell.common.util.poi.ExcelHandlerAdapter;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 自定义导出Excel数据注解
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Excel {
|
||||
/**
|
||||
* 导出时在excel中排序
|
||||
*/
|
||||
public int sort() default Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 导出到Excel中的名字.
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 日期格式, 如: yyyy-MM-dd
|
||||
*/
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 如果是字典类型,请设置字典的type值 (如: sys_user_sex)
|
||||
*/
|
||||
public String dictType() default "";
|
||||
|
||||
/**
|
||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||
*/
|
||||
public String readConverterExp() default "";
|
||||
|
||||
/**
|
||||
* 分隔符,读取字符串组内容
|
||||
*/
|
||||
public String separator() default ",";
|
||||
|
||||
/**
|
||||
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化)
|
||||
*/
|
||||
public int scale() default -1;
|
||||
|
||||
/**
|
||||
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
|
||||
*/
|
||||
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的高度 单位为字符
|
||||
*/
|
||||
public double height() default 14;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的宽 单位为字符
|
||||
*/
|
||||
public double width() default 16;
|
||||
|
||||
/**
|
||||
* 文字后缀,如% 90 变成90%
|
||||
*/
|
||||
public String suffix() default "";
|
||||
|
||||
/**
|
||||
* 当值为空时,字段的默认值
|
||||
*/
|
||||
public String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
public String prompt() default "";
|
||||
|
||||
/**
|
||||
* 设置只能选择不能输入的列内容.
|
||||
*/
|
||||
public String[] combo() default {};
|
||||
|
||||
/**
|
||||
* 是否需要纵向合并单元格,应对需求:含有list集合单元格)
|
||||
*/
|
||||
public boolean needMerge() default false;
|
||||
|
||||
/**
|
||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||
*/
|
||||
public boolean isExport() default true;
|
||||
|
||||
/**
|
||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||
*/
|
||||
public String targetAttr() default "";
|
||||
|
||||
/**
|
||||
* 是否自动统计数据,在最后追加一行统计数据总和
|
||||
*/
|
||||
public boolean isStatistics() default false;
|
||||
|
||||
/**
|
||||
* 导出类型(0数字 1字符串 2图片)
|
||||
*/
|
||||
public ColumnType cellType() default ColumnType.STRING;
|
||||
|
||||
/**
|
||||
* 导出列头背景色
|
||||
*/
|
||||
public IndexedColors headerBackgroundColor() default IndexedColors.GREY_50_PERCENT;
|
||||
|
||||
/**
|
||||
* 导出列头字体颜色
|
||||
*/
|
||||
public IndexedColors headerColor() default IndexedColors.WHITE;
|
||||
|
||||
/**
|
||||
* 导出单元格背景色
|
||||
*/
|
||||
public IndexedColors backgroundColor() default IndexedColors.WHITE;
|
||||
|
||||
/**
|
||||
* 导出单元格字体颜色
|
||||
*/
|
||||
public IndexedColors color() default IndexedColors.BLACK;
|
||||
|
||||
/**
|
||||
* 导出字段对齐方式
|
||||
*/
|
||||
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器
|
||||
*/
|
||||
public Class<?> handler() default ExcelHandlerAdapter.class;
|
||||
|
||||
/**
|
||||
* 自定义数据处理器参数
|
||||
*/
|
||||
public String[] args() default {};
|
||||
|
||||
/**
|
||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||
*/
|
||||
Type type() default Type.ALL;
|
||||
|
||||
public enum Type {
|
||||
ALL(0), EXPORT(1), IMPORT(2);
|
||||
private final int value;
|
||||
|
||||
Type(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ColumnType {
|
||||
NUMERIC(0), STRING(1), IMAGE(2);
|
||||
private final int value;
|
||||
|
||||
ColumnType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel注解集
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels {
|
||||
public Excel[] value();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import com.jsowell.common.enums.BusinessType;
|
||||
import com.jsowell.common.enums.OperatorType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 自定义操作日志记录注解
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Target({ElementType.PARAMETER, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Log {
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
public String title() default "";
|
||||
|
||||
/**
|
||||
* 功能
|
||||
*/
|
||||
public BusinessType businessType() default BusinessType.OTHER;
|
||||
|
||||
/**
|
||||
* 操作人类别
|
||||
*/
|
||||
public OperatorType operatorType() default OperatorType.MANAGE;
|
||||
|
||||
/**
|
||||
* 是否保存请求的参数
|
||||
*/
|
||||
public boolean isSaveRequestData() default true;
|
||||
|
||||
/**
|
||||
* 是否保存响应的参数
|
||||
*/
|
||||
public boolean isSaveResponseData() default true;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.enums.LimitType;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 限流注解
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RateLimiter {
|
||||
/**
|
||||
* 限流key
|
||||
*/
|
||||
public String key() default CacheConstants.RATE_LIMIT_KEY;
|
||||
|
||||
/**
|
||||
* 限流时间,单位秒
|
||||
*/
|
||||
public int time() default 60;
|
||||
|
||||
/**
|
||||
* 限流次数
|
||||
*/
|
||||
public int count() default 100;
|
||||
|
||||
/**
|
||||
* 限流类型
|
||||
*/
|
||||
public LimitType limitType() default LimitType.DEFAULT;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jsowell.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 自定义注解防止表单重复提交
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Inherited
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RepeatSubmit {
|
||||
/**
|
||||
* 间隔时间(ms),小于此时间视为重复提交
|
||||
*/
|
||||
public int interval() default 5000;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
public String message() default "不允许重复提交,请稍候再试";
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.jsowell.common.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 读取项目相关配置
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "jsowell")
|
||||
public class JsowellConfig {
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 版权年份
|
||||
*/
|
||||
private String copyrightYear;
|
||||
|
||||
/**
|
||||
* 实例演示开关
|
||||
*/
|
||||
private boolean demoEnabled;
|
||||
|
||||
/**
|
||||
* 上传路径
|
||||
*/
|
||||
private static String profile;
|
||||
|
||||
/**
|
||||
* 获取地址开关
|
||||
*/
|
||||
private static boolean addressEnabled;
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
*/
|
||||
private static String captchaType;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getCopyrightYear() {
|
||||
return copyrightYear;
|
||||
}
|
||||
|
||||
public void setCopyrightYear(String copyrightYear) {
|
||||
this.copyrightYear = copyrightYear;
|
||||
}
|
||||
|
||||
public boolean isDemoEnabled() {
|
||||
return demoEnabled;
|
||||
}
|
||||
|
||||
public void setDemoEnabled(boolean demoEnabled) {
|
||||
this.demoEnabled = demoEnabled;
|
||||
}
|
||||
|
||||
public static String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile) {
|
||||
JsowellConfig.profile = profile;
|
||||
}
|
||||
|
||||
public static boolean isAddressEnabled() {
|
||||
return addressEnabled;
|
||||
}
|
||||
|
||||
public void setAddressEnabled(boolean addressEnabled) {
|
||||
JsowellConfig.addressEnabled = addressEnabled;
|
||||
}
|
||||
|
||||
public static String getCaptchaType() {
|
||||
return captchaType;
|
||||
}
|
||||
|
||||
public void setCaptchaType(String captchaType) {
|
||||
JsowellConfig.captchaType = captchaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入上传路径
|
||||
*/
|
||||
public static String getImportPath() {
|
||||
return getProfile() + "/import";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取头像上传路径
|
||||
*/
|
||||
public static String getAvatarPath() {
|
||||
return getProfile() + "/avatar";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载路径
|
||||
*/
|
||||
public static String getDownloadPath() {
|
||||
return getProfile() + "/download/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传路径
|
||||
*/
|
||||
public static String getUploadPath() {
|
||||
return getProfile() + "/upload";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.jsowell.common.constant;
|
||||
|
||||
/**
|
||||
* 缓存的key 常量
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class CacheConstants {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public static final int cache_expire_time_1m = 60;
|
||||
|
||||
public static final int cache_expire_time_5m = 60 * 5;
|
||||
|
||||
public static final int cache_expire_time_10m = 60 * 10;
|
||||
|
||||
public static final int cache_expire_time_1h = 60 * 60;
|
||||
|
||||
public static final int cache_expire_time_12h = 60 * 60 * 12;
|
||||
|
||||
public static final int cache_expire_time_1d = 60 * 60 * 24;
|
||||
|
||||
public static final String PILE_PROGRAM_VERSION = "pile_program_version";
|
||||
|
||||
/**
|
||||
* 通过订单号查询订单信息Key
|
||||
*/
|
||||
public static final String GET_ORDER_INFO_BY_ORDER_CODE = "get_order_info_by_order_code:";
|
||||
|
||||
/**
|
||||
* 充电枪口实时监控数据
|
||||
*/
|
||||
public static final String PILE_REAL_TIME_MONITOR_DATA = "pile_real_time_monitor_data:";
|
||||
|
||||
/**
|
||||
* 充电桩最后连接时间
|
||||
*/
|
||||
public static final String PILE_LAST_CONNECTION = "pile_last_connection:";
|
||||
|
||||
/**
|
||||
* 查询枪口信息列表前缀
|
||||
*/
|
||||
public static final String SELECT_PILE_CONNECTOR_INFO_LIST = "select_pile_connector_info_list:";
|
||||
|
||||
/**
|
||||
* 充电桩枪口状态前缀
|
||||
*/
|
||||
public static final String PILE_CONNECTOR_STATUS_KEY = "pile_connector_status:";
|
||||
|
||||
/**
|
||||
* 充电桩sn生成 key
|
||||
*/
|
||||
public static final String PILE_SN_GENERATE_KEY = "pile_sn_generate_";
|
||||
|
||||
/**
|
||||
* 充电桩详情key
|
||||
*/
|
||||
public static final String PILE_DETAIL_KEY = "pile_detail:";
|
||||
|
||||
/**
|
||||
* 登录用户 redis key
|
||||
*/
|
||||
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 防重提交 redis key
|
||||
*/
|
||||
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
|
||||
|
||||
/**
|
||||
* 限流 redis key
|
||||
*/
|
||||
public static final String RATE_LIMIT_KEY = "rate_limit:";
|
||||
|
||||
/**
|
||||
* 登录账户密码错误次数 redis key
|
||||
*/
|
||||
public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
|
||||
|
||||
/**
|
||||
* 验证码有效期时长 redis key
|
||||
*/
|
||||
public static final String SMS_VERIFICATION_CODE_KEY = "sms_verification_code:";
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.jsowell.common.constant;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
|
||||
/**
|
||||
* 通用常量信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class Constants {
|
||||
// 充电桩sn号长度
|
||||
public static final int PILE_SN_LENGTH = 14;
|
||||
|
||||
// 充电桩枪口号长度
|
||||
public static final int CONNECTOR_CODE_LENGTH = 2;
|
||||
|
||||
// 充电桩枪口编号长度
|
||||
public static final int PILE_CONNECTOR_CODE_LENGTH = PILE_SN_LENGTH + CONNECTOR_CODE_LENGTH;
|
||||
|
||||
public static final String SOCKET_IP = "127.0.0.1";
|
||||
public static final Integer SOCKET_PORT = 9011;
|
||||
|
||||
public static final String updateServerIP = "192.168.2.5";
|
||||
public static final int port = 0x15;
|
||||
|
||||
public static final byte[] updateServerPort = new byte[]{port};
|
||||
|
||||
public static final String updateServerUserName = "ftpuser";
|
||||
|
||||
public static final String updateServerPassword = "ftp123456";
|
||||
|
||||
public static final String filePath = "/pile/test.bin";
|
||||
|
||||
public static final String partnerId = "1632405339"; // 商户号Id
|
||||
|
||||
// public static final String APP_ID = "wxbb3e0d474569481d"; // 举视充电网 wxbb3e0d474569481d
|
||||
//
|
||||
// public static final String APP_SECRET = "bbac689f4654b209de4d6944808ec80b"; // 举视充电网 bbac689f4654b209de4d6944808ec80b
|
||||
|
||||
public static final String ZERO = "0";
|
||||
|
||||
public static final String ONE = "1";
|
||||
|
||||
public static final String TWO = "2";
|
||||
|
||||
public static final String THREE = "3";
|
||||
|
||||
public static final int zero = 0;
|
||||
|
||||
public static final int one = 1;
|
||||
|
||||
public static final byte zeroByte = 0x00;
|
||||
|
||||
public static final byte[] zeroByteArray = new byte[]{zeroByte};
|
||||
|
||||
public static final byte oneByte = 0x01;
|
||||
|
||||
public static final byte[] oneByteArray = new byte[]{oneByte};
|
||||
|
||||
public static final byte twoByte = 0x02;
|
||||
|
||||
public static final byte[] twoByteArray = new byte[]{twoByte};
|
||||
|
||||
public static final String FAULT_CODE = "255";
|
||||
|
||||
public static final String DOUBLE_ZERO = "00";
|
||||
|
||||
public static final String ZERO_ONE = "01";
|
||||
|
||||
public static final String ZERO_THREE = "03";
|
||||
/**
|
||||
* 删除标识 0标识正常
|
||||
*/
|
||||
public static final String DEL_FLAG_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 删除标识 1标识被删除
|
||||
*/
|
||||
public static final String DEL_FLAG_DELETE = "1";
|
||||
/**
|
||||
* UTF-8 字符集
|
||||
*/
|
||||
public static final String UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* GBK 字符集
|
||||
*/
|
||||
public static final String GBK = "GBK";
|
||||
|
||||
/**
|
||||
* http请求
|
||||
*/
|
||||
public static final String HTTP = "http://";
|
||||
|
||||
/**
|
||||
* https请求
|
||||
*/
|
||||
public static final String HTTPS = "https://";
|
||||
|
||||
/**
|
||||
* 通用成功标识
|
||||
*/
|
||||
public static final String SUCCESS = "0";
|
||||
|
||||
/**
|
||||
* 通用失败标识
|
||||
*/
|
||||
public static final String FAIL = "1";
|
||||
|
||||
/**
|
||||
* 登录成功
|
||||
*/
|
||||
public static final String LOGIN_SUCCESS = "Success";
|
||||
|
||||
/**
|
||||
* 注销
|
||||
*/
|
||||
public static final String LOGOUT = "Logout";
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public static final String REGISTER = "Register";
|
||||
|
||||
/**
|
||||
* 登录失败
|
||||
*/
|
||||
public static final String LOGIN_FAIL = "Error";
|
||||
|
||||
/**
|
||||
* 登录验证码有效期
|
||||
*/
|
||||
public static final Integer VERIFICATION_CODE_EXPIRATION_TIME = 10;
|
||||
|
||||
/**
|
||||
* 验证码有效期(分钟)
|
||||
*/
|
||||
public static final Integer CAPTCHA_EXPIRATION = 2;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
public static final String TOKEN = "token";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String TOKEN_PREFIX = "Bearer";
|
||||
|
||||
/**
|
||||
* 令牌前缀
|
||||
*/
|
||||
public static final String LOGIN_USER_KEY = "login_user_key";
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
public static final String JWT_USERID = "userid";
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
public static final String JWT_USERNAME = Claims.SUBJECT;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
public static final String JWT_AVATAR = "avatar";
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
public static final String JWT_CREATED = "created";
|
||||
|
||||
/**
|
||||
* 用户权限
|
||||
*/
|
||||
public static final String JWT_AUTHORITIES = "authorities";
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
public static final String RESOURCE_PREFIX = "/profile";
|
||||
|
||||
/**
|
||||
* RMI 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_RMI = "rmi:";
|
||||
|
||||
/**
|
||||
* LDAP 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAP = "ldap:";
|
||||
|
||||
/**
|
||||
* LDAPS 远程方法调用
|
||||
*/
|
||||
public static final String LOOKUP_LDAPS = "ldaps:";
|
||||
|
||||
/**
|
||||
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
|
||||
*/
|
||||
public static final String[] JOB_WHITELIST_STR = {"com.jsowell"};
|
||||
|
||||
/**
|
||||
* 定时任务违规的字符
|
||||
*/
|
||||
public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
|
||||
"org.springframework", "org.apache", "com.jsowell.common.util.file"};
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package com.jsowell.common.constant;
|
||||
|
||||
/**
|
||||
* 代码生成通用常量
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class GenConstants {
|
||||
/**
|
||||
* 单表(增删改查)
|
||||
*/
|
||||
public static final String TPL_CRUD = "crud";
|
||||
|
||||
/**
|
||||
* 树表(增删改查)
|
||||
*/
|
||||
public static final String TPL_TREE = "tree";
|
||||
|
||||
/**
|
||||
* 主子表(增删改查)
|
||||
*/
|
||||
public static final String TPL_SUB = "sub";
|
||||
|
||||
/**
|
||||
* 树编码字段
|
||||
*/
|
||||
public static final String TREE_CODE = "treeCode";
|
||||
|
||||
/**
|
||||
* 树父编码字段
|
||||
*/
|
||||
public static final String TREE_PARENT_CODE = "treeParentCode";
|
||||
|
||||
/**
|
||||
* 树名称字段
|
||||
*/
|
||||
public static final String TREE_NAME = "treeName";
|
||||
|
||||
/**
|
||||
* 上级菜单ID字段
|
||||
*/
|
||||
public static final String PARENT_MENU_ID = "parentMenuId";
|
||||
|
||||
/**
|
||||
* 上级菜单名称字段
|
||||
*/
|
||||
public static final String PARENT_MENU_NAME = "parentMenuName";
|
||||
|
||||
/**
|
||||
* 数据库字符串类型
|
||||
*/
|
||||
public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"};
|
||||
|
||||
/**
|
||||
* 数据库文本类型
|
||||
*/
|
||||
public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"};
|
||||
|
||||
/**
|
||||
* 数据库时间类型
|
||||
*/
|
||||
public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"};
|
||||
|
||||
/**
|
||||
* 数据库数字类型
|
||||
*/
|
||||
public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||
"bit", "bigint", "float", "double", "decimal"};
|
||||
|
||||
/**
|
||||
* 页面不需要编辑字段
|
||||
*/
|
||||
public static final String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"};
|
||||
|
||||
/**
|
||||
* 页面不需要显示的列表字段
|
||||
*/
|
||||
public static final String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by",
|
||||
"update_time"};
|
||||
|
||||
/**
|
||||
* 页面不需要查询字段
|
||||
*/
|
||||
public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by",
|
||||
"update_time", "remark"};
|
||||
|
||||
/**
|
||||
* Entity基类字段
|
||||
*/
|
||||
public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"};
|
||||
|
||||
/**
|
||||
* Tree基类字段
|
||||
*/
|
||||
public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors", "children"};
|
||||
|
||||
/**
|
||||
* 文本框
|
||||
*/
|
||||
public static final String HTML_INPUT = "input";
|
||||
|
||||
/**
|
||||
* 文本域
|
||||
*/
|
||||
public static final String HTML_TEXTAREA = "textarea";
|
||||
|
||||
/**
|
||||
* 下拉框
|
||||
*/
|
||||
public static final String HTML_SELECT = "select";
|
||||
|
||||
/**
|
||||
* 单选框
|
||||
*/
|
||||
public static final String HTML_RADIO = "radio";
|
||||
|
||||
/**
|
||||
* 复选框
|
||||
*/
|
||||
public static final String HTML_CHECKBOX = "checkbox";
|
||||
|
||||
/**
|
||||
* 日期控件
|
||||
*/
|
||||
public static final String HTML_DATETIME = "datetime";
|
||||
|
||||
/**
|
||||
* 图片上传控件
|
||||
*/
|
||||
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
||||
|
||||
/**
|
||||
* 文件上传控件
|
||||
*/
|
||||
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
||||
|
||||
/**
|
||||
* 富文本控件
|
||||
*/
|
||||
public static final String HTML_EDITOR = "editor";
|
||||
|
||||
/**
|
||||
* 字符串类型
|
||||
*/
|
||||
public static final String TYPE_STRING = "String";
|
||||
|
||||
/**
|
||||
* 整型
|
||||
*/
|
||||
public static final String TYPE_INTEGER = "Integer";
|
||||
|
||||
/**
|
||||
* 长整型
|
||||
*/
|
||||
public static final String TYPE_LONG = "Long";
|
||||
|
||||
/**
|
||||
* 浮点型
|
||||
*/
|
||||
public static final String TYPE_DOUBLE = "Double";
|
||||
|
||||
/**
|
||||
* 高精度计算类型
|
||||
*/
|
||||
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
||||
|
||||
/**
|
||||
* 时间类型
|
||||
*/
|
||||
public static final String TYPE_DATE = "Date";
|
||||
|
||||
/**
|
||||
* 模糊查询
|
||||
*/
|
||||
public static final String QUERY_LIKE = "LIKE";
|
||||
|
||||
/**
|
||||
* 相等查询
|
||||
*/
|
||||
public static final String QUERY_EQ = "EQ";
|
||||
|
||||
/**
|
||||
* 需要
|
||||
*/
|
||||
public static final String REQUIRE = "1";
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.jsowell.common.constant;
|
||||
|
||||
/**
|
||||
* 返回状态码
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class HttpStatus {
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public static final int SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 对象创建成功
|
||||
*/
|
||||
public static final int CREATED = 201;
|
||||
|
||||
/**
|
||||
* 请求已经被接受
|
||||
*/
|
||||
public static final int ACCEPTED = 202;
|
||||
|
||||
/**
|
||||
* 操作已经执行成功,但是没有返回数据
|
||||
*/
|
||||
public static final int NO_CONTENT = 204;
|
||||
|
||||
/**
|
||||
* 资源已被移除
|
||||
*/
|
||||
public static final int MOVED_PERM = 301;
|
||||
|
||||
/**
|
||||
* 重定向
|
||||
*/
|
||||
public static final int SEE_OTHER = 303;
|
||||
|
||||
/**
|
||||
* 资源没有被修改
|
||||
*/
|
||||
public static final int NOT_MODIFIED = 304;
|
||||
|
||||
/**
|
||||
* 参数列表错误(缺少,格式不匹配)
|
||||
*/
|
||||
public static final int BAD_REQUEST = 400;
|
||||
|
||||
/**
|
||||
* 未授权
|
||||
*/
|
||||
public static final int UNAUTHORIZED = 401;
|
||||
|
||||
/**
|
||||
* 访问受限,授权过期
|
||||
*/
|
||||
public static final int FORBIDDEN = 403;
|
||||
|
||||
/**
|
||||
* 资源,服务未找到
|
||||
*/
|
||||
public static final int NOT_FOUND = 404;
|
||||
|
||||
/**
|
||||
* 不允许的http方法
|
||||
*/
|
||||
public static final int BAD_METHOD = 405;
|
||||
|
||||
/**
|
||||
* 资源冲突,或者资源被锁
|
||||
*/
|
||||
public static final int CONFLICT = 409;
|
||||
|
||||
/**
|
||||
* 不支持的数据,媒体类型
|
||||
*/
|
||||
public static final int UNSUPPORTED_TYPE = 415;
|
||||
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
public static final int ERROR = 500;
|
||||
|
||||
/**
|
||||
* 接口未实现
|
||||
*/
|
||||
public static final int NOT_IMPLEMENTED = 501;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.jsowell.common.constant;
|
||||
|
||||
/**
|
||||
* 任务调度通用常量
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class ScheduleConstants {
|
||||
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
||||
|
||||
/**
|
||||
* 执行目标key
|
||||
*/
|
||||
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
||||
|
||||
/**
|
||||
* 默认
|
||||
*/
|
||||
public static final String MISFIRE_DEFAULT = "0";
|
||||
|
||||
/**
|
||||
* 立即触发执行
|
||||
*/
|
||||
public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
||||
|
||||
/**
|
||||
* 触发一次执行
|
||||
*/
|
||||
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
||||
|
||||
/**
|
||||
* 不触发立即执行
|
||||
*/
|
||||
public static final String MISFIRE_DO_NOTHING = "3";
|
||||
|
||||
public enum Status {
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL("0"),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
PAUSE("1");
|
||||
|
||||
private String value;
|
||||
|
||||
private Status(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.jsowell.common.constant;
|
||||
|
||||
/**
|
||||
* 用户常量信息
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class UserConstants {
|
||||
/**
|
||||
* 平台内系统用户的唯一标志
|
||||
*/
|
||||
public static final String SYS_USER = "SYS_USER";
|
||||
|
||||
/**
|
||||
* 正常状态
|
||||
*/
|
||||
public static final String NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 异常状态
|
||||
*/
|
||||
public static final String EXCEPTION = "1";
|
||||
|
||||
/**
|
||||
* 用户封禁状态
|
||||
*/
|
||||
public static final String USER_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 角色封禁状态
|
||||
*/
|
||||
public static final String ROLE_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 部门正常状态
|
||||
*/
|
||||
public static final String DEPT_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 部门停用状态
|
||||
*/
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 字典正常状态
|
||||
*/
|
||||
public static final String DICT_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 是否为系统默认(是)
|
||||
*/
|
||||
public static final String YES = "Y";
|
||||
|
||||
/**
|
||||
* 是否菜单外链(是)
|
||||
*/
|
||||
public static final String YES_FRAME = "0";
|
||||
|
||||
/**
|
||||
* 是否菜单外链(否)
|
||||
*/
|
||||
public static final String NO_FRAME = "1";
|
||||
|
||||
/**
|
||||
* 菜单类型(目录)
|
||||
*/
|
||||
public static final String TYPE_DIR = "M";
|
||||
|
||||
/**
|
||||
* 菜单类型(菜单)
|
||||
*/
|
||||
public static final String TYPE_MENU = "C";
|
||||
|
||||
/**
|
||||
* 菜单类型(按钮)
|
||||
*/
|
||||
public static final String TYPE_BUTTON = "F";
|
||||
|
||||
/**
|
||||
* Layout组件标识
|
||||
*/
|
||||
public final static String LAYOUT = "Layout";
|
||||
|
||||
/**
|
||||
* ParentView组件标识
|
||||
*/
|
||||
public final static String PARENT_VIEW = "ParentView";
|
||||
|
||||
/**
|
||||
* InnerLink组件标识
|
||||
*/
|
||||
public final static String INNER_LINK = "InnerLink";
|
||||
|
||||
/**
|
||||
* 校验返回结果码
|
||||
*/
|
||||
public final static String UNIQUE = "0";
|
||||
public final static String NOT_UNIQUE = "1";
|
||||
|
||||
/**
|
||||
* 用户名长度限制
|
||||
*/
|
||||
public static final int USERNAME_MIN_LENGTH = 2;
|
||||
public static final int USERNAME_MAX_LENGTH = 20;
|
||||
|
||||
/**
|
||||
* 密码长度限制
|
||||
*/
|
||||
public static final int PASSWORD_MIN_LENGTH = 5;
|
||||
public static final int PASSWORD_MAX_LENGTH = 20;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.jsowell.common.constant;
|
||||
|
||||
/**
|
||||
* 微信支付常量
|
||||
* WeiXinConstants<BR>
|
||||
* 创建人:小威 <BR>
|
||||
* 时间:2015年10月19日-下午7:14:15 <BR>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class WeiXinConstants {
|
||||
|
||||
|
||||
public static final String URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";//统一下单url
|
||||
|
||||
public static final String MCH_URL = "https://api.mch.weixin.qq.com/secapi/pay/profitsharing";//统一分账url
|
||||
|
||||
public static final String MCH_URL_MULTIPRO = "https://api.mch.weixin.qq.com/secapi/pay/multiprofitsharing";//统一分账url(多次分账)
|
||||
|
||||
public static final String PROFIT_SHARING_QUERY = "https://api.mch.weixin.qq.com/pay/profitsharingquery"; //统一分账结果查询
|
||||
|
||||
public static final String MCH_URL_FINISH = "https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish";//统一分账url
|
||||
|
||||
public static final String MCH_STATUS_URL = "https://api.mch.weixin.qq.com/pay/profitsharingquery";//统一分账查询url
|
||||
|
||||
public static final String MCH_ADD_RELATION_URL = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";//分账关系绑定地址
|
||||
|
||||
public static final String REFUND = "https://api.mch.weixin.qq.com/secapi/pay/refund";//退款
|
||||
|
||||
|
||||
public static final String RETURN_CODE = "return_code"; // SUCCESS/FAIL 此字段是通信标识,非交易标识
|
||||
|
||||
public static final String SUCCESS = "SUCCESS"; // SUCCESS/FAIL 此字段是通信标识,非交易标识
|
||||
|
||||
public static final int WIDTH = 200;//二维码宽度
|
||||
|
||||
public static final int HEIGHT = 200;//二维码高度
|
||||
|
||||
public static final String RESULT = "result_code";//返回结果
|
||||
|
||||
public static final String ORDER_PAID = "orderPaid";//已经支付
|
||||
|
||||
public static final String WEIXINPAY = "weixinPay";//可以支付
|
||||
|
||||
public static final String CODE_URL = "code_url";//微信支付url
|
||||
|
||||
public static final String ERROR_CODE = "err_code";//错误码
|
||||
|
||||
public static final String ATTACH = "attach";//商家数据包
|
||||
|
||||
public static final String BODY = "body";//商品名称
|
||||
|
||||
public static final String NOTIFY_URL = "notify_url";//异步回调地址
|
||||
|
||||
public static final String OUT_TRADE_NO = "out_trade_no";//商家订单号
|
||||
|
||||
public static final String TRANSACTION_ID = "transaction_id";//微信订单号
|
||||
|
||||
public static final String PRODUCT_ID = "product_id";//商品ID
|
||||
|
||||
public static final String SPBILL_CREATE_IP = "spbill_create_ip";//支付用户IP地址
|
||||
|
||||
public static final String TOTAL_FEE = "total_fee";//支付金额
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.jsowell.common.core.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.jsowell.common.constant.HttpStatus;
|
||||
import com.jsowell.common.core.domain.AjaxResult;
|
||||
import com.jsowell.common.core.domain.model.LoginUser;
|
||||
import com.jsowell.common.core.page.PageDomain;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
import com.jsowell.common.core.page.TableSupport;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.PageUtils;
|
||||
import com.jsowell.common.util.SecurityUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.sql.SqlUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class BaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
* 将前台传递过来的日期格式的字符串,自动转化为Date类型
|
||||
*/
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
// Date 类型转换
|
||||
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
|
||||
@Override
|
||||
public void setAsText(String text) {
|
||||
setValue(DateUtils.parseDate(text));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
protected void startPage() {
|
||||
PageUtils.startPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求排序数据
|
||||
*/
|
||||
protected void startOrderBy() {
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
PageHelper.orderBy(orderBy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理分页的线程变量
|
||||
*/
|
||||
protected void clearPage() {
|
||||
PageUtils.clearPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应请求分页数据
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
protected TableDataInfo getDataTable(List<?> list) {
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
*/
|
||||
public AjaxResult success() {
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error() {
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*/
|
||||
public AjaxResult success(String message) {
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回失败消息
|
||||
*/
|
||||
public AjaxResult error(String message) {
|
||||
return AjaxResult.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows) {
|
||||
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param result 结果
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(boolean result) {
|
||||
return result ? success() : error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 页面跳转
|
||||
*/
|
||||
public String redirect(String url) {
|
||||
return StringUtils.format("redirect:{}", url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户缓存信息
|
||||
*/
|
||||
public LoginUser getLoginUser() {
|
||||
return SecurityUtils.getLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户id
|
||||
*/
|
||||
public Long getUserId() {
|
||||
return getLoginUser().getUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录部门id
|
||||
*/
|
||||
public Long getDeptId() {
|
||||
return getLoginUser().getDeptId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录用户名
|
||||
*/
|
||||
public String getUsername() {
|
||||
return getLoginUser().getUsername();
|
||||
}
|
||||
|
||||
public String getMemberIdByAuthorization(String authorization) {
|
||||
if (StringUtils.isBlank(authorization)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
String memberId = JWTUtils.getMemberId(authorization);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
// logger.info("authorization:{}, memberId:{}", authorization, memberId);
|
||||
return memberId;
|
||||
}
|
||||
|
||||
public String getMemberIdByAuthorization(HttpServletRequest request) {
|
||||
return getMemberIdByAuthorization(request.getHeader("Authorization"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.jsowell.common.core.domain;
|
||||
|
||||
import com.jsowell.common.constant.HttpStatus;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 操作消息提醒
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class AjaxResult extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
*/
|
||||
public static final String CODE_TAG = "code";
|
||||
|
||||
/**
|
||||
* 返回内容
|
||||
*/
|
||||
public static final String MSG_TAG = "msg";
|
||||
|
||||
/**
|
||||
* 数据对象
|
||||
*/
|
||||
public static final String DATA_TAG = "data";
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||
*/
|
||||
public AjaxResult() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
*/
|
||||
public AjaxResult(int code, String msg) {
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
*/
|
||||
public AjaxResult(int code, String msg, Object data) {
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
if (StringUtils.isNotNull(data)) {
|
||||
super.put(DATA_TAG, data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success() {
|
||||
return AjaxResult.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功数据
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(Object data) {
|
||||
return AjaxResult.success("操作成功", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(String msg) {
|
||||
return AjaxResult.success(msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult success(String msg, Object data) {
|
||||
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static AjaxResult error() {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(String msg) {
|
||||
return AjaxResult.error(msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(String msg, Object data) {
|
||||
return new AjaxResult(HttpStatus.ERROR, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(int code, String msg) {
|
||||
return new AjaxResult(code, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方便链式调用
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @return 数据对象
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult put(String key, Object value) {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.jsowell.common.core.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
private String searchValue;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
public String getSearchValue() {
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue) {
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams() {
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.jsowell.common.core.domain;
|
||||
|
||||
import com.jsowell.common.constant.HttpStatus;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class R<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
public static final int SUCCESS = HttpStatus.SUCCESS;
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final int FAIL = HttpStatus.ERROR;
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private T data;
|
||||
|
||||
public static <T> R<T> ok() {
|
||||
return restResult(null, SUCCESS, "操作成功");
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, SUCCESS, "操作成功");
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data, String msg) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail() {
|
||||
return restResult(null, FAIL, "操作失败");
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg) {
|
||||
return restResult(null, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data) {
|
||||
return restResult(data, FAIL, "操作失败");
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data, String msg) {
|
||||
return restResult(data, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(int code, String msg) {
|
||||
return restResult(null, code, msg);
|
||||
}
|
||||
|
||||
private static <T> R<T> restResult(T data, int code, String msg) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.jsowell.common.core.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Tree基类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class TreeEntity extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 父菜单名称
|
||||
*/
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 祖级列表
|
||||
*/
|
||||
private String ancestors;
|
||||
|
||||
/**
|
||||
* 子部门
|
||||
*/
|
||||
private List<?> children = new ArrayList<>();
|
||||
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getAncestors() {
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
public void setAncestors(String ancestors) {
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
public List<?> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<?> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsowell.common.core.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.jsowell.common.core.domain.entity.SysDept;
|
||||
import com.jsowell.common.core.domain.entity.SysMenu;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Treeselect树结构实体类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class TreeSelect implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeSelect> children;
|
||||
|
||||
public TreeSelect() {
|
||||
|
||||
}
|
||||
|
||||
public TreeSelect(SysDept dept) {
|
||||
this.id = dept.getDeptId();
|
||||
this.label = dept.getDeptName();
|
||||
this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public TreeSelect(SysMenu menu) {
|
||||
this.id = menu.getMenuId();
|
||||
this.label = menu.getMenuName();
|
||||
this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<TreeSelect> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TreeSelect> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.jsowell.common.core.domain.entity;
|
||||
|
||||
import com.jsowell.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 部门表 sys_dept
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class SysDept extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 父部门ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 祖级列表
|
||||
*/
|
||||
private String ancestors;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 负责人
|
||||
*/
|
||||
private String leader;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 部门状态:0正常,1停用
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 父部门名称
|
||||
*/
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 子部门
|
||||
*/
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getAncestors() {
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
public void setAncestors(String ancestors) {
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||
public String getDeptName() {
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName) {
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getLeader() {
|
||||
return leader;
|
||||
}
|
||||
|
||||
public void setLeader(String leader) {
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public List<SysDept> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysDept> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("deptId", getDeptId())
|
||||
.append("parentId", getParentId())
|
||||
.append("ancestors", getAncestors())
|
||||
.append("deptName", getDeptName())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("leader", getLeader())
|
||||
.append("phone", getPhone())
|
||||
.append("email", getEmail())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.jsowell.common.core.domain.entity;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import com.jsowell.common.annotation.Excel.ColumnType;
|
||||
import com.jsowell.common.constant.UserConstants;
|
||||
import com.jsowell.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 字典数据表 sys_dict_data
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class SysDictData extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
|
||||
private Long dictCode;
|
||||
|
||||
/**
|
||||
* 字典排序
|
||||
*/
|
||||
@Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
|
||||
private Long dictSort;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@Excel(name = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典键值
|
||||
*/
|
||||
@Excel(name = "字典键值")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@Excel(name = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 样式属性(其他样式扩展)
|
||||
*/
|
||||
private String cssClass;
|
||||
|
||||
/**
|
||||
* 表格字典样式
|
||||
*/
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 是否默认(Y是 N否)
|
||||
*/
|
||||
@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
|
||||
private String isDefault;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
public Long getDictCode() {
|
||||
return dictCode;
|
||||
}
|
||||
|
||||
public void setDictCode(Long dictCode) {
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
|
||||
public Long getDictSort() {
|
||||
return dictSort;
|
||||
}
|
||||
|
||||
public void setDictSort(Long dictSort) {
|
||||
this.dictSort = dictSort;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||
public String getDictLabel() {
|
||||
return dictLabel;
|
||||
}
|
||||
|
||||
public void setDictLabel(String dictLabel) {
|
||||
this.dictLabel = dictLabel;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||
public String getDictValue() {
|
||||
return dictValue;
|
||||
}
|
||||
|
||||
public void setDictValue(String dictValue) {
|
||||
this.dictValue = dictValue;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||
public String getCssClass() {
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
public void setCssClass(String cssClass) {
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
|
||||
public String getListClass() {
|
||||
return listClass;
|
||||
}
|
||||
|
||||
public void setListClass(String listClass) {
|
||||
this.listClass = listClass;
|
||||
}
|
||||
|
||||
public boolean getDefault() {
|
||||
return UserConstants.YES.equals(this.isDefault) ? true : false;
|
||||
}
|
||||
|
||||
public String getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(String isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("dictCode", getDictCode())
|
||||
.append("dictSort", getDictSort())
|
||||
.append("dictLabel", getDictLabel())
|
||||
.append("dictValue", getDictValue())
|
||||
.append("dictType", getDictType())
|
||||
.append("cssClass", getCssClass())
|
||||
.append("listClass", getListClass())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("status", getStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.jsowell.common.core.domain.entity;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import com.jsowell.common.annotation.Excel.ColumnType;
|
||||
import com.jsowell.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 字典类型表 sys_dict_type
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class SysDictType extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典主键
|
||||
*/
|
||||
@Excel(name = "字典主键", cellType = ColumnType.NUMERIC)
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@Excel(name = "字典名称")
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@Excel(name = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
public Long getDictId() {
|
||||
return dictId;
|
||||
}
|
||||
|
||||
public void setDictId(Long dictId) {
|
||||
this.dictId = dictId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||
public String getDictName() {
|
||||
return dictName;
|
||||
}
|
||||
|
||||
public void setDictName(String dictName) {
|
||||
this.dictName = dictName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
|
||||
public String getDictType() {
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType) {
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("dictId", getDictId())
|
||||
.append("dictName", getDictName())
|
||||
.append("dictType", getDictType())
|
||||
.append("status", getStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package com.jsowell.common.core.domain.entity;
|
||||
|
||||
import com.jsowell.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单权限表 sys_menu
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class SysMenu extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 菜单ID
|
||||
*/
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 父菜单名称
|
||||
*/
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 父菜单ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 显示顺序
|
||||
*/
|
||||
private Integer orderNum;
|
||||
|
||||
/**
|
||||
* 路由地址
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 组件路径
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 路由参数
|
||||
*/
|
||||
private String query;
|
||||
|
||||
/**
|
||||
* 是否为外链(0是 1否)
|
||||
*/
|
||||
private String isFrame;
|
||||
|
||||
/**
|
||||
* 是否缓存(0缓存 1不缓存)
|
||||
*/
|
||||
private String isCache;
|
||||
|
||||
/**
|
||||
* 类型(M目录 C菜单 F按钮)
|
||||
*/
|
||||
private String menuType;
|
||||
|
||||
/**
|
||||
* 显示状态(0显示 1隐藏)
|
||||
*/
|
||||
private String visible;
|
||||
|
||||
/**
|
||||
* 菜单状态(0显示 1隐藏)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 权限字符串
|
||||
*/
|
||||
private String perms;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 子菜单
|
||||
*/
|
||||
private List<SysMenu> children = new ArrayList<SysMenu>();
|
||||
|
||||
public Long getMenuId() {
|
||||
return menuId;
|
||||
}
|
||||
|
||||
public void setMenuId(Long menuId) {
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单名称不能为空")
|
||||
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
public String getMenuName() {
|
||||
return menuName;
|
||||
}
|
||||
|
||||
public void setMenuName(String menuName) {
|
||||
this.menuName = menuName;
|
||||
}
|
||||
|
||||
public String getParentName() {
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum() {
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
|
||||
public String getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
public void setComponent(String component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public String getIsFrame() {
|
||||
return isFrame;
|
||||
}
|
||||
|
||||
public void setIsFrame(String isFrame) {
|
||||
this.isFrame = isFrame;
|
||||
}
|
||||
|
||||
public String getIsCache() {
|
||||
return isCache;
|
||||
}
|
||||
|
||||
public void setIsCache(String isCache) {
|
||||
this.isCache = isCache;
|
||||
}
|
||||
|
||||
@NotBlank(message = "菜单类型不能为空")
|
||||
public String getMenuType() {
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public void setMenuType(String menuType) {
|
||||
this.menuType = menuType;
|
||||
}
|
||||
|
||||
public String getVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void setVisible(String visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
|
||||
public String getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(String perms) {
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public List<SysMenu> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysMenu> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("menuId", getMenuId())
|
||||
.append("menuName", getMenuName())
|
||||
.append("parentId", getParentId())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("path", getPath())
|
||||
.append("component", getComponent())
|
||||
.append("isFrame", getIsFrame())
|
||||
.append("IsCache", getIsCache())
|
||||
.append("menuType", getMenuType())
|
||||
.append("visible", getVisible())
|
||||
.append("status ", getStatus())
|
||||
.append("perms", getPerms())
|
||||
.append("icon", getIcon())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package com.jsowell.common.core.domain.entity;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import com.jsowell.common.annotation.Excel.ColumnType;
|
||||
import com.jsowell.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 角色表 sys_role
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class SysRole extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@Excel(name = "角色名称")
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
@Excel(name = "角色权限")
|
||||
private String roleKey;
|
||||
|
||||
/**
|
||||
* 角色排序
|
||||
*/
|
||||
@Excel(name = "角色排序")
|
||||
private String roleSort;
|
||||
|
||||
/**
|
||||
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
|
||||
*/
|
||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
|
||||
private String dataScope;
|
||||
|
||||
/**
|
||||
* 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
|
||||
*/
|
||||
private boolean menuCheckStrictly;
|
||||
|
||||
/**
|
||||
* 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
|
||||
*/
|
||||
private boolean deptCheckStrictly;
|
||||
|
||||
/**
|
||||
* 角色状态(0正常 1停用)
|
||||
*/
|
||||
@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 用户是否存在此角色标识 默认不存在
|
||||
*/
|
||||
private boolean flag = false;
|
||||
|
||||
/**
|
||||
* 菜单组
|
||||
*/
|
||||
private Long[] menuIds;
|
||||
|
||||
/**
|
||||
* 部门组(数据权限)
|
||||
*/
|
||||
private Long[] deptIds;
|
||||
|
||||
public SysRole() {
|
||||
|
||||
}
|
||||
|
||||
public SysRole(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin(this.roleId);
|
||||
}
|
||||
|
||||
public static boolean isAdmin(Long roleId) {
|
||||
return roleId != null && 1L == roleId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "角色名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "权限字符不能为空")
|
||||
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
|
||||
public String getRoleKey() {
|
||||
return roleKey;
|
||||
}
|
||||
|
||||
public void setRoleKey(String roleKey) {
|
||||
this.roleKey = roleKey;
|
||||
}
|
||||
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
public String getRoleSort() {
|
||||
return roleSort;
|
||||
}
|
||||
|
||||
public void setRoleSort(String roleSort) {
|
||||
this.roleSort = roleSort;
|
||||
}
|
||||
|
||||
public String getDataScope() {
|
||||
return dataScope;
|
||||
}
|
||||
|
||||
public void setDataScope(String dataScope) {
|
||||
this.dataScope = dataScope;
|
||||
}
|
||||
|
||||
public boolean isMenuCheckStrictly() {
|
||||
return menuCheckStrictly;
|
||||
}
|
||||
|
||||
public void setMenuCheckStrictly(boolean menuCheckStrictly) {
|
||||
this.menuCheckStrictly = menuCheckStrictly;
|
||||
}
|
||||
|
||||
public boolean isDeptCheckStrictly() {
|
||||
return deptCheckStrictly;
|
||||
}
|
||||
|
||||
public void setDeptCheckStrictly(boolean deptCheckStrictly) {
|
||||
this.deptCheckStrictly = deptCheckStrictly;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public Long[] getMenuIds() {
|
||||
return menuIds;
|
||||
}
|
||||
|
||||
public void setMenuIds(Long[] menuIds) {
|
||||
this.menuIds = menuIds;
|
||||
}
|
||||
|
||||
public Long[] getDeptIds() {
|
||||
return deptIds;
|
||||
}
|
||||
|
||||
public void setDeptIds(Long[] deptIds) {
|
||||
this.deptIds = deptIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("roleId", getRoleId())
|
||||
.append("roleName", getRoleName())
|
||||
.append("roleKey", getRoleKey())
|
||||
.append("roleSort", getRoleSort())
|
||||
.append("dataScope", getDataScope())
|
||||
.append("menuCheckStrictly", isMenuCheckStrictly())
|
||||
.append("deptCheckStrictly", isDeptCheckStrictly())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
package com.jsowell.common.core.domain.entity;
|
||||
|
||||
import com.jsowell.common.annotation.Excel;
|
||||
import com.jsowell.common.annotation.Excel.ColumnType;
|
||||
import com.jsowell.common.annotation.Excel.Type;
|
||||
import com.jsowell.common.annotation.Excels;
|
||||
import com.jsowell.common.core.domain.BaseEntity;
|
||||
import com.jsowell.common.xss.Xss;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户对象 sys_user
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class SysUser extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@Excel(name = "部门编号", type = Type.IMPORT)
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
@Excel(name = "登录名称")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
@Excel(name = "用户名称")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
@Excel(name = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
@Excel(name = "手机号码")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*/
|
||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 2代表删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
@Excel(name = "最后登录IP", type = Type.EXPORT)
|
||||
private String loginIp;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||
private Date loginDate;
|
||||
|
||||
/**
|
||||
* 部门对象
|
||||
*/
|
||||
@Excels({
|
||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
|
||||
})
|
||||
private SysDept dept;
|
||||
|
||||
/**
|
||||
* 角色对象
|
||||
*/
|
||||
private List<SysRole> roles;
|
||||
|
||||
/**
|
||||
* 角色组
|
||||
*/
|
||||
private Long[] roleIds;
|
||||
|
||||
/**
|
||||
* 岗位组
|
||||
*/
|
||||
private Long[] postIds;
|
||||
|
||||
/**
|
||||
* 角色ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
public SysUser() {
|
||||
|
||||
}
|
||||
|
||||
public SysUser(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin(this.userId);
|
||||
}
|
||||
|
||||
public static boolean isAdmin(Long userId) {
|
||||
return userId != null && 1L == userId;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
@Xss(message = "用户昵称不能包含脚本字符")
|
||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
@Xss(message = "用户账号不能包含脚本字符")
|
||||
@NotBlank(message = "用户账号不能为空")
|
||||
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getLoginIp() {
|
||||
return loginIp;
|
||||
}
|
||||
|
||||
public void setLoginIp(String loginIp) {
|
||||
this.loginIp = loginIp;
|
||||
}
|
||||
|
||||
public Date getLoginDate() {
|
||||
return loginDate;
|
||||
}
|
||||
|
||||
public void setLoginDate(Date loginDate) {
|
||||
this.loginDate = loginDate;
|
||||
}
|
||||
|
||||
public SysDept getDept() {
|
||||
return dept;
|
||||
}
|
||||
|
||||
public void setDept(SysDept dept) {
|
||||
this.dept = dept;
|
||||
}
|
||||
|
||||
public List<SysRole> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<SysRole> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public Long[] getRoleIds() {
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
public void setRoleIds(Long[] roleIds) {
|
||||
this.roleIds = roleIds;
|
||||
}
|
||||
|
||||
public Long[] getPostIds() {
|
||||
return postIds;
|
||||
}
|
||||
|
||||
public void setPostIds(Long[] postIds) {
|
||||
this.postIds = postIds;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("deptId", getDeptId())
|
||||
.append("userName", getUserName())
|
||||
.append("nickName", getNickName())
|
||||
.append("email", getEmail())
|
||||
.append("phone", getPhone())
|
||||
.append("sex", getSex())
|
||||
.append("avatar", getAvatar())
|
||||
.append("password", getPassword())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("loginIp", getLoginIp())
|
||||
.append("loginDate", getLoginDate())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("dept", getDept())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.jsowell.common.core.domain.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户登录对象
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
@Data
|
||||
public class LoginBody {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 唯一标识
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package com.jsowell.common.core.domain.model;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.jsowell.common.core.domain.entity.SysUser;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 登录用户身份权限
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class LoginUser implements UserDetails {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 登录时间
|
||||
*/
|
||||
private Long loginTime;
|
||||
|
||||
/**
|
||||
* 过期时间
|
||||
*/
|
||||
private Long expireTime;
|
||||
|
||||
/**
|
||||
* 登录IP地址
|
||||
*/
|
||||
private String ipaddr;
|
||||
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
private String loginLocation;
|
||||
|
||||
/**
|
||||
* 浏览器类型
|
||||
*/
|
||||
private String browser;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String os;
|
||||
|
||||
/**
|
||||
* 权限列表
|
||||
*/
|
||||
private Set<String> permissions;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private SysUser user;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public LoginUser() {
|
||||
}
|
||||
|
||||
public LoginUser(SysUser user, Set<String> permissions) {
|
||||
this.user = user;
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions) {
|
||||
this.userId = userId;
|
||||
this.deptId = deptId;
|
||||
this.user = user;
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return user.getUserName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 账户是否未过期,过期无法验证
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定用户是否解锁,锁定的用户无法进行身份验证
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可用 ,禁用的用户不能身份验证
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Long getLoginTime() {
|
||||
return loginTime;
|
||||
}
|
||||
|
||||
public void setLoginTime(Long loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
|
||||
public String getIpaddr() {
|
||||
return ipaddr;
|
||||
}
|
||||
|
||||
public void setIpaddr(String ipaddr) {
|
||||
this.ipaddr = ipaddr;
|
||||
}
|
||||
|
||||
public String getLoginLocation() {
|
||||
return loginLocation;
|
||||
}
|
||||
|
||||
public void setLoginLocation(String loginLocation) {
|
||||
this.loginLocation = loginLocation;
|
||||
}
|
||||
|
||||
public String getBrowser() {
|
||||
return browser;
|
||||
}
|
||||
|
||||
public void setBrowser(String browser) {
|
||||
this.browser = browser;
|
||||
}
|
||||
|
||||
public String getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(String os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
public Long getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
public void setExpireTime(Long expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public Set<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(Set<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public SysUser getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(SysUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.jsowell.common.core.domain.model;
|
||||
|
||||
/**
|
||||
* 用户注册对象
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class RegisterBody extends LoginBody {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.jsowell.common.core.domain.ykc;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class LoginRequestData {
|
||||
/**
|
||||
* 桩编码 BCD 码 7 不足 7 位补 0
|
||||
*/
|
||||
private String pileSn;
|
||||
|
||||
/**
|
||||
* 桩类型 BIN 码 1 0 表示直流桩, 1 表示交流桩
|
||||
*/
|
||||
private String pileType;
|
||||
|
||||
/**
|
||||
* 充电枪数量 BIN 码 1
|
||||
*/
|
||||
private String connectorNum;
|
||||
|
||||
/**
|
||||
* 通信协议版本 BIN 码 1 版本号乘 10,v1.0 表示 0x0A
|
||||
*/
|
||||
private String communicationVersion;
|
||||
|
||||
/**
|
||||
* 程序版本 ASCII 码 8 不足 8 位补零
|
||||
*/
|
||||
private String programVersion;
|
||||
|
||||
/**
|
||||
* 网络链接类型 BIN 码 1 0x00 SIM 卡
|
||||
* 0x01 LAN
|
||||
* 0x02 WAN
|
||||
* 0x03 其他
|
||||
*/
|
||||
private String internetConnection;
|
||||
|
||||
/**
|
||||
* Sim 卡 BCD 码 10 不足 10 位补零,取不到置零
|
||||
*/
|
||||
private String iccid;
|
||||
|
||||
/**
|
||||
* 运营商 BIN 码 1 0x00 移动
|
||||
* 0x02 电信
|
||||
* 0x03 联通
|
||||
* 0x04 其他
|
||||
*/
|
||||
private String business;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.jsowell.common.core.domain.ykc;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实时监测数据
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class RealTimeMonitorData {
|
||||
/**
|
||||
* 交易流水号
|
||||
*/
|
||||
private String orderCode;
|
||||
|
||||
/**
|
||||
* 桩编号
|
||||
*/
|
||||
private String pileSn;
|
||||
|
||||
/**
|
||||
* 枪口编号
|
||||
*/
|
||||
private String connectorCode;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String connectorStatus;
|
||||
|
||||
/**
|
||||
* 枪是否归位
|
||||
*/
|
||||
private String homingFlag;
|
||||
|
||||
/**
|
||||
* 充电枪编号
|
||||
*/
|
||||
private String pileConnectorCode;
|
||||
|
||||
/**
|
||||
* 是否插枪 0x00:否 0x01:是
|
||||
*/
|
||||
private String putGunType;
|
||||
|
||||
/**
|
||||
* 输出电压
|
||||
*/
|
||||
private String outputVoltage;
|
||||
|
||||
/**
|
||||
* 输出电流
|
||||
*/
|
||||
private String outputCurrent;
|
||||
|
||||
/**
|
||||
* 输出功率(由输出电压,输出电流计算得出)
|
||||
*/
|
||||
private String outputPower;
|
||||
|
||||
/**
|
||||
* 枪线温度
|
||||
*/
|
||||
private String gunLineTemperature;
|
||||
|
||||
/**
|
||||
* 枪线编码 没有置零
|
||||
*/
|
||||
private String gunLineCode;
|
||||
|
||||
/**
|
||||
* SOC 待机置零;交流桩置零
|
||||
*/
|
||||
private String SOC;
|
||||
|
||||
/**
|
||||
* 电池组最高温度
|
||||
*/
|
||||
private String batteryMaxTemperature;
|
||||
|
||||
/**
|
||||
* 累计充电时间 单位: min;待机置零
|
||||
*/
|
||||
private String sumChargingTime;
|
||||
|
||||
/**
|
||||
* 剩余时间 单位: min;待机置零、交流桩置零
|
||||
*/
|
||||
private String timeRemaining;
|
||||
|
||||
/**
|
||||
* 充电度数 精确到小数点后四位;待机置零
|
||||
*/
|
||||
private String chargingDegree;
|
||||
|
||||
/**
|
||||
* 计损充电度数 精确到小数点后四位;待机置零 未设置计损比例时等于充电度数
|
||||
*/
|
||||
private String lossDegree;
|
||||
|
||||
/**
|
||||
* 已充金额 精确到小数点后四位;待机置零 (电费+服务费) *计损充电度数
|
||||
*/
|
||||
private String chargingAmount;
|
||||
|
||||
/**
|
||||
* 硬件故障
|
||||
*/
|
||||
private String hardwareFault;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private String dateTime;
|
||||
|
||||
public String getPileConnectorCode() {
|
||||
return this.pileSn + this.getConnectorCode();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.jsowell.common.core.domain.ykc;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 交易记录数据对象
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2022/11/16 15:01
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class TransactionRecordsData {
|
||||
|
||||
// 交易流水号
|
||||
private String orderCode;
|
||||
|
||||
// 桩编码
|
||||
private String pileSn;
|
||||
|
||||
// 枪号
|
||||
private String connectorCode;
|
||||
|
||||
// 开始时间 CP56Time2a 格式
|
||||
private String startTime;
|
||||
|
||||
// 结束时间
|
||||
private String endTime;
|
||||
|
||||
// 尖单价 精确到小数点后五位(尖电费+尖服务费,见费率帧)
|
||||
private String sharpPrice;
|
||||
|
||||
// 尖电量 精确到小数点后四位
|
||||
private String sharpUsedElectricity;
|
||||
|
||||
// 计损尖电量
|
||||
private String sharpPlanLossElectricity;
|
||||
|
||||
// 尖金额
|
||||
private String sharpAmount;
|
||||
|
||||
// 峰单价 精确到小数点后五位(峰电费+峰服务费)
|
||||
private String peakPrice;
|
||||
|
||||
// 峰电量
|
||||
private String peakUsedElectricity;
|
||||
|
||||
// 计损峰电量
|
||||
private String peakPlanLossElectricity;
|
||||
|
||||
// 峰金额
|
||||
private String peakAmount;
|
||||
|
||||
// 平单价 精确到小数点后五位(平电费+平服务费)
|
||||
private String flatPrice;
|
||||
|
||||
// 平电量
|
||||
private String flatUsedElectricity;
|
||||
|
||||
// 计损平电量
|
||||
private String flatPlanLossElectricity;
|
||||
|
||||
// 平金额
|
||||
private String flatAmount;
|
||||
|
||||
// 谷单价 精确到小数点后五位(谷电费+谷 服务费)
|
||||
private String valleyPrice;
|
||||
|
||||
// 谷电量
|
||||
private String valleyUsedElectricity;
|
||||
|
||||
// 计损谷电量
|
||||
private String valleyPlanLossElectricity;
|
||||
|
||||
// 谷金额
|
||||
private String valleyAmount;
|
||||
|
||||
// 电表总起值
|
||||
private String ammeterTotalStart;
|
||||
|
||||
// 电表总止值
|
||||
private String ammeterTotalEnd;
|
||||
|
||||
// 总电量
|
||||
private String totalElectricity;
|
||||
|
||||
// 计损总电量
|
||||
private String planLossTotalElectricity;
|
||||
|
||||
// 消费金额 精确到小数点后四位,包含电费、 服务费
|
||||
private String consumptionAmount;
|
||||
|
||||
// VIN 码 VIN 码,此处 VIN 码和充电时 VIN 码不同, 正序直接上传, 无需补 0 和反序
|
||||
private String vinCode;
|
||||
|
||||
/** order_anomaly_record
|
||||
* 交易标识
|
||||
* 0x01: app 启动
|
||||
* 0x02:卡启动
|
||||
* 0x04:离线卡启动
|
||||
* 0x05: vin 码启动充电
|
||||
*/
|
||||
private String transactionIdentifier;
|
||||
|
||||
// 交易时间 CP56Time2a 格式
|
||||
private String transactionTime;
|
||||
|
||||
// 停止原因
|
||||
private String stopReasonMsg;
|
||||
|
||||
// 物理卡号 不足 8 位补 0
|
||||
private String logicCard;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||
.append("orderCode", orderCode)
|
||||
.append("pileSn", pileSn)
|
||||
.append("connectorCode", connectorCode)
|
||||
.append("startTime", startTime)
|
||||
.append("endTime", endTime)
|
||||
.append("sharpPrice", sharpPrice)
|
||||
.append("sharpUsedElectricity", sharpUsedElectricity)
|
||||
.append("sharpPlanLossElectricity", sharpPlanLossElectricity)
|
||||
.append("sharpAmount", sharpAmount)
|
||||
.append("peakPrice", peakPrice)
|
||||
.append("peakUsedElectricity", peakUsedElectricity)
|
||||
.append("peakPlanLossElectricity", peakPlanLossElectricity)
|
||||
.append("peakAmount", peakAmount)
|
||||
.append("flatPrice", flatPrice)
|
||||
.append("flatUsedElectricity", flatUsedElectricity)
|
||||
.append("flatPlanLossElectricity", flatPlanLossElectricity)
|
||||
.append("flatAmount", flatAmount)
|
||||
.append("valleyPrice", valleyPrice)
|
||||
.append("valleyUsedElectricity", valleyUsedElectricity)
|
||||
.append("valleyPlanLossElectricity", valleyPlanLossElectricity)
|
||||
.append("valleyAmount", valleyAmount)
|
||||
.append("ammeterTotalStart", ammeterTotalStart)
|
||||
.append("ammeterTotalEnd", ammeterTotalEnd)
|
||||
.append("totalElectricity", totalElectricity)
|
||||
.append("planLossTotalElectricity", planLossTotalElectricity)
|
||||
.append("consumptionAmount", consumptionAmount)
|
||||
.append("vinCode", vinCode)
|
||||
.append("transactionIdentifier", transactionIdentifier)
|
||||
.append("transactionTime", transactionTime)
|
||||
.append("stopReasonMsg", stopReasonMsg)
|
||||
.append("logicCard", logicCard)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.jsowell.common.core.domain.ykc;
|
||||
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 云快充数据模板
|
||||
*/
|
||||
@Data
|
||||
public class YKCDataProtocol {
|
||||
/**
|
||||
* 起始标志 1字节
|
||||
*/
|
||||
private byte[] head;
|
||||
|
||||
/**
|
||||
* 数据长度 1字节
|
||||
*/
|
||||
private byte[] length;
|
||||
|
||||
/**
|
||||
* 序列号域 2字节
|
||||
*/
|
||||
private byte[] serialNumber;
|
||||
|
||||
/**
|
||||
* 加密标志 1 字节
|
||||
*/
|
||||
private byte[] encryptFlag;
|
||||
|
||||
/**
|
||||
* 帧类型标志 1 字节
|
||||
*/
|
||||
private byte[] frameType;
|
||||
|
||||
/**
|
||||
* 消息体 N字节
|
||||
*/
|
||||
private byte[] msgBody;
|
||||
|
||||
/**
|
||||
* 帧校验域 2字节
|
||||
*/
|
||||
private byte[] crcByte;
|
||||
|
||||
public YKCDataProtocol(byte[] msg) {
|
||||
// 起始标志
|
||||
this.head = BytesUtil.copyBytes(msg, 0, 1);
|
||||
// 数据长度
|
||||
this.length = BytesUtil.copyBytes(msg, 1, 1);
|
||||
// 序列号域
|
||||
this.serialNumber = BytesUtil.copyBytes(msg, 2, 2);
|
||||
// 加密标志
|
||||
this.encryptFlag = BytesUtil.copyBytes(msg, 4, 1);
|
||||
// 帧类型标志
|
||||
this.frameType = BytesUtil.copyBytes(msg, 5, 1);
|
||||
// 消息体
|
||||
this.msgBody = BytesUtil.copyBytes(msg, 6, msg.length - 8);
|
||||
// 帧校验域
|
||||
this.crcByte = new byte[]{msg[msg.length - 2], msg[msg.length - 1]};
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为十六进制字符串
|
||||
*
|
||||
* @return 报文
|
||||
*/
|
||||
public String getHEXString() {
|
||||
byte[] bytes = Bytes.concat(this.head, this.length, this.serialNumber, this.encryptFlag, this.frameType, this.msgBody, this.crcByte);
|
||||
return BytesUtil.binary(bytes, 16);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.jsowell.common.core.domain.ykc;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
|
||||
/**
|
||||
* 云快充 帧类型码
|
||||
* FrameTypeCode
|
||||
* frame
|
||||
*/
|
||||
public enum YKCFrameTypeCode {
|
||||
|
||||
LOGIN_CODE(0x01, "充电桩登录认证"),
|
||||
LOGIN_ANSWER_CODE(0x02, "登录认证应答"),
|
||||
|
||||
HEART_BEAT_CODE(0x03, "充电桩心跳包"),
|
||||
HEART_BEAT_ANSWER_CODE(0x04, "心跳包应答"),
|
||||
|
||||
BILLING_TEMPLATE_VALIDATE_CODE(0x05, "计费模型验证请求"),
|
||||
BILLING_TEMPLATE_VALIDATE_ANSWER_CODE(0x06, "计费模型验证请求应答"),
|
||||
|
||||
BILLING_TEMPLATE_CODE(0x09, "充电桩计费模型请求"),
|
||||
BILLING_TEMPLATE_ANSWER_CODE(0x0A, "计费模型请求应答"),
|
||||
|
||||
UPLOAD_REAL_TIME_MONITOR_DATA_OLD_VERSION_CODE(0x11, "上传实时监测数据V1.3"),
|
||||
READ_REAL_TIME_MONITOR_DATA_CODE(0x12, "读取实时监测数据"),
|
||||
UPLOAD_REAL_TIME_MONITOR_DATA_CODE(0x13, "上传实时监测数据"),
|
||||
|
||||
CHARGING_HANDSHAKE_CODE(0x15, "充电握手"),
|
||||
PARAMETER_CONFIGURATION_CODE(0x17, "参数配置"),
|
||||
CHARGE_END_CODE(0X19, "充电结束"),
|
||||
ERROR_MESSAGE_CODE(0x1B, "错误报文"),
|
||||
BMS_ABORT_DURING_CHARGING_PHASE_CODE(0x1D, "充电阶段BMS中止"),
|
||||
THE_CHARGER_IS_ABORTED_DURING_THE_CHARGING_PHASE_CODE(0X21, "充电阶段充电机中止"),
|
||||
CHARGING_PROCESS_BMS_DEMAND_AND_CHARGER_OUTPUT_CODE(0X23, "充电过程 BMS 需求与充电机输出"),
|
||||
CHARGING_PROCESS_BMS_INFORMATION_CODE(0X25, "充电过程 BMS 信息"),
|
||||
|
||||
REQUEST_START_CHARGING_CODE(0x31, "充电桩主动申请启动充电"),
|
||||
CONFIRM_START_CHARGING_CODE(0x32, "运营平台确认启动充电"),
|
||||
|
||||
REMOTE_START_CHARGING_ANSWER_CODE(0x33, "远程启动充电命令回复"),
|
||||
REMOTE_CONTROL_START_CODE(0x34, "运营平台远程控制启机"),
|
||||
|
||||
REMOTE_STOP_CHARGING_ANSWER_CODE(0x35, "远程停机命令回复"),
|
||||
REMOTE_STOP_CHARGING_CODE(0x36, "运营平台远程停机"),
|
||||
|
||||
|
||||
TRANSACTION_RECORDS_CODE(0x3B, "交易记录"),
|
||||
TRANSACTION_RECORDS_OLD_VERSION_CODE(0x39, "交易记录V1.3"),
|
||||
TRANSACTION_RECORDS_CONFIRM_CODE(0x40, "交易记录确认"),
|
||||
|
||||
REMOTE_ACCOUNT_BALANCE_UPDATE_CODE(0x42, "远程账户余额更新"),
|
||||
REMOTE_ACCOUNT_BALANCE_UPDATE_ANSWER_CODE(0x41, "余额更新应答"),
|
||||
|
||||
OFFLINE_CARD_DATA_SYNCHRONIZATION_CODE(0x44, "离线卡数据同步"),
|
||||
OFFLINE_CARD_DATA_SYNCHRONIZATION_ANSWER_CODE(0x43, "离线卡数据同步应答"),
|
||||
|
||||
OFFLINE_CARD_DATA_CLEANING_CODE(0x46, "离线卡数据清除"),
|
||||
OFFLINE_CARD_DATA_CLEANING_ANSWER_CODE(0x45, "离线卡数据清除应答"),
|
||||
|
||||
OFFLINE_CARD_DATA_QUERY_CODE(0x48, "离线卡数据查询"),
|
||||
OFFLINE_CARD_DATA_QUERY_ANSWER_CODE(0x47, "离线卡数据查询应答"),
|
||||
|
||||
CHARGING_PILE_WORKING_PARAMETER_SETTING_CODE(0x52, "充电桩工作参数设置"),
|
||||
CHARGING_PILE_WORKING_PARAMETER_SETTING_ANSWER_CODE(0x51, "充电桩工作参数设置应答"),
|
||||
|
||||
TIME_CHECK_SETTING_CODE(0x56, "对时设置"),
|
||||
TIME_CHECK_SETTING_ANSWER_CODE(0x55, "对时设置应答"),
|
||||
|
||||
BILLING_TEMPLATE_SETTING_CODE(0x58, "计费模型设置"),
|
||||
BILLING_TEMPLATE_SETTING_ANSWER_CODE(0x57, "计费模型设置应答"),
|
||||
|
||||
GROUND_LOCK_DATA_UPLOAD_CODE(0x61, "地锁数据上送"),
|
||||
REMOTE_CONTROL_GROUND_LOCK_LIFTING_CODE(0x62, "遥控地锁升降"),
|
||||
CHARGING_PILE_RESPOND_GROUND_LOCK_LIFTING_CODE(0X63, "充电桩响应地锁升降数据"),
|
||||
|
||||
REMOTE_RESTART_CODE(0x92, "远程重启"),
|
||||
REMOTE_RESTART_ANSWER_CODE(0x91, "远程重启应答"),
|
||||
|
||||
REMOTE_UPDATE_CODE(0x94, "远程更新"),
|
||||
REMOTE_UPDATE_ANSWER_CODE(0x93, "远程更新应答"),
|
||||
|
||||
REMOTE_ISSUE_QRCODE_CODE(0xF0, "后台远程下发二维码前缀指令"),
|
||||
REMOTE_ISSUE_QRCODE_ANSWER_CODE(0xF1, "桩应答远程下发二维码前缀指令"),
|
||||
|
||||
// 自定义FrameType
|
||||
PILE_LOG_OUT(9999, "充电桩退出"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
YKCFrameTypeCode(int code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private int code;
|
||||
private String value;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return BytesUtil.intToBytesLittle(code, 1);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
byte[] bytes = BytesUtil.intToBytesLittle(9999, 1);
|
||||
System.out.println(YKCUtils.frameType2Str(bytes));
|
||||
}
|
||||
|
||||
public static YKCFrameTypeCode fromCode(byte code) {
|
||||
for (YKCFrameTypeCode item : YKCFrameTypeCode.values()) {
|
||||
if (item.getCode() == code) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getFrameTypeStr(String frameType) {
|
||||
for (YKCFrameTypeCode item : YKCFrameTypeCode.values()) {
|
||||
String str = YKCUtils.frameType2Str(item.getBytes());
|
||||
if (StringUtils.equals(frameType, str)) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求应答 帧类型关系
|
||||
*/
|
||||
public enum ResponseRelation {
|
||||
// 登录
|
||||
LOGIN(LOGIN_CODE.getCode(), LOGIN_ANSWER_CODE.getCode()),
|
||||
// 心跳
|
||||
HEART_BEAT(HEART_BEAT_CODE.getCode(), HEART_BEAT_ANSWER_CODE.getCode()),
|
||||
// 计费模板验证
|
||||
BILLING_TEMPLATE_VALIDATE(BILLING_TEMPLATE_VALIDATE_CODE.getCode(), BILLING_TEMPLATE_VALIDATE_ANSWER_CODE.getCode()),
|
||||
// 计费模板请求
|
||||
BILLING_TEMPLATE(BILLING_TEMPLATE_CODE.getCode(), BILLING_TEMPLATE_ANSWER_CODE.getCode()),
|
||||
// 请求开始充电
|
||||
START_CHARGING(REQUEST_START_CHARGING_CODE.getCode(), CONFIRM_START_CHARGING_CODE.getCode()),
|
||||
// 远程请求充电
|
||||
REMOTE_START_CHARGING(REMOTE_CONTROL_START_CODE.getCode(), REMOTE_START_CHARGING_ANSWER_CODE.getCode()),
|
||||
// 远程停止充电
|
||||
REMOTE_STOP_CHARGING(REMOTE_STOP_CHARGING_CODE.getCode(), REMOTE_STOP_CHARGING_ANSWER_CODE.getCode()),
|
||||
// 交易记录
|
||||
TRANSACTION_RECORDS(TRANSACTION_RECORDS_CODE.getCode(), TRANSACTION_RECORDS_CONFIRM_CODE.getCode()),
|
||||
// 远程账户更新
|
||||
REMOTE_ACCOUNT_BALANCE_UPDATE(REMOTE_ACCOUNT_BALANCE_UPDATE_CODE.getCode(), REMOTE_ACCOUNT_BALANCE_UPDATE_ANSWER_CODE.getCode());
|
||||
|
||||
// 请求帧类型
|
||||
private int requestFrameType;
|
||||
|
||||
// 响应帧类型
|
||||
private int responseFrameType;
|
||||
|
||||
public int getRequestFrameType() {
|
||||
return requestFrameType;
|
||||
}
|
||||
|
||||
public void setRequestFrameType(int requestFrameType) {
|
||||
this.requestFrameType = requestFrameType;
|
||||
}
|
||||
|
||||
public int getResponseFrameType() {
|
||||
return responseFrameType;
|
||||
}
|
||||
|
||||
public void setResponseFrameType(int responseFrameType) {
|
||||
this.responseFrameType = responseFrameType;
|
||||
}
|
||||
|
||||
ResponseRelation(int requestFrameType, int responseFrameType) {
|
||||
this.requestFrameType = requestFrameType;
|
||||
this.responseFrameType = responseFrameType;
|
||||
}
|
||||
|
||||
// 根据请求帧类型 获取应答帧类型
|
||||
public static int getResponseFrameType(int requestFrameType) {
|
||||
for (ResponseRelation responseRelation : ResponseRelation.values()) {
|
||||
if (responseRelation.getRequestFrameType() == requestFrameType) {
|
||||
return responseRelation.getResponseFrameType();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static byte[] getResponseFrameType(byte[] requestFrameType) {
|
||||
int frameType = BytesUtil.bytesToInt(requestFrameType);
|
||||
return BytesUtil.intToBytes(getResponseFrameType(frameType), 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.jsowell.common.core.page;
|
||||
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 分页数据
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class PageDomain {
|
||||
/**
|
||||
* 当前记录起始索引
|
||||
*/
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
private String orderByColumn;
|
||||
|
||||
/**
|
||||
* 排序的方向desc或者asc
|
||||
*/
|
||||
private String isAsc = "asc";
|
||||
|
||||
/**
|
||||
* 分页参数合理化
|
||||
*/
|
||||
private Boolean reasonable = true;
|
||||
|
||||
public String getOrderBy() {
|
||||
if (StringUtils.isEmpty(orderByColumn)) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
||||
}
|
||||
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum(Integer pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public String getOrderByColumn() {
|
||||
return orderByColumn;
|
||||
}
|
||||
|
||||
public void setOrderByColumn(String orderByColumn) {
|
||||
this.orderByColumn = orderByColumn;
|
||||
}
|
||||
|
||||
public String getIsAsc() {
|
||||
return isAsc;
|
||||
}
|
||||
|
||||
public void setIsAsc(String isAsc) {
|
||||
if (StringUtils.isNotEmpty(isAsc)) {
|
||||
// 兼容前端排序类型
|
||||
if ("ascending".equals(isAsc)) {
|
||||
isAsc = "asc";
|
||||
} else if ("descending".equals(isAsc)) {
|
||||
isAsc = "desc";
|
||||
}
|
||||
this.isAsc = isAsc;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getReasonable() {
|
||||
if (StringUtils.isNull(reasonable)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return reasonable;
|
||||
}
|
||||
|
||||
public void setReasonable(Boolean reasonable) {
|
||||
this.reasonable = reasonable;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.jsowell.common.core.page;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class PageResponse implements Serializable {
|
||||
private static final long serialVersionUID = -8561048121257788971L;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private int pageNum;
|
||||
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
private int pageSize;
|
||||
|
||||
/**
|
||||
* 数据集合
|
||||
*/
|
||||
private List<?> list;
|
||||
|
||||
/**
|
||||
* 结果总数
|
||||
*/
|
||||
private long total;
|
||||
|
||||
/**
|
||||
* 结果总页数
|
||||
*/
|
||||
private int pages;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.jsowell.common.core.page;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表格分页数据对象
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class TableDataInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private long total;
|
||||
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<?> rows;
|
||||
|
||||
/**
|
||||
* 消息状态码
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 表格数据对象
|
||||
*/
|
||||
public TableDataInfo() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param list 列表数据
|
||||
* @param total 总记录数
|
||||
*/
|
||||
public TableDataInfo(List<?> list, int total) {
|
||||
this.rows = list;
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public long getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(long total) {
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public List<?> getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void setRows(List<?> rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.jsowell.common.core.page;
|
||||
|
||||
import com.jsowell.common.core.text.Convert;
|
||||
import com.jsowell.common.util.ServletUtils;
|
||||
|
||||
/**
|
||||
* 表格数据处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class TableSupport {
|
||||
/**
|
||||
* 当前记录起始索引
|
||||
*/
|
||||
public static final String PAGE_NUM = "pageNum";
|
||||
|
||||
/**
|
||||
* 每页显示记录数
|
||||
*/
|
||||
public static final String PAGE_SIZE = "pageSize";
|
||||
|
||||
/**
|
||||
* 排序列
|
||||
*/
|
||||
public static final String ORDER_BY_COLUMN = "orderByColumn";
|
||||
|
||||
/**
|
||||
* 排序的方向 "desc" 或者 "asc".
|
||||
*/
|
||||
public static final String IS_ASC = "isAsc";
|
||||
|
||||
/**
|
||||
* 分页参数合理化
|
||||
*/
|
||||
public static final String REASONABLE = "reasonable";
|
||||
|
||||
/**
|
||||
* 封装分页对象
|
||||
*/
|
||||
public static PageDomain getPageDomain() {
|
||||
PageDomain pageDomain = new PageDomain();
|
||||
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
|
||||
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
|
||||
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
|
||||
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
|
||||
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
|
||||
return pageDomain;
|
||||
}
|
||||
|
||||
public static PageDomain buildPageRequest() {
|
||||
return getPageDomain();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,504 @@
|
||||
package com.jsowell.common.core.redis;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.BoundSetOperations;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.HashOperations;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* spring redis 工具类
|
||||
*
|
||||
* @author jsowell
|
||||
**/
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
@Component
|
||||
public class RedisCache {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(RedisCache.class);
|
||||
|
||||
@Autowired
|
||||
public RedisTemplate redisTemplate;
|
||||
|
||||
// redis锁获取超时时间
|
||||
private long timeout = 500l;
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置缓存
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @param timeout 超时时间 单位秒
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value, final Integer timeout) {
|
||||
// redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||
setCacheObject(key, value, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存基本的对象,Integer、String、实体类等
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param value 缓存的值
|
||||
* @param timeout 时间
|
||||
* @param timeUnit 时间颗粒度
|
||||
*/
|
||||
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout) {
|
||||
return expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param timeout 超时时间
|
||||
* @param unit 时间单位
|
||||
* @return true=设置成功;false=设置失败
|
||||
*/
|
||||
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||
return redisTemplate.expire(key, timeout, unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取有效时间
|
||||
*
|
||||
* @param key Redis键
|
||||
* @return 有效时间
|
||||
*/
|
||||
public long getExpire(final String key) {
|
||||
return redisTemplate.getExpire(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 key是否存在
|
||||
*
|
||||
* @param key 键
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
public Boolean hasKey(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象。
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> T getCacheObject(final String key) {
|
||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||
return operation.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个对象
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public boolean deleteObject(final String key) {
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除集合对象
|
||||
*
|
||||
* @param collection 多个对象
|
||||
* @return
|
||||
*/
|
||||
public long deleteObject(final Collection collection) {
|
||||
return redisTemplate.delete(collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存List数据
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @param dataList 待缓存的List数据
|
||||
* @return 缓存的对象
|
||||
*/
|
||||
public <T> long setCacheList(final String key, final List<T> dataList) {
|
||||
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
||||
return count == null ? 0 : count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的list对象
|
||||
*
|
||||
* @param key 缓存的键值
|
||||
* @return 缓存键值对应的数据
|
||||
*/
|
||||
public <T> List<T> getCacheList(final String key) {
|
||||
return redisTemplate.opsForList().range(key, 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取缓存
|
||||
*
|
||||
* @param keys
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public <T> List<T> multiGet(final List<String> keys) {
|
||||
return redisTemplate.opsForValue().multiGet(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param dataSet 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
Iterator<T> it = dataSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
setOperation.add(it.next());
|
||||
}
|
||||
return setOperation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的set
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Set<T> getCacheSet(final String key) {
|
||||
return redisTemplate.opsForSet().members(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存Map
|
||||
*
|
||||
* @param key
|
||||
* @param dataMap
|
||||
*/
|
||||
public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
|
||||
if (dataMap != null) {
|
||||
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的Map
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public <T> Map<String, T> getCacheMap(final String key) {
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 往Hash中存入数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @param value 值
|
||||
*/
|
||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
|
||||
redisTemplate.opsForHash().put(key, hKey, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @return Hash中的对象
|
||||
*/
|
||||
public <T> T getCacheMapValue(final String key, final String hKey) {
|
||||
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
||||
return opsForHash.get(key, hKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Hash中的数据
|
||||
*
|
||||
* @param key
|
||||
* @param hKey
|
||||
*/
|
||||
public void delCacheMapValue(final String key, final String hKey) {
|
||||
HashOperations hashOperations = redisTemplate.opsForHash();
|
||||
hashOperations.delete(key, hKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个Hash中的数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKeys Hash键集合
|
||||
* @return Hash对象集合
|
||||
*/
|
||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
|
||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Hash中的某条数据
|
||||
*
|
||||
* @param key Redis键
|
||||
* @param hKey Hash键
|
||||
* @return 是否成功
|
||||
*/
|
||||
public boolean deleteCacheMapValue(final String key, final String hKey) {
|
||||
return Boolean.TRUE.equals(redisTemplate.opsForHash().delete(key, hKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得缓存的基本对象列表
|
||||
*
|
||||
* @param pattern 字符串前缀
|
||||
* @return 对象列表
|
||||
*/
|
||||
public Collection<String> keys(final String pattern) {
|
||||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
|
||||
public Long increment(final String key, final long delta) {
|
||||
return redisTemplate.opsForValue().increment(key, delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* scan 实现
|
||||
*
|
||||
* @param pattern 表达式,如:abc*,找出所有以abc开始的键
|
||||
*/
|
||||
public Set<String> scan(String pattern) {
|
||||
return (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
|
||||
Set<String> keysTmp = new HashSet<>();
|
||||
try (Cursor<byte[]> cursor = connection.scan(new ScanOptions.ScanOptionsBuilder()
|
||||
.match(pattern)
|
||||
.count(10000).build())) {
|
||||
|
||||
while (cursor.hasNext()) {
|
||||
keysTmp.add(new String(cursor.next(), "Utf-8"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return keysTmp;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 加锁,无阻塞
|
||||
*
|
||||
* @param lockKey 锁
|
||||
* @param requestId 请求标识
|
||||
* @param expireTime 超期时间
|
||||
* @return 是否获取成功
|
||||
*/
|
||||
public Boolean lock(String lockKey, String requestId, long expireTime) {
|
||||
Long start = System.currentTimeMillis();
|
||||
//在一定时间内获取锁,超时则返回错误
|
||||
for (; ; ) {
|
||||
//Set命令返回OK,则证明获取锁成功
|
||||
Boolean ret = redisTemplate.opsForValue().setIfAbsent(lockKey, requestId, expireTime, TimeUnit.SECONDS);
|
||||
if (ret != null && ret) {
|
||||
return true;
|
||||
}
|
||||
//否则循环等待,在timeout时间内仍未获取到锁,则获取失败
|
||||
long end = System.currentTimeMillis() - start;
|
||||
if (end >= timeout) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据key'删除锁
|
||||
*
|
||||
* @param lockKey
|
||||
*/
|
||||
public void unLock(String lockKey) {
|
||||
// 删除key即可释放锁
|
||||
redisTemplate.delete(lockKey);
|
||||
}
|
||||
|
||||
// ================================Map=================================
|
||||
|
||||
/**
|
||||
* HashGet
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 不能为null
|
||||
*/
|
||||
public Object hget(String key, String item) {
|
||||
return redisTemplate.opsForHash().get(key, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取hashKey对应的所有键值
|
||||
*
|
||||
* @param key 键
|
||||
* @return 对应的多个键值
|
||||
*/
|
||||
public Map<Object, Object> hmget(String key) {
|
||||
return redisTemplate.opsForHash().entries(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* HashSet
|
||||
*
|
||||
* @param key 键
|
||||
* @param map 对应多个键值
|
||||
*/
|
||||
public boolean hmset(String key, Map<String, Object> map) {
|
||||
try {
|
||||
redisTemplate.opsForHash().putAll(key, map);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HashSet 并设置时间
|
||||
*
|
||||
* @param key 键
|
||||
* @param map 对应多个键值
|
||||
* @param time 时间(秒)
|
||||
* @return true成功 false失败
|
||||
*/
|
||||
public boolean hmset(String key, Map<String, Object> map, long time, TimeUnit timeUnit) {
|
||||
try {
|
||||
redisTemplate.opsForHash().putAll(key, map);
|
||||
if (time > 0) {
|
||||
expire(key, time, timeUnit);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 向一张hash表中放入数据,如果不存在将创建
|
||||
*
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param value 值
|
||||
* @return true 成功 false失败
|
||||
*/
|
||||
public boolean hset(String key, String item, Object value) {
|
||||
try {
|
||||
redisTemplate.opsForHash().put(key, item, value);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向一张hash表中放入数据,如果不存在将创建
|
||||
*
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param value 值
|
||||
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
|
||||
* @return true 成功 false失败
|
||||
*/
|
||||
public boolean hset(String key, String item, Object value, long time, TimeUnit timeUnit) {
|
||||
try {
|
||||
redisTemplate.opsForHash().put(key, item, value);
|
||||
if (time > 0) {
|
||||
expire(key, time, timeUnit);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除hash表中的值
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 可以使多个 不能为null
|
||||
*/
|
||||
public void hdel(String key, Object... item) {
|
||||
redisTemplate.opsForHash().delete(key, item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断hash表中是否有该项的值
|
||||
*
|
||||
* @param key 键 不能为null
|
||||
* @param item 项 不能为null
|
||||
* @return true 存在 false不存在
|
||||
*/
|
||||
public boolean hHasKey(String key, String item) {
|
||||
return redisTemplate.opsForHash().hasKey(key, item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
|
||||
*
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param by 要增加几(大于0)
|
||||
*/
|
||||
public double hincr(String key, String item, double by) {
|
||||
return redisTemplate.opsForHash().increment(key, item, by);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hash递减
|
||||
*
|
||||
* @param key 键
|
||||
* @param item 项
|
||||
* @param by 要减少记(小于0)
|
||||
*/
|
||||
public double hdecr(String key, String item, double by) {
|
||||
return redisTemplate.opsForHash().increment(key, item, -by);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.jsowell.common.core.text;
|
||||
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 字符集工具类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class CharsetKit {
|
||||
/**
|
||||
* ISO-8859-1
|
||||
*/
|
||||
public static final String ISO_8859_1 = "ISO-8859-1";
|
||||
/**
|
||||
* UTF-8
|
||||
*/
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
/**
|
||||
* GBK
|
||||
*/
|
||||
public static final String GBK = "GBK";
|
||||
|
||||
/**
|
||||
* ISO-8859-1
|
||||
*/
|
||||
public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
|
||||
/**
|
||||
* UTF-8
|
||||
*/
|
||||
public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
|
||||
/**
|
||||
* GBK
|
||||
*/
|
||||
public static final Charset CHARSET_GBK = Charset.forName(GBK);
|
||||
|
||||
/**
|
||||
* 转换为Charset对象
|
||||
*
|
||||
* @param charset 字符集,为空则返回默认字符集
|
||||
* @return Charset
|
||||
*/
|
||||
public static Charset charset(String charset) {
|
||||
return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换字符串的字符集编码
|
||||
*
|
||||
* @param source 字符串
|
||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||
* @param destCharset 目标字符集,默认UTF-8
|
||||
* @return 转换后的字符集
|
||||
*/
|
||||
public static String convert(String source, String srcCharset, String destCharset) {
|
||||
return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换字符串的字符集编码
|
||||
*
|
||||
* @param source 字符串
|
||||
* @param srcCharset 源字符集,默认ISO-8859-1
|
||||
* @param destCharset 目标字符集,默认UTF-8
|
||||
* @return 转换后的字符集
|
||||
*/
|
||||
public static String convert(String source, Charset srcCharset, Charset destCharset) {
|
||||
if (null == srcCharset) {
|
||||
srcCharset = StandardCharsets.ISO_8859_1;
|
||||
}
|
||||
|
||||
if (null == destCharset) {
|
||||
destCharset = StandardCharsets.UTF_8;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) {
|
||||
return source;
|
||||
}
|
||||
return new String(source.getBytes(srcCharset), destCharset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 系统字符集编码
|
||||
*/
|
||||
public static String systemCharset() {
|
||||
return Charset.defaultCharset().name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,849 @@
|
||||
package com.jsowell.common.core.text;
|
||||
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 类型转换器
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class Convert {
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value, String defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value) {
|
||||
return toStr(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value, Character defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
return (Character) value;
|
||||
}
|
||||
|
||||
final String valueStr = toStr(value, null);
|
||||
return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value) {
|
||||
return toChar(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value, Byte defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Byte) {
|
||||
return (Byte) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).byteValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Byte.parseByte(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value) {
|
||||
return toByte(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value, Short defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Short) {
|
||||
return (Short) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).shortValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Short.parseShort(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value) {
|
||||
return toShort(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value, Number defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return (Number) value;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return NumberFormat.getInstance().parse(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value) {
|
||||
return toNumber(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value, Integer defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value) {
|
||||
return toInt(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String str) {
|
||||
return toIntArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String str) {
|
||||
return toLongArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Integer[]{};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Integer[] ints = new Integer[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Integer v = toInt(arr[i], 0);
|
||||
ints[i] = v;
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Long[]{};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Long[] longs = new Long[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Long v = toLong(arr[i], null);
|
||||
longs[i] = v;
|
||||
}
|
||||
return longs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String str) {
|
||||
return toStrArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String split, String str) {
|
||||
return str.split(split);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value, Long defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).longValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value) {
|
||||
return toLong(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value, Double defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
return (Double) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).doubleValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).doubleValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value) {
|
||||
return toDouble(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value, Float defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Float) {
|
||||
return (Float) value;
|
||||
}
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).floatValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Float.parseFloat(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value) {
|
||||
return toFloat(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value, Boolean defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
valueStr = valueStr.trim().toLowerCase();
|
||||
switch (valueStr) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "ok":
|
||||
case "1":
|
||||
return true;
|
||||
case "false":
|
||||
case "no":
|
||||
case "0":
|
||||
return false;
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value) {
|
||||
return toBool(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @param defaultValue 默认值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (clazz.isAssignableFrom(value.getClass())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E myE = (E) value;
|
||||
return myE;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Enum.valueOf(clazz, valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
|
||||
return toEnum(clazz, value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigInteger) {
|
||||
return (BigInteger) value;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return BigInteger.valueOf((Long) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigInteger(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value) {
|
||||
return toBigInteger(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof BigDecimal) {
|
||||
return (BigDecimal) value;
|
||||
}
|
||||
if (value instanceof Long) {
|
||||
return new BigDecimal((Long) value);
|
||||
}
|
||||
if (value instanceof Double) {
|
||||
return new BigDecimal((Double) value);
|
||||
}
|
||||
if (value instanceof Integer) {
|
||||
return new BigDecimal((Integer) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value) {
|
||||
return toBigDecimal(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String utf8Str(Object obj) {
|
||||
return str(obj, CharsetKit.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charsetName 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, String charsetName) {
|
||||
return str(obj, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, Charset charset) {
|
||||
if (null == obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
return (String) obj;
|
||||
} else if (obj instanceof byte[]) {
|
||||
return str((byte[]) obj, charset);
|
||||
} else if (obj instanceof Byte[]) {
|
||||
byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj);
|
||||
return str(bytes, charset);
|
||||
} else if (obj instanceof ByteBuffer) {
|
||||
return str((ByteBuffer) obj, charset);
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte数组转为字符串
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(byte[] bytes, String charset) {
|
||||
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码字节码
|
||||
*
|
||||
* @param data 字符串
|
||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||
* @return 解码后的字符串
|
||||
*/
|
||||
public static String str(byte[] data, Charset charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (null == charset) {
|
||||
return new String(data);
|
||||
}
|
||||
return new String(data, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, String charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return str(data, Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, Charset charset) {
|
||||
if (null == charset) {
|
||||
charset = Charset.defaultCharset();
|
||||
}
|
||||
return charset.decode(data).toString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- 全角半角转换
|
||||
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input) {
|
||||
return toSBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input, Set<Character> notConvertSet) {
|
||||
char[] c = input.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c[i] == ' ') {
|
||||
c[i] = '\u3000';
|
||||
} else if (c[i] < '\177') {
|
||||
c[i] = (char) (c[i] + 65248);
|
||||
|
||||
}
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全角转半角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 半角字符串
|
||||
*/
|
||||
public static String toDBC(String input) {
|
||||
return toDBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换全角为半角
|
||||
*
|
||||
* @param text 文本
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 替换后的字符
|
||||
*/
|
||||
public static String toDBC(String text, Set<Character> notConvertSet) {
|
||||
char[] c = text.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c[i] == '\u3000') {
|
||||
c[i] = ' ';
|
||||
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
}
|
||||
String returnString = new String(c);
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||
*
|
||||
* @param n 数字
|
||||
* @return 中文大写数字
|
||||
*/
|
||||
public static String digitUppercase(double n) {
|
||||
String[] fraction = {"角", "分"};
|
||||
String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
||||
String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
|
||||
|
||||
String head = n < 0 ? "负" : "";
|
||||
n = Math.abs(n);
|
||||
|
||||
String s = "";
|
||||
for (int i = 0; i < fraction.length; i++) {
|
||||
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
||||
}
|
||||
if (s.length() < 1) {
|
||||
s = "整";
|
||||
}
|
||||
int integerPart = (int) Math.floor(n);
|
||||
|
||||
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
|
||||
String p = "";
|
||||
for (int j = 0; j < unit[1].length && n > 0; j++) {
|
||||
p = digit[integerPart % 10] + unit[1][j] + p;
|
||||
integerPart = integerPart / 10;
|
||||
}
|
||||
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s;
|
||||
}
|
||||
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.jsowell.common.core.text;
|
||||
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 字符串格式化
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class StrFormatter {
|
||||
public static final String EMPTY_JSON = "{}";
|
||||
public static final char C_BACKSLASH = '\\';
|
||||
public static final char C_DELIM_START = '{';
|
||||
public static final char C_DELIM_END = '}';
|
||||
|
||||
/**
|
||||
* 格式化字符串<br>
|
||||
* 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
|
||||
* 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
|
||||
* 例:<br>
|
||||
* 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
|
||||
* 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
|
||||
* 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
|
||||
*
|
||||
* @param strPattern 字符串模板
|
||||
* @param argArray 参数列表
|
||||
* @return 结果
|
||||
*/
|
||||
public static String format(final String strPattern, final Object... argArray) {
|
||||
if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) {
|
||||
return strPattern;
|
||||
}
|
||||
final int strPatternLength = strPattern.length();
|
||||
|
||||
// 初始化定义好的长度以获得更好的性能
|
||||
StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
|
||||
|
||||
int handledPosition = 0;
|
||||
int delimIndex;// 占位符所在位置
|
||||
for (int argIndex = 0; argIndex < argArray.length; argIndex++) {
|
||||
delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
|
||||
if (delimIndex == -1) {
|
||||
if (handledPosition == 0) {
|
||||
return strPattern;
|
||||
} else { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
|
||||
sbuf.append(strPattern, handledPosition, strPatternLength);
|
||||
return sbuf.toString();
|
||||
}
|
||||
} else {
|
||||
if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) {
|
||||
if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) {
|
||||
// 转义符之前还有一个转义符,占位符依旧有效
|
||||
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
||||
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
||||
handledPosition = delimIndex + 2;
|
||||
} else {
|
||||
// 占位符被转义
|
||||
argIndex--;
|
||||
sbuf.append(strPattern, handledPosition, delimIndex - 1);
|
||||
sbuf.append(C_DELIM_START);
|
||||
handledPosition = delimIndex + 1;
|
||||
}
|
||||
} else {
|
||||
// 正常占位符
|
||||
sbuf.append(strPattern, handledPosition, delimIndex);
|
||||
sbuf.append(Convert.utf8Str(argArray[argIndex]));
|
||||
handledPosition = delimIndex + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 加入最后一个占位符后所有的字符
|
||||
sbuf.append(strPattern, handledPosition, strPattern.length());
|
||||
|
||||
return sbuf.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 操作状态
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public enum BusinessStatus {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS,
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAIL,
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 业务操作类型
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public enum BusinessType {
|
||||
/**
|
||||
* 其它
|
||||
*/
|
||||
OTHER,
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
INSERT,
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
UPDATE,
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
DELETE,
|
||||
|
||||
/**
|
||||
* 授权
|
||||
*/
|
||||
GRANT,
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
EXPORT,
|
||||
|
||||
/**
|
||||
* 导入
|
||||
*/
|
||||
IMPORT,
|
||||
|
||||
/**
|
||||
* 强退
|
||||
*/
|
||||
FORCE,
|
||||
|
||||
/**
|
||||
* 生成代码
|
||||
*/
|
||||
GENCODE,
|
||||
|
||||
/**
|
||||
* 清空数据
|
||||
*/
|
||||
CLEAN,
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public enum DataSourceType {
|
||||
/**
|
||||
* 主库
|
||||
*/
|
||||
MASTER,
|
||||
|
||||
/**
|
||||
* 从库
|
||||
*/
|
||||
SLAVE
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 删除标识枚举
|
||||
*/
|
||||
public enum DelFlagEnum {
|
||||
normal("0", "正常"),
|
||||
delete("1", "删除"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
DelFlagEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 请求方式
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public enum HttpMethod {
|
||||
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
|
||||
|
||||
private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
|
||||
|
||||
static {
|
||||
for (HttpMethod httpMethod : values()) {
|
||||
mappings.put(httpMethod.name(), httpMethod);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static HttpMethod resolve(@Nullable String method) {
|
||||
return (method != null ? mappings.get(method) : null);
|
||||
}
|
||||
|
||||
public boolean matches(String method) {
|
||||
return (this == resolve(method));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 限流类型
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
|
||||
public enum LimitType {
|
||||
/**
|
||||
* 默认策略全局限流
|
||||
*/
|
||||
DEFAULT,
|
||||
|
||||
/**
|
||||
* 根据请求者IP进行限流
|
||||
*/
|
||||
IP
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 会员钱包enum
|
||||
*/
|
||||
public enum MemberWalletEnum {
|
||||
|
||||
/**
|
||||
* 更新类型
|
||||
* 1-进账;2-出账
|
||||
*/
|
||||
TYPE_IN("1", "进账"),
|
||||
TYPE_OUT("2", "出账"),
|
||||
|
||||
/**
|
||||
* 子类型
|
||||
* 进账:10-充值, 11-赠送, 12-订单结算退款
|
||||
* 出账:20-后管扣款, 21-订单付款, 22-用户退款
|
||||
*/
|
||||
SUBTYPE_TOP_UP("10", "充值"),
|
||||
SUBTYPE_GIVING("11", "赠送"),
|
||||
SUBTYPE_ORDER_SETTLEMENT_REFUND("12", "订单结算退款"),
|
||||
|
||||
SUBTYPE_WEB_DEDUCT_MONEY("20", "后管扣款"),
|
||||
SUBTYPE_PAYMENT_FOR_ORDER("21", "订单付款"),
|
||||
SUBTYPE_USER_REFUND("22", "用户退款"),
|
||||
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
MemberWalletEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 操作人类别
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public enum OperatorType {
|
||||
/**
|
||||
* 其它
|
||||
*/
|
||||
OTHER,
|
||||
|
||||
/**
|
||||
* 后台用户
|
||||
*/
|
||||
MANAGE,
|
||||
|
||||
/**
|
||||
* 手机端用户
|
||||
*/
|
||||
MOBILE
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 软件协议enum
|
||||
*/
|
||||
public enum SoftwareProtocolEnum {
|
||||
YUN_KUAI_CHONG("1", "云快充"),
|
||||
YONG_LIAN("2", "永联"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
SoftwareProtocolEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.jsowell.common.enums;
|
||||
|
||||
/**
|
||||
* 用户状态
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public enum UserStatus {
|
||||
OK("0" , "正常"),
|
||||
DISABLE("1" , "停用"),
|
||||
DELETED("2" , "删除");
|
||||
|
||||
private final String code;
|
||||
private final String info;
|
||||
|
||||
UserStatus(String code, String info) {
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.jsowell.common.enums.sim;
|
||||
|
||||
|
||||
/**
|
||||
* Sim卡状态对应Enum
|
||||
* (WuLian)
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2023/1/5 10:59
|
||||
*/
|
||||
public enum SimCardStatusCorrespondEnum {
|
||||
// 正常
|
||||
NORMAL("9", "0"),
|
||||
|
||||
// 断网
|
||||
OFFLINE("5", "1"),
|
||||
|
||||
// 销卡
|
||||
PIN_CARD("99", "6"),
|
||||
|
||||
// 服务结束
|
||||
SERVICE_FINISHED("20", "1"),
|
||||
|
||||
// 未开卡
|
||||
NOT_OPEN_CARD("0", "7"),
|
||||
|
||||
// 沉默期
|
||||
SILENCE_PERIOD("2", "8"),
|
||||
|
||||
// 已停机
|
||||
SHUT_DOWN_CARD("4", "9"),
|
||||
|
||||
// 待激活
|
||||
INACTIVE_CARD("8", "10"),
|
||||
|
||||
// 已回收
|
||||
RECYCLE_CARD("21", "11"),
|
||||
|
||||
// 未知
|
||||
UN_KNOW("80", "99"),
|
||||
|
||||
;
|
||||
private String WuLianCardStatus;
|
||||
private String dataBaseCardStatus;
|
||||
|
||||
public String getWuLianCardStatus() {
|
||||
return WuLianCardStatus;
|
||||
}
|
||||
|
||||
public void setWuLianCardStatus(String wuLianCardStatus) {
|
||||
WuLianCardStatus = wuLianCardStatus;
|
||||
}
|
||||
|
||||
public String getDataBaseCardStatus() {
|
||||
return dataBaseCardStatus;
|
||||
}
|
||||
|
||||
public void setDataBaseCardStatus(String dataBaseCardStatus) {
|
||||
this.dataBaseCardStatus = dataBaseCardStatus;
|
||||
}
|
||||
|
||||
SimCardStatusCorrespondEnum(String wuLianCardStatus, String dataBaseCardStatus) {
|
||||
WuLianCardStatus = wuLianCardStatus;
|
||||
this.dataBaseCardStatus = dataBaseCardStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 WuLianCardStatus 获取 dataBaseCardStatus
|
||||
* @param WuLianCardStatus
|
||||
* @return
|
||||
*/
|
||||
public static String getDataBaseCardStatus(String WuLianCardStatus) {
|
||||
for (SimCardStatusCorrespondEnum item : SimCardStatusCorrespondEnum.values()) {
|
||||
if (item.getWuLianCardStatus().equals(WuLianCardStatus)) {
|
||||
return item.getDataBaseCardStatus();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.jsowell.common.enums.sim;
|
||||
|
||||
|
||||
/**
|
||||
* Sim卡商
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2022/12/17 14:30
|
||||
*/
|
||||
public enum SimSupplierEnum {
|
||||
XUN_ZHONG("1", "讯众物联"),
|
||||
WU_LIAN_INTERNET("2", "物联网智能云平台")
|
||||
|
||||
|
||||
;
|
||||
private String code;
|
||||
private String name;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
SimSupplierEnum(String code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取name
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static String getNameByCode(String code) {
|
||||
for (SimSupplierEnum item : SimSupplierEnum.values()) {
|
||||
if (item.getCode().equals(code)) {
|
||||
return item.getName();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.jsowell.common.enums.uniapp;
|
||||
|
||||
import com.jsowell.common.enums.ykc.StopChargingFailedReasonEnum;
|
||||
|
||||
/**
|
||||
* 用户账户余额Enum
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2022/11/26 11:34
|
||||
*/
|
||||
public enum BalanceChangesEnum {
|
||||
/**
|
||||
* 进账
|
||||
*/
|
||||
CODE_RECHARGE("10", "充值"),
|
||||
|
||||
CODE_PRESENTED("11", "赠送"),
|
||||
|
||||
CODE_ORDER_SETTLEMENT_REFUND("12", "订单结算退款"),
|
||||
|
||||
|
||||
/**
|
||||
* 出账
|
||||
*/
|
||||
CODE_SYSTEM_DEDUCTIONS("20", "后管扣款"),
|
||||
|
||||
CODE_ORDER_PAYMENT("21", "订单付款"),
|
||||
|
||||
CODE_USER_REFUND("22", "用户退款"),
|
||||
;
|
||||
private String code;
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
BalanceChangesEnum(String code, String value) {
|
||||
this.value = value;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取value
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static String getValueByCode(String code) {
|
||||
for (BalanceChangesEnum item : BalanceChangesEnum.values()) {
|
||||
if (item.getCode().equals(code)) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.jsowell.common.enums.weixin;
|
||||
|
||||
/**
|
||||
* 业务类型
|
||||
*
|
||||
* @author xiaojiewen
|
||||
*/
|
||||
|
||||
public enum BusinessType {
|
||||
|
||||
CLIENT("客户端", 6L),
|
||||
DISTRIBUTOR("分销商", 2L),
|
||||
MERCHANT("服务商", 3L),
|
||||
OTHER("其他", 0L)
|
||||
|
||||
;
|
||||
|
||||
private String type;
|
||||
|
||||
private Long enumType;
|
||||
|
||||
BusinessType(String type, Long enumType) {
|
||||
this.type = type;
|
||||
this.enumType = enumType;
|
||||
}
|
||||
|
||||
public Long getEnumType() {
|
||||
return enumType;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.jsowell.common.enums.weixin;
|
||||
|
||||
/**
|
||||
* 微信支付参数
|
||||
* WeiXinPayParam<BR>
|
||||
* 创建人:小威 <BR>
|
||||
* 时间:2015年12月1日-下午4:41:02 <BR>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public enum WeiXinPayParam {
|
||||
|
||||
WEIXIN_PAY_DATA("data", "微信支付数据"),
|
||||
WEIXIN_PAY_ID("id", "缓存id"),
|
||||
WEIXIN_PAY_ORDERID("orderId", "订单id"),
|
||||
WEIXIN_PAY_MONEY("money", "支付价格");
|
||||
|
||||
|
||||
private String value;
|
||||
private String desc;
|
||||
|
||||
WeiXinPayParam(String value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.jsowell.common.enums.weixin;
|
||||
|
||||
/**
|
||||
* 微信支付交易状态
|
||||
* WeiXinPayTradeStatus<BR>
|
||||
* 创建人:小威 <BR>
|
||||
* 时间:2015年12月1日-下午4:37:55 <BR>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public enum WeiXinPayTradeStatus {
|
||||
SUCCESS("SUCCESS", "交易成功"),
|
||||
FAIL("FAIL", "交易失败");
|
||||
private String value;
|
||||
private String desc;
|
||||
|
||||
WeiXinPayTradeStatus(String value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 操作类型枚举
|
||||
*/
|
||||
public enum ActionTypeEnum {
|
||||
FORWARD("forward", "正向"),
|
||||
REVERSE("reverse", "逆向"),
|
||||
;
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
ActionTypeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 计费模板 时间类型
|
||||
* (1-尖时;2-峰时;3-平时;4-谷时)
|
||||
*/
|
||||
public enum BillingTimeEnum {
|
||||
SHARP("1", "尖时"),
|
||||
PEAK("2", "峰时"),
|
||||
FLAT("3", "平时"),
|
||||
VALLEY("4", "谷时"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
BillingTimeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
public enum BusinessTypeEnum {
|
||||
OPERATING_PILE("1", "运营桩"),
|
||||
INDIVIDUAL_PILE("2", "个人桩"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
BusinessTypeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 启动充电失败原因
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2022/11/16 14:32
|
||||
*/
|
||||
public enum ChargingFailedReasonEnum {
|
||||
NULL(0x00, "无"),
|
||||
EQUIPMENT_PILE_SN_NOT_MATCH(0x01, "设备桩号不匹配"),
|
||||
CONNECTOR_IS_CHARGING(0x02, "枪已在充电"),
|
||||
EQUIPMENT_BREAKDOWN(0x03, "设备故障"),
|
||||
EQUIPMENT_OFFLINE(0x04, "设备离线"),
|
||||
UNPLUGGED_GUN(0x05, "未插枪"),
|
||||
|
||||
;
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
ChargingFailedReasonEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取停止原因描述
|
||||
*
|
||||
* @param code 编码
|
||||
* @return 停止原因描述
|
||||
*/
|
||||
public static String getMsgByCode(int code) {
|
||||
for (ChargingFailedReasonEnum item : ChargingFailedReasonEnum.values()) {
|
||||
if (item.getCode() == code) {
|
||||
return item.getMsg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 订单支付方式enum
|
||||
* 前端给的参数
|
||||
*/
|
||||
public enum OrderPayModeEnum {
|
||||
|
||||
PAYMENT_OF_BALANCE("1", "余额支付"),
|
||||
PAYMENT_OF_WHITELIST("3", "白名单支付"),
|
||||
PAYMENT_OF_WECHATPAY("4", "微信支付"),
|
||||
PAYMENT_OF_ALIPAY("5", "支付宝支付"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static String getPayModeDescription(String value) {
|
||||
for (OrderPayModeEnum orderPayModeEnum : OrderPayModeEnum.values()) {
|
||||
if (orderPayModeEnum.getValue().equals(value)) {
|
||||
return orderPayModeEnum.getLabel();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
OrderPayModeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* order_pay_record表pay_mode字段
|
||||
* 支付方式(1-本金余额支付;2-赠送余额支付;3-白名单支付;4-微信支付;5-支付宝支付)
|
||||
* 后端数据库
|
||||
*/
|
||||
public enum OrderPayRecordEnum {
|
||||
PRINCIPAL_BALANCE_PAYMENT("1", "本金余额支付"),
|
||||
GIFT_BALANCE_PAYMENT("2", "赠送余额支付"),
|
||||
WHITELIST_PAYMENT("3", "白名单支付"),
|
||||
WECHATPAY_PAYMENT("4", "微信支付"),
|
||||
ALIPAY_PAYMENT("5", "支付宝支付"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static String getPayModeDescription(String value) {
|
||||
for (OrderPayRecordEnum orderPayModeEnum : OrderPayRecordEnum.values()) {
|
||||
if (orderPayModeEnum.getValue().equals(value)) {
|
||||
return orderPayModeEnum.getLabel();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
OrderPayRecordEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 订单支付状态
|
||||
*/
|
||||
public enum OrderPayStatusEnum {
|
||||
unpaid("0", "待支付"),
|
||||
paid("1", "支付完成"),
|
||||
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
OrderPayStatusEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* order_basic_info表 order_status字段
|
||||
* 订单状态(0-未启动;1-充电中;2-待结算;3-待补缴;4-异常;5-可疑;6-订单完成;7-超时关闭)
|
||||
*/
|
||||
public enum OrderStatusEnum {
|
||||
|
||||
NOT_START("0", "未启动"),
|
||||
IN_THE_CHARGING("1", "充电中"),
|
||||
STAY_SETTLEMENT("2", "待结算"),
|
||||
STAY_RETROACTIVE_AMOUNT("3", "待补缴"),
|
||||
ABNORMAL("4", "异常"),
|
||||
SUSPICIOUS("5", "可疑"),
|
||||
ORDER_COMPLETE("6", "订单完成"),
|
||||
ORDER_CLOSE_TIMEOUT("7", "超时关闭"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
OrderStatusEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static String getOrderStatus(String value) {
|
||||
for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
|
||||
if (orderStatusEnum.getValue().equals(value)) {
|
||||
return orderStatusEnum.getLabel();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
public enum PayModeEnum {
|
||||
PAYMENT_OF_BALANCE("balance", "余额支付"),
|
||||
PAYMENT_OF_WHITELIST("whitelist", "白名单支付"),
|
||||
PAYMENT_OF_WECHATPAY("wechatpay", "微信支付"),
|
||||
PAYMENT_OF_ALIPAY("alipay", "支付宝支付"),
|
||||
;
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
PayModeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 桩编号和channel的关联关系处理 entity
|
||||
*/
|
||||
public class PileChannelEntity {
|
||||
|
||||
private static HashMap<String, Channel> manager = new HashMap<>();
|
||||
|
||||
public static void put(String pileSn, Channel channel) {
|
||||
manager.put(pileSn, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过桩编号获取channel链接信息
|
||||
* @param pileSn
|
||||
* @return
|
||||
*/
|
||||
public static Channel getChannelByPileSn(String pileSn) {
|
||||
return manager.get(pileSn);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过channelId获取桩编号
|
||||
* @param channelId
|
||||
* @return
|
||||
*/
|
||||
public static String getPileSnByChannelId(String channelId) {
|
||||
for (HashMap.Entry<String, Channel> entry : manager.entrySet()) {
|
||||
if (entry.getValue().id().asLongText().equals(channelId)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印
|
||||
*/
|
||||
public static void output() {
|
||||
for (HashMap.Entry<String, Channel> entry : manager.entrySet()) {
|
||||
System.out.println("pileSn:" + entry.getKey() +
|
||||
",ChannelId:" + entry.getValue().id().asLongText());
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeByPileSn(String pileSn){
|
||||
manager.remove(pileSn);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 充电枪口数据库状态
|
||||
*/
|
||||
public enum PileConnectorDataBaseStatusEnum {
|
||||
|
||||
OFF_NETWORK("0", "离线"),
|
||||
FREE("1", "空闲"),
|
||||
OCCUPIED_NOT_CHARGED("2", "占用(未充电)"),
|
||||
OCCUPIED_CHARGING("3", "占用(充电中)"),
|
||||
OCCUPIED_APPOINTMENT_LOCK("4", "占用(预约锁定)"),
|
||||
FAULT("255", "故障")
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
PileConnectorDataBaseStatusEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static String getStatusDescription(String value) {
|
||||
for (PileConnectorDataBaseStatusEnum statusEnum : PileConnectorDataBaseStatusEnum.values()) {
|
||||
if (statusEnum.getValue().equals(value)) {
|
||||
return statusEnum.getLabel();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 充电接口状态
|
||||
* 桩传过来的枪口状态: 0x00:离线 0x01:故障 0x02:空闲 0x03:充电
|
||||
*/
|
||||
public enum PileConnectorStatusEnum {
|
||||
OFF_NETWORK("00", "离线"),
|
||||
FAULT("01", "故障"),
|
||||
FREE("02", "空闲"),
|
||||
OCCUPIED_CHARGING("03", "充电"),
|
||||
;
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
PileConnectorStatusEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 充电桩状态enum
|
||||
*/
|
||||
public enum PileStatusEnum {
|
||||
UNKNOWN("0", "未知"),
|
||||
ON_LINE("1", "在线"),
|
||||
OFF_LINE("2","离线"),
|
||||
FAULT("3", "故障"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
PileStatusEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static String getStatusDescription(String status) {
|
||||
for (PileStatusEnum pileStatusEnum : PileStatusEnum.values()) {
|
||||
if (pileStatusEnum.getValue().equals(status)) {
|
||||
return pileStatusEnum.getLabel();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
public enum ReturnCodeEnum {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
CODE_SUCCESS("00100000", "操作成功"),
|
||||
|
||||
CODE_TOKEN_ERROR("00100002", "身份验证失败,请重新登录"),
|
||||
|
||||
CODE_PARAM_NOT_NULL_ERROR("00100003", "参数不能为空"),
|
||||
|
||||
CODE_VERIFICATION_CODE_ERROR("00100004", "验证码错误"),
|
||||
|
||||
CODE_VERIFICATION_CODE_TIMEOUT_ERROR("00100005", "验证码超时"),
|
||||
|
||||
CODE_SEND_SMS_ERROR("00100006", "发送短信验证码错误"),
|
||||
|
||||
CODE_MEMBER_REGISTER_AND_LOGIN_ERROR("00100007", "会员登录注册接口异常"),
|
||||
|
||||
CODE_WECHAT_LOGIN_ERROR("00100008", "微信登录异常"),
|
||||
|
||||
CODE_GET_MEMBER_PHONE_NUMBER_ERROR("00100009", "获取用户手机号异常"),
|
||||
|
||||
CODE_HANDLE_USER_INFO_ERROR("00100010", "处理用户信息异常"),
|
||||
|
||||
CODE_GET_PILE_STATION_INFO_ERROR("00100011", "查询充电站信息列表异常"),
|
||||
|
||||
CODE_GET_CONNECTOR_INFO_BY_STATION_ID_ERROR("00100012", "通过站点id查询充电枪口列表异常"),
|
||||
|
||||
CODE_PILE_CONNECTOR_STATUS_ERROR("00100013", "该枪口状态不正确"),
|
||||
|
||||
CODE_GENERATE_ORDER_ERROR("00100014", "生成订单失败"),
|
||||
|
||||
CODE_CONNECTOR_INFO_NULL_ERROR("00100015", "充电枪口为空"),
|
||||
|
||||
CODE_BILLING_TEMPLATE_NULL_ERROR("00100016", "查询充电桩的计费模板为空"),
|
||||
|
||||
CODE_DATA_LENGTH_ERROR("00100017", "数据长度不正确"),
|
||||
|
||||
CODE_SETTLE_ORDER_ERROR("00100018", "订单结算异常"),
|
||||
|
||||
CODE_ORDER_INFO_ERROR("00100019", "订单信息有误"),
|
||||
|
||||
CODE_QUERY_ORDER_NULL_ERROR("00100020", "查询订单为空"),
|
||||
|
||||
CODE_ORDER_PILE_MAPPING_ERROR("00100021", "订单与当前桩不匹配"),
|
||||
|
||||
CODE_GET_MEMBER_ACCOUNT_AMOUNT_ERROR("00100022", "查询用户账户总余额异常"),
|
||||
|
||||
CODE_BALANCE_IS_INSUFFICIENT("00100023", "账户余额不足"),
|
||||
|
||||
CODE_GET_MOBILE_NUMBER_BY_CODE_ERROR("00100024", "获取微信登录手机号失败"),
|
||||
|
||||
CODE_GET_MERCHANT_ID_BY_APP_ID_ERROR("00100024", "获取商户id失败"),
|
||||
|
||||
CODE_GET_ORDER_INFO_BY_MEMBER_ID_ERROR("00100025", "通过会员Id查询某状态订单失败"),
|
||||
|
||||
CODE_GET_OPEN_ID_BY_CODE_ERROR("00100026", "获取openid失败"),
|
||||
|
||||
CODE_GET_WECHAT_PAY_PARAMETER_ERROR("00100027", "获取微信支付参数失败"),
|
||||
|
||||
CODE_GET_BALANCE_CHANGES_ERROR("00100028", "查询用户账户余额变动信息异常"),
|
||||
|
||||
CODE_ORDER_PAY_ERROR("00100029", "订单支付失败"),
|
||||
|
||||
CODE_ORDER_PAY_CALLBACK_ERROR("00100030", "支付回调失败"),
|
||||
|
||||
CODE_ORDER_IS_NOT_TO_BE_PAID_ERROR("00100031", "订单不是待支付状态"),
|
||||
|
||||
CODE_ORDER_MEMBER_NOT_MATCH_ERROR("00100032", "订单与会员信息不匹配"),
|
||||
|
||||
CODE_STOP_CHARGING_ERROR("00100033", "停止充电失败"),
|
||||
|
||||
CODE_ORDER_IS_NOT_STAY_SETTLEMENT_ERROR("00100034", "订单不是待结算状态"),
|
||||
|
||||
CODE_GET_PILE_DETAIL_ERROR("00100035", "查询充电桩详情失败"),
|
||||
|
||||
CODE_WEIXIN_REFUND_ERROR("00100036", "微信退款接口失败"),
|
||||
|
||||
CODE_REFUND_ORDER_AMOUNT_ERROR("00100037", "订单退款金额不能大于可退金额"),
|
||||
|
||||
CODE_REFUND_ORDER_CALLBACK_RECORD_ERROR("00100038", "订单退款处理逻辑, 查询订单微信支付记录为空!"),
|
||||
|
||||
CODE_SELECT_MEMBER_NULL_ERROR("00100039", "没有查询到会员信息"),
|
||||
|
||||
CODE_REFUND_MEMBER_BALANCE_ERROR("00100040", "退款金额不能大于本金金额"),
|
||||
|
||||
CODE_GET_ORDER_DETAIL_ERROR("00100041", "小程序获取订单详情失败"),
|
||||
|
||||
CODE_SELECT_PILE_STARTER_STATUS("00100042", "根据订单号查询充电桩启动状态失败"),
|
||||
|
||||
CODE_PILE_HAS_BEEN_BINDING_ERROR("00400001", "此桩已被绑定,请联系管理员!"),
|
||||
|
||||
CODE_AUTHENTICATION_ERROR("00400002", "您的身份信息验证有误,请重试!"),
|
||||
|
||||
CODE_USER_IS_NOT_REGISTER("00400003", "此用户未注册平台账号,请核实身份!"),
|
||||
|
||||
CODE_USER_HAS_BEEN_THIS_PILE("00400004", "此用户已绑定该桩,请检查!"),
|
||||
|
||||
CODE_NO_CHARGING_ORDER_ERROR("00400005", "当前无正在充电的订单"),
|
||||
|
||||
CODE_NO_REAL_TIME_INFO("00400006", "未查到充电枪口实时信息"),
|
||||
|
||||
CODE_BINDING_PERSONAL_PILE_ERROR("00400007", "获取个人桩枪口实时数据异常"),
|
||||
|
||||
CODE_ADMIN_ISSUE_ERROR("00400008", "桩管理员下发个人桩异常"),
|
||||
|
||||
CODE_GET_PERSONAL_PILE_BY_MEMBER_ID_ERROR("00400009", "通过memberId查个人桩列表异常"),
|
||||
|
||||
CODE_GET_PERSONAL_PILE_CONNECTOR_INFO_ERROR("00400010", "获取个人桩枪口实时数据异常"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
|
||||
private String label;
|
||||
|
||||
private ReturnCodeEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 支付场景枚举
|
||||
*/
|
||||
public enum ScenarioEnum {
|
||||
ORDER("order", "支付订单"),
|
||||
|
||||
BALANCE("balance", "支付余额"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String label;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
ScenarioEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 远程停止充电失败原因enum
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2022/11/16 8:31
|
||||
*/
|
||||
public enum StopChargingFailedReasonEnum {
|
||||
NULL("00", "无"),
|
||||
EQUIPMENT_CODE_NOT_MATCH("01", "设备编号不匹配"),
|
||||
CONNECTOR_NOT_IN_CHARGING("02", "枪未处于充电状态"),
|
||||
OTHER("03","其他"),
|
||||
|
||||
|
||||
;
|
||||
private String code;
|
||||
private String msg;
|
||||
|
||||
StopChargingFailedReasonEnum(String code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取msg
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static String getMsgByCode(String code) {
|
||||
for (StopChargingFailedReasonEnum item : StopChargingFailedReasonEnum.values()) {
|
||||
if (item.getCode().equals(code)) {
|
||||
return item.getMsg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
|
||||
/**
|
||||
* 云快充充电停止原因enum
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2022/11/4 16:46
|
||||
*/
|
||||
public enum YKCChargingStopReasonEnum {
|
||||
/**
|
||||
* 充电完成
|
||||
*/
|
||||
APP_REMOTE_STOP(0x40, "结束充电,APP远程停止"),
|
||||
SOC_FULL(0x41, "结束充电,SOC 达到 100%"),
|
||||
CHARGING_ELECTRICITY_ELIGIBLE(0x42, "结束充电,充电电量满足设定条件"),
|
||||
CHARGING_AMOUNT_ELIGIBLE(0x43, "结束充电,充电金额满足设定条件"),
|
||||
CHARGING_TIME_ELIGIBLE(0x44, "结束充电,充电时间满足设定条件"),
|
||||
MANUALLY_STOP_CHARGING(0x45, "结束充电,手动停止充电"),
|
||||
|
||||
OTHER_FORTY_SIX(0x46, "其他方式(预留)"),
|
||||
OTHER_FORTY_SEVEN(0x47, "其他方式(预留)"),
|
||||
OTHER_FORTY_EIGHT(0x48, "其他方式(预留)"),
|
||||
OTHER_FORTY_NINE(0x49, "其他方式(预留)"),
|
||||
|
||||
/**
|
||||
* 充电启动失败
|
||||
*/
|
||||
PILE_CONTROL_SYSTEM_FAULT(0x4A, "充电启动失败,充电桩控制系统故障(需要重启或自动恢复)"),
|
||||
CONTROL_GUIDANCE_BREAK(0x4B, "充电启动失败,控制导引断开"),
|
||||
CIRCUIT_BREAKER_TRIP(0x4C, "充电启动失败,断路器跳位"),
|
||||
AMMETER_COMMUNICATION_BREAK(0x4D, "充电启动失败,电表通信中断"),
|
||||
LACK_OF_BALANCE(0x4E, "充电启动失败,余额不足"),
|
||||
CHARGING_MODEL_FAULT(0x4F, "充电启动失败,充电模块故障"),
|
||||
EMERGENCY_STOP_FAULT(0x50, "充电启动失败,急停开入"),
|
||||
SPD_ABNORMAL(0x51, "充电启动失败,防雷器异常"),
|
||||
BMS_UNREADY(0x52, "充电启动失败, BMS 未就绪"),
|
||||
TEMPERATURE_ABNORMAL(0x53, "充电启动失败,温度异常"),
|
||||
BATTERY_REVERSE_CONNECT_FAULT(0x54, "充电启动失败,电池反接故障"),
|
||||
ELECTRICITY_LOCK_FAULT(0x55, "充电启动失败,电子锁异常"),
|
||||
FAIL_CLOSE_ACT(0x56, "充电启动失败,合闸失败"),
|
||||
INSULATION_FAULT(0x57, "充电启动失败,绝缘异常"),
|
||||
RESERVED_FIFTY_EIGHT(0x58, "预留"),
|
||||
RECEIVED_BMS_HANDSHAKE_REPORT_TIMEOUT(0x59, "充电启动失败,接收 BMS 握手报文 BHM 超时"),
|
||||
RECEIVED_BMS_AND_CAR_IDENTIFY_REPORT_TIMEOUT(0x5A, "充电启动失败,接收 BMS 和车辆的辨识报文超时 BRM"),
|
||||
RECEIVED_BATTERY_CHARGING_DATA_TIMEOUT(0x5B, "充电启动失败,接收电池充电参数报文超时 BCP"),
|
||||
RECEIVED_CHARGING_COMPLETE_REPORT_TIMEOUT(0x5C, "充电启动失败,接收 BMS 完成充电准备报文超时 BRO AA"),
|
||||
RECEIVED_CHARGING_STATUS_REPORT_TIMEOUT(0x5D, "充电启动失败,接收电池充电总状态报文超时 BCS"),
|
||||
RECEIVED_CHARGING_REQUEST_REPORT_TIMEOUT(0x5E, "充电启动失败,接收电池充电要求报文超时 BCL"),
|
||||
RECEIVED_BATTERY_STATUS_TIMEOUT(0x5F, "充电启动失败,接收电池状态信息报文超时 BSM"),
|
||||
GB_2015_PROHIBIT_CHARGING_AT_BHM(0x60, "充电启动失败, GB2015 电池在 BHM 阶段有电压不允许充电"),
|
||||
GB_2015_BATTERY_VOLTAGE_GAP(0x61, "充电启动失败, GB2015 辨识阶段在 BRO_AA 时候电池实际电压 与 BCP 报文电池电压差距大于 5%"),
|
||||
B_2015_CHARGER_BRO_AA_TO_BRO_OO(0x62, "充电启动失败, B2015 充电机在预充电阶段从 BRO_AA 变成 BRO_00 状态"),
|
||||
RECEIVED_HOST_CONFIG_REPORT_TIMEOUT(0x63, "充电启动失败,接收主机配置报文超时"),
|
||||
CHARGER_UNREADY(0x64, "充电启动失败,充电机未准备就绪,我们没有回 CRO AA,对应 老国标"),
|
||||
|
||||
OTHER_SIXTY_FIVE(0x65, "(其他原因)预留"),
|
||||
OTHER_SIXTY_SIX(0x66, "(其他原因)预留"),
|
||||
OTHER_SIXTY_SEVEN(0x67, "(其他原因)预留"),
|
||||
OTHER_SIXTY_EIGHT(0x68, "(其他原因)预留"),
|
||||
OTHER_SIXTY_NINE(0x69, "(其他原因)预留"),
|
||||
|
||||
/**
|
||||
* 充电异常中止
|
||||
*/
|
||||
SYSTEM_CLOSE_LOCK(0x6A, "充电异常中止,系统闭锁"),
|
||||
GUIDANCE_BREAK(0x6B, "充电异常中止,导引断开"),
|
||||
BREAKER_TRIP(0x6C, "充电异常中止,断路器跳位"),
|
||||
AMMETER_COMMUNICATION_INTERRUPT(0x6D, "充电异常中止,电表通信中断"),
|
||||
NOT_SUFFICIENT_FUNDS(0x6E, "充电异常中止,余额不足"),
|
||||
AC_PROTECT_ACTION(0x6F, "充电异常中止,交流保护动作"),
|
||||
DC_PROTECT_ACTION(0x70, "充电异常中止,直流保护动作"),
|
||||
CHARGE_MODEL_UNUSUAL(0x71, "充电异常中止,充电模块故障"),
|
||||
FETCH_UP_UNUSUAL(0x72, "充电异常中止,急停开入"),
|
||||
SPD_UNUSUAL(0x73, "充电异常中止,防雷器异常"),
|
||||
TEMPERATURE_UNUSUAL(0x74, "充电异常中止,温度异常"),
|
||||
OUTPUT_UNUSUAL(0x75, "充电异常中止,输出异常"),
|
||||
CHARGING_NO_CURRENT(0x76, "充电异常中止,充电无流"),
|
||||
ELECTRICITY_LOCK_UNUSUAL(0x77, "充电异常中止,电子锁异常"),
|
||||
|
||||
OTHER_SEVENTY_EIGHT(0x78, "预留"),
|
||||
|
||||
TOTAL_CHARGING_VOLTAGE_UNUSUAL(0x79, "充电异常中止,总充电电压异常"),
|
||||
TOTAL_CHARGING_CURRENT_UNUSUAL(0x7A, "充电异常中止,总充电电流异常"),
|
||||
SINGLE_CHARGING_VOLTAGE_UNUSUAL(0x7B, "充电异常中止,单体充电电压异常"),
|
||||
BATTERY_TEMPERATURE_TOO_HIGH(0x7C, "充电异常中止,电池组过温"),
|
||||
HIGHEST_SINGLE_CHARGING_VOLTAGE_UNUSUAL(0x7D, "充电异常中止,最高单体充电电压异常"),
|
||||
HIGHEST_BATTERY_TEMPERATURE_TOO_HIGH(0x7E, "充电异常中止,最高电池组过温"),
|
||||
BMV_SINGLE_CHARGING_VOLTAGE_UNUSUAL(0x7F, "充电异常中止, BMV 单体充电电压异常"),
|
||||
BMT_BATTERY_TEMPERATURE_TOO_HIGH(0x80, "充电异常中止, BMT 电池组过温"),
|
||||
BATTERY_STATUS_UNUSUAL_STOP_CHARGING(0x81, "充电异常中止,电池状态异常停止充电"),
|
||||
CAR_SEND_REPORT_FORBID_CHARGING(0x82, "充电异常中止,车辆发报文禁止充电"),
|
||||
CHARGING_PILE_OUTAGE(0x83, "充电异常中止,充电桩断电"),
|
||||
RECEIVED_BATTERY_CHARGING_STATUS_TIMEOUT(0x84, "充电异常中止,接收电池充电总状态报文超时"),
|
||||
RECEIVED_BATTERY_CHARGING_REQUEST_TIMEOUT(0x85, "充电异常中止,接收电池充电要求报文超时"),
|
||||
RECEIVED_BATTERY_STATUS_DATA_TIMEOUT(0x86, "充电异常中止,接收电池状态信息报文超时"),
|
||||
RECEIVED_BMS_STOP_CHARGING_TIMEOUT(0x87, "充电异常中止,接收 BMS 中止充电报文超时"),
|
||||
RECEIVED_BMS_CHARGING_STATISTICAL_TIMEOUT(0x88, "充电异常中止,接收 BMS 充电统计报文超时"),
|
||||
RECEIVED_CCS_TIMEOUT(0x89, "充电异常中止,接收对侧 CCS 报文超时"),
|
||||
|
||||
OTHER_EIGHTY_A(0x8A, "(其他原因)预留"),
|
||||
OTHER_EIGHTY_B(0x8B, "(其他原因)预留"),
|
||||
OTHER_EIGHTY_C(0x8C, "(其他原因)预留"),
|
||||
OTHER_EIGHTY_D(0x8D, "(其他原因)预留"),
|
||||
OTHER_EIGHTY_E(0x8E, "(其他原因)预留"),
|
||||
OTHER_EIGHTY_F(0x8F, "(其他原因)预留"),
|
||||
|
||||
|
||||
/**
|
||||
* 未知原因停止
|
||||
*/
|
||||
UNKNOWN_REASON_STOP_CHARGING(0x90, "未知原因停止"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
YKCChargingStopReasonEnum(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取停止原因描述
|
||||
*
|
||||
* @param code 编码
|
||||
* @return 停止原因描述
|
||||
*/
|
||||
public static String getMsgByCode(int code) {
|
||||
for (YKCChargingStopReasonEnum item : YKCChargingStopReasonEnum.values()) {
|
||||
if (item.getCode() == code) {
|
||||
return item.getMsg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String stopReason = "6B";
|
||||
byte[] stopReasonByteArr = new byte[]{0x6B};
|
||||
String s = BytesUtil.bin2HexStr(stopReasonByteArr);
|
||||
|
||||
int i = Integer.parseInt(stopReason, 16);
|
||||
String stopReasonMsg = YKCChargingStopReasonEnum.getMsgByCode(i);
|
||||
System.out.println(stopReasonMsg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.jsowell.common.enums.ykc;
|
||||
|
||||
/**
|
||||
* 充电桩故障原因enum
|
||||
*
|
||||
* @author JS-ZZA
|
||||
* @date 2022/10/17 9:03
|
||||
*/
|
||||
public enum YKCPileFaultReasonEnum {
|
||||
|
||||
STOP_BUTTON_FAULT(1, "急停按钮动作故障"),
|
||||
NO_CAN_USE_RECTIFICATION_MODEL_FAULT(2, "无可用整流模块"),
|
||||
OUTLET_TEMPERATURE_TOO_HIGH_FAULT(3, "出风口温度过高"),
|
||||
ALTERNATING_LIGHTING_PROTECTION_FAULT(4, "交流防雷故障"),
|
||||
DC20_COMMUNICATION_INTERRUPT_FAULT(5, "交直流模块 DC20 通信中断"),
|
||||
FC08_COMMUNICATION_INTERRUPT_FAULT(6, "交直流模块 FC08 通信中断"),
|
||||
WATT_HOUR_METER_COMMUNICATION_INTERRUPT_FAULT(7, "电度表通信中断"),
|
||||
CARD_READER_COMMUNICATION_INTERRUPT_FAULT(8, "读卡器通信中断"),
|
||||
RC10_COMMUNICATION_INTERRUPT_FAULT(9, "RC10 通信中断"),
|
||||
FAN_SPEED_CONTROL_FAULT(10, "风扇调速板故障"),
|
||||
DC_FUSE_FAULT(11, "直流熔断器故障"),
|
||||
HIGH_PRESSURE_CONTACTOR_FAULT(12, "高压接触器故障"),
|
||||
DOOR_OPEN_FAULT(13, "门打开"),
|
||||
;
|
||||
|
||||
/**
|
||||
* 根据code获取故障描述
|
||||
*
|
||||
* @param code 故障编码
|
||||
* @return 故障描述
|
||||
*/
|
||||
public static String getValueByCode(int code) {
|
||||
for (YKCPileFaultReasonEnum item : YKCPileFaultReasonEnum.values()) {
|
||||
if (item.getCode() == code) {
|
||||
return item.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int code;
|
||||
private String value;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
YKCPileFaultReasonEnum(int code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jsowell.common.exception;
|
||||
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BusinessException extends RuntimeException{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
|
||||
public BusinessException(ReturnCodeEnum returnCodeEnum) {
|
||||
this.code = returnCodeEnum.getValue();
|
||||
this.message = returnCodeEnum.getLabel();
|
||||
}
|
||||
|
||||
public BusinessException(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.jsowell.common.exception;
|
||||
|
||||
/**
|
||||
* 演示模式异常
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class DemoModeException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DemoModeException() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.jsowell.common.exception;
|
||||
|
||||
/**
|
||||
* 全局异常
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class GlobalException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 错误明细,内部调试错误
|
||||
* <p>
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public GlobalException() {
|
||||
}
|
||||
|
||||
public GlobalException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getDetailMessage() {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
public GlobalException setDetailMessage(String detailMessage) {
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public GlobalException setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.jsowell.common.exception;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public final class ServiceException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 错误明细,内部调试错误
|
||||
* <p>
|
||||
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||
*/
|
||||
private String detailMessage;
|
||||
|
||||
/**
|
||||
* 空构造方法,避免反序列化问题
|
||||
*/
|
||||
public ServiceException() {
|
||||
}
|
||||
|
||||
public ServiceException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ServiceException(String message, Integer code) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDetailMessage() {
|
||||
return detailMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public ServiceException setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServiceException setDetailMessage(String detailMessage) {
|
||||
this.detailMessage = detailMessage;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.jsowell.common.exception;
|
||||
|
||||
/**
|
||||
* 工具类异常
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class UtilException extends RuntimeException {
|
||||
private static final long serialVersionUID = 8247610319171014183L;
|
||||
|
||||
public UtilException(Throwable e) {
|
||||
super(e.getMessage(), e);
|
||||
}
|
||||
|
||||
public UtilException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UtilException(String message, Throwable throwable) {
|
||||
super(message, throwable);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.jsowell.common.exception.base;
|
||||
|
||||
import com.jsowell.common.util.MessageUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
/**
|
||||
* 基础异常
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class BaseException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 所属模块
|
||||
*/
|
||||
private String module;
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 错误码对应的参数
|
||||
*/
|
||||
private Object[] args;
|
||||
|
||||
/**
|
||||
* 错误消息
|
||||
*/
|
||||
private String defaultMessage;
|
||||
|
||||
public BaseException(String module, String code, Object[] args, String defaultMessage) {
|
||||
this.module = module;
|
||||
this.code = code;
|
||||
this.args = args;
|
||||
this.defaultMessage = defaultMessage;
|
||||
}
|
||||
|
||||
public BaseException(String module, String code, Object[] args) {
|
||||
this(module, code, args, null);
|
||||
}
|
||||
|
||||
public BaseException(String module, String defaultMessage) {
|
||||
this(module, null, null, defaultMessage);
|
||||
}
|
||||
|
||||
public BaseException(String code, Object[] args) {
|
||||
this(null, code, args, null);
|
||||
}
|
||||
|
||||
public BaseException(String defaultMessage) {
|
||||
this(null, null, null, defaultMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
String message = null;
|
||||
if (!StringUtils.isEmpty(code)) {
|
||||
message = MessageUtils.message(code, args);
|
||||
}
|
||||
if (message == null) {
|
||||
message = defaultMessage;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public Object[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public String getDefaultMessage() {
|
||||
return defaultMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.jsowell.common.exception.file;
|
||||
|
||||
import com.jsowell.common.exception.base.BaseException;
|
||||
|
||||
/**
|
||||
* 文件信息异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class FileException extends BaseException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileException(String code, Object[] args) {
|
||||
super("file", code, args, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.jsowell.common.exception.file;
|
||||
|
||||
/**
|
||||
* 文件名称超长限制异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class FileNameLengthLimitExceededException extends FileException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileNameLengthLimitExceededException(int defaultFileNameLength) {
|
||||
super("upload.filename.exceed.length", new Object[]{defaultFileNameLength});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.jsowell.common.exception.file;
|
||||
|
||||
/**
|
||||
* 文件名大小限制异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class FileSizeLimitExceededException extends FileException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public FileSizeLimitExceededException(long defaultMaxSize) {
|
||||
super("upload.exceed.maxSize", new Object[]{defaultMaxSize});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.jsowell.common.exception.file;
|
||||
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 文件上传 误异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class InvalidExtensionException extends FileUploadException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String[] allowedExtension;
|
||||
private String extension;
|
||||
private String filename;
|
||||
|
||||
public InvalidExtensionException(String[] allowedExtension, String extension, String filename) {
|
||||
super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式");
|
||||
this.allowedExtension = allowedExtension;
|
||||
this.extension = extension;
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String[] getAllowedExtension() {
|
||||
return allowedExtension;
|
||||
}
|
||||
|
||||
public String getExtension() {
|
||||
return extension;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public static class InvalidImageExtensionException extends InvalidExtensionException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) {
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidFlashExtensionException extends InvalidExtensionException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) {
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidMediaExtensionException extends InvalidExtensionException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) {
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InvalidVideoExtensionException extends InvalidExtensionException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) {
|
||||
super(allowedExtension, extension, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jsowell.common.exception.job;
|
||||
|
||||
/**
|
||||
* 计划策略异常
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class TaskException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Code code;
|
||||
|
||||
public TaskException(String msg, Code code) {
|
||||
this(msg, code, null);
|
||||
}
|
||||
|
||||
public TaskException(String msg, Code code, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Code getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public enum Code {
|
||||
TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.jsowell.common.exception.user;
|
||||
|
||||
/**
|
||||
* 验证码错误异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class CaptchaException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CaptchaException() {
|
||||
super("user.jcaptcha.error", null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.jsowell.common.exception.user;
|
||||
|
||||
/**
|
||||
* 验证码失效异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class CaptchaExpireException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public CaptchaExpireException() {
|
||||
super("user.jcaptcha.expire", null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.jsowell.common.exception.user;
|
||||
|
||||
import com.jsowell.common.exception.base.BaseException;
|
||||
|
||||
/**
|
||||
* 用户信息异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class UserException extends BaseException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserException(String code, Object[] args) {
|
||||
super("user", code, args, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.jsowell.common.exception.user;
|
||||
|
||||
/**
|
||||
* 用户密码不正确或不符合规范异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class UserPasswordNotMatchException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserPasswordNotMatchException() {
|
||||
super("user.password.not.match", null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.jsowell.common.exception.user;
|
||||
|
||||
/**
|
||||
* 用户错误最大次数异常类
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class UserPasswordRetryLimitExceedException extends UserException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime) {
|
||||
super("user.password.retry.limit.exceed", new Object[]{retryLimitCount, lockTime});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.jsowell.common.filter;
|
||||
|
||||
import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
|
||||
|
||||
/**
|
||||
* 排除JSON敏感属性
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class PropertyPreExcludeFilter extends SimplePropertyPreFilter {
|
||||
public PropertyPreExcludeFilter() {
|
||||
}
|
||||
|
||||
public PropertyPreExcludeFilter addExcludes(String... filters) {
|
||||
for (int i = 0; i < filters.length; i++) {
|
||||
this.getExcludes().add(filters[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.jsowell.common.filter;
|
||||
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Repeatable 过滤器
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class RepeatableFilter implements Filter {
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
ServletRequest requestWrapper = null;
|
||||
if (request instanceof HttpServletRequest
|
||||
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) {
|
||||
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
|
||||
}
|
||||
if (null == requestWrapper) {
|
||||
chain.doFilter(request, response);
|
||||
} else {
|
||||
chain.doFilter(requestWrapper, response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.jsowell.common.filter;
|
||||
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.util.http.HttpHelper;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* 构建可重复读取inputStream的request
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
|
||||
private final byte[] body;
|
||||
|
||||
public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException {
|
||||
super(request);
|
||||
request.setCharacterEncoding(Constants.UTF8);
|
||||
response.setCharacterEncoding(Constants.UTF8);
|
||||
|
||||
body = HttpHelper.getBodyString(request).getBytes(Constants.UTF8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() throws IOException {
|
||||
return new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return bais.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return body.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.jsowell.common.filter;
|
||||
|
||||
import com.jsowell.common.enums.HttpMethod;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 防止XSS攻击的过滤器
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class XssFilter implements Filter {
|
||||
/**
|
||||
* 排除链接
|
||||
*/
|
||||
public List<String> excludes = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
String tempExcludes = filterConfig.getInitParameter("excludes");
|
||||
if (StringUtils.isNotEmpty(tempExcludes)) {
|
||||
String[] url = tempExcludes.split(",");
|
||||
for (int i = 0; url != null && i < url.length; i++) {
|
||||
excludes.add(url[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
if (handleExcludeURL(req, resp)) {
|
||||
chain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request);
|
||||
chain.doFilter(xssRequest, response);
|
||||
}
|
||||
|
||||
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) {
|
||||
String url = request.getServletPath();
|
||||
String method = request.getMethod();
|
||||
// GET DELETE 不过滤
|
||||
if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method)) {
|
||||
return true;
|
||||
}
|
||||
return StringUtils.matches(url, excludes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.jsowell.common.filter;
|
||||
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.html.EscapeUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* XSS过滤处理
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
/**
|
||||
* @param request
|
||||
*/
|
||||
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||
super(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
String[] values = super.getParameterValues(name);
|
||||
if (values != null) {
|
||||
int length = values.length;
|
||||
String[] escapseValues = new String[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
// 防xss攻击和过滤前后空格
|
||||
escapseValues[i] = EscapeUtil.clean(values[i]).trim();
|
||||
}
|
||||
return escapseValues;
|
||||
}
|
||||
return super.getParameterValues(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() throws IOException {
|
||||
// 非json类型,直接返回
|
||||
if (!isJsonRequest()) {
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
// 为空,直接返回
|
||||
String json = IOUtils.toString(super.getInputStream(), "utf-8");
|
||||
if (StringUtils.isEmpty(json)) {
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
// xss过滤
|
||||
json = EscapeUtil.clean(json).trim();
|
||||
byte[] jsonBytes = json.getBytes("utf-8");
|
||||
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return jsonBytes.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return bis.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是Json请求
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
public boolean isJsonRequest() {
|
||||
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
|
||||
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.jsowell.common.response;
|
||||
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RestApiResponse<T> {
|
||||
/**
|
||||
* 返回码
|
||||
*/
|
||||
private String resCode;
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
private T obj;
|
||||
|
||||
public RestApiResponse() {
|
||||
this.resCode = ReturnCodeEnum.CODE_SUCCESS.getValue();
|
||||
this.msg = ReturnCodeEnum.CODE_SUCCESS.getLabel();
|
||||
}
|
||||
|
||||
public RestApiResponse(T t) {
|
||||
this.resCode = ReturnCodeEnum.CODE_SUCCESS.getValue();
|
||||
this.msg = ReturnCodeEnum.CODE_SUCCESS.getLabel();
|
||||
this.obj = t;
|
||||
}
|
||||
|
||||
public RestApiResponse(String resCode, String msg) {
|
||||
this.resCode = resCode;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public RestApiResponse(ReturnCodeEnum returnCodeEnum) {
|
||||
this.resCode = returnCodeEnum.getValue();
|
||||
this.msg = returnCodeEnum.getLabel();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user