@
- 说明:基础工具类
- Msg
- PageResult
- Response
- BusinessDomainEnum(枚举)
- EsDocumentConstants(常量)
- 本人其他文章链接
说明:基础工具类
Msg
package com.geespace.microservices.data.computing.model.server.response;import java.util.HashMap;
import java.util.Map;import lombok.AllArgsConstructor;
import lombok.Getter;/*** Msg* * @author:* @date: 2020-06-18*/
@AllArgsConstructor
@Getter
public enum Msg {/*** 请求类型错误*/SUCCESS(200, "success"), FAILED(20001, "Operation failed"),EXCUTE_ERROR(16001, "Service invocation exception, please try again later"),UNKNOW_ERROR(16002, "unknown error"),PARAM_ERROR(16003, "request param error"),DATA_SAVE_FAIL(16004, "data save fail"),ID_IS_NOT_EXIST(16005, "id isn't exist"),QUERY_RESULT_IS_EMPTY(16006, "request result is null"),NAME_IS_EXIST(16007, "name already exist"),ID_IS_NOT_EXIST_DATA(16008, "There is no data for the current ID"),DATASOURCE_NOT_EXIST(16009, "datasource not exist"),JDBC_EXCEPTION(16010, "jdbc connection or search exception"),TASK_HAS_BEEN_STOPPED(16011, "task has been stopped");private int code;private String msg;private static final Map<Integer, Msg> MAP = new HashMap<>();static {for (Msg msgEnum : Msg.values()) {MAP.put(msgEnum.code, msgEnum);}}/*** 通过code获取枚举** @param code* code* @return 枚举*/public static Msg getByCode(int code) {return MAP.get(code);}
}
PageResult
package com.geespace.microservices.data.computing.model.server.response;import java.io.Serializable;
import java.util.List;import lombok.Data;/**** @param <T>* Construct return entity* @author liudz* @since Oracle JDK1.8**/
@Data
public class PageResult<T> implements Serializable {private int pageNum;private int pageSize;private long totalCount;private long totalPage;private List<T> list;
}
Response
package com.geespace.microservices.data.computing.model.server.response;import java.io.Serializable;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;/*** merge fromn iot* * @param <T>* @Author: Mickey* @Date: 2019/9/9 {TIME}* @Version 1.0*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public final class Response<T> implements Serializable {private int code;private String msg;private T info;private Response(Msg msg) {this(msg, null);}private Response(Msg msg, T info) {this.code = msg.getCode();this.msg = msg.getMsg();this.info = info;}private Response(int code, String msg) {this.code = code;this.msg = msg;}/*** Return to success** @param <T>* Return info* @return <T> Success*/public static <T> Response<T> success() {return success(null);}/*** Return to success** @param t* Return info* @param <T>* Return generic* @return <T> Return entity*/public static <T> Response<T> success(T t) {return new Response<>(Msg.SUCCESS, t);}/*** Return failed** @param msg* result enumeration* @param <T>* Return info* @return <T> Return entity*/public static <T> Response<T> error(Msg msg) {return new Response<>(msg);}/*** Return failed** @param code* Error code* @param msg* Error message* @param <T>* Return info* @return <T> Return entity*/public static <T> Response<T> error(int code, String msg) {return new Response<>(code, msg);}/**** @author luke liu* @param <T>* t* @param msg* error msg* @return error result**/public static <T> Response<T> error(String msg) {return new Response(msg);}/*** Determine whether response is successful in returning** @return Success*/public boolean responseSuccess() {if (this.code == Msg.SUCCESS.getCode()) {return true;}return false;}private Response(String msg) {this.code = Msg.FAILED.getCode();this.msg = msg;this.info = null;}
}
BusinessDomainEnum(枚举)
package com.geespace.microservices.directory.assets.enums;import lombok.AllArgsConstructor;
import lombok.Getter;/*** 业务域* @Author: liudz* @Date: 2020/6/22* @Version 1.0*/
@AllArgsConstructor
@Getter
public enum BusinessDomainEnum {/*** 类型1*/ONE(1, "低轨物联"),/*** 类型2*/TWO(2, "大网");private int category;private String value;/*** @author liudz* @param category category* @return ture or false**/public static String transfer(int category) {BusinessDomainEnum[] values = BusinessDomainEnum.values();for (BusinessDomainEnum subEnum : values) {if (category == subEnum.getCategory()) {return subEnum.getValue();}}return "error";}
}
EsDocumentConstants(常量)
package com.geespace.microservices.directory.assets.constants;/*** 资产目录功能相关符号常量* @author: liudz* @date: 2020/9/15*/
public final class EsDocumentConstants {private EsDocumentConstants(){}public static final String FILE_NAME = "file_name";public static final String FILE_TYPE = "file_type";public static final String DATABASE_NAME = "database_name";public static final String TABLE_NAME = "table_name";public static final String INCLUDE_FIELDS = "include_fields";public static final String BUSINESS_DOMAIN = "business_domain";public static final String STORE_TYPE = "store_type";public static final String UPDATE_TIME = "update_time";public static final String WHETHER_ONLINE = "whether_online";public static final String FOREIGN_ID = "foreign_id";
}
本人其他文章链接
1.java小工具util系列1:日期毫秒数转日期字符串
https://blog.csdn.net/a924382407/article/details/121955349
2.java小工具util系列2:获取字符modelStr在字符串str中第count次出现时的下标
https://blog.csdn.net/a924382407/article/details/121955455
3.java小工具util系列3:正则表达式匹配:匹配不包含@特殊字符的字符串
https://blog.csdn.net/a924382407/article/details/121955737
4.java小工具util系列4:String[] 转 List< Integer >
https://blog.csdn.net/a924382407/article/details/121956201
5.java小工具util系列5:基础工具代码(Msg、PageResult、Response、常量、枚举)
https://blog.csdn.net/a924382407/article/details/120952865
6.java小工具util系列6:java执行string返回boolean结果
https://blog.csdn.net/a924382407/article/details/117124536
7.java小工具util系列7:集合中实体对象转换 list中Enrey转Dto
https://blog.csdn.net/a924382407/article/details/121957545
8.java小工具util系列8:JSONObject获取key
https://blog.csdn.net/a924382407/article/details/121957607
9.java小工具util系列9:检测一个字符串是否是时间格式
https://blog.csdn.net/a924382407/article/details/123948881
10.java小工具util系列10:时间毫秒数、时间格式字符串、日期之间相互转化
https://blog.csdn.net/a924382407/article/details/124581851
重要信息
- 官网:https://ais.cn/u/vEbMBz