初始化
This commit is contained in:
22
src/main/java/com/dpkj/common/config/FileConfig.java
Normal file
22
src/main/java/com/dpkj/common/config/FileConfig.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.dpkj.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2024/4/28 14:55
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "dpkj.file")
|
||||
public class FileConfig {
|
||||
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
private String path;
|
||||
|
||||
}
|
||||
32
src/main/java/com/dpkj/common/config/PrinterConfig.java
Normal file
32
src/main/java/com/dpkj/common/config/PrinterConfig.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.dpkj.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Auther: 萧道子
|
||||
* @Date: 2024/4/28 14:55
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "dpkj.printer")
|
||||
public class PrinterConfig {
|
||||
|
||||
/**
|
||||
* 打印机连接方式 USB: usb连接 | BTMS:串口连接
|
||||
*/
|
||||
private String connectionType;
|
||||
|
||||
/**
|
||||
* 打印端口 串口连接下使用
|
||||
*/
|
||||
private String portName;
|
||||
|
||||
/**
|
||||
* 波特率 串口连接下使用
|
||||
*/
|
||||
private Integer baudRate;
|
||||
}
|
||||
9
src/main/java/com/dpkj/common/constant/CommonConst.java
Normal file
9
src/main/java/com/dpkj/common/constant/CommonConst.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.dpkj.common.constant;
|
||||
|
||||
public interface CommonConst {
|
||||
Integer SC_500 = 500;
|
||||
Integer SC_404 = 404;
|
||||
Integer SC_200 = 200;
|
||||
|
||||
|
||||
}
|
||||
81
src/main/java/com/dpkj/common/vo/Result.java
Normal file
81
src/main/java/com/dpkj/common/vo/Result.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package com.dpkj.common.vo;
|
||||
|
||||
import com.dpkj.common.constant.CommonConst;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 接口返回数据格式
|
||||
*/
|
||||
@Data
|
||||
public class Result<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 成功标志
|
||||
*/
|
||||
private boolean success = true;
|
||||
|
||||
/**
|
||||
* 返回处理消息
|
||||
*/
|
||||
private String message = "";
|
||||
|
||||
/**
|
||||
* 返回代码
|
||||
*/
|
||||
private Integer code = 0;
|
||||
|
||||
/**
|
||||
* 返回数据对象 data
|
||||
*/
|
||||
private T result;
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
public Result() {
|
||||
}
|
||||
|
||||
public static <T> Result<T> ok() {
|
||||
return ok("", null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> ok(String msg) {
|
||||
return ok(msg, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> ok(T data) {
|
||||
return error("", data);
|
||||
}
|
||||
|
||||
public static <T> Result<T> ok(String msg, T data) {
|
||||
Result<T> r = new Result<T>();
|
||||
r.setSuccess(true);
|
||||
r.setCode(CommonConst.SC_200);
|
||||
r.setMessage(msg);
|
||||
r.setResult(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(String msg, T data) {
|
||||
return error(CommonConst.SC_500, msg, data);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(String msg) {
|
||||
return error(CommonConst.SC_500, msg, null);
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(int code, String msg, T data) {
|
||||
Result<T> r = new Result<T>();
|
||||
r.setCode(code);
|
||||
r.setMessage(msg);
|
||||
r.setSuccess(false);
|
||||
r.setResult(data);
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user