feat:模块名称调整

This commit is contained in:
曾文豪
2023-01-11 11:21:01 +08:00
parent 61a4a6494a
commit c721e4877f
125 changed files with 56 additions and 56 deletions

View File

@@ -0,0 +1,183 @@
package com.tiesheng.util.pojos;
import com.tiesheng.util.exception.ApiRespEnum;
/**
* @author huang
* @ProjectName health
* @Copyright Hangzhou ShuoChuang Technology Co.,Ltd All Right Reserved
* @Description 这里是对文件的描述
* @data 2017/9/4
* @note 这里写文件的详细功能和改动
* @note
*/
public class ApiResp<T> {
public static int CODE_OK = 200;
private int code;
private String message;
private Throwable exception;
private T data;
private long recordsTotal = 0;
private boolean encrypt = false;
/**
* 请求成功
*
* @param data
* @param <T>
* @return
*/
public static <T> ApiResp<T> respOK(T data) {
ApiRespEnum okResp = ApiRespEnum.OK;
ApiResp<T> result = new ApiResp<>();
result.code = okResp.getCode();
result.message = okResp.getMessage();
result.data = data;
return result;
}
/**
* 请求成功,返回总条数
*
* @param data
* @param recordsTotal
* @param <T>
* @return
*/
public static <T> ApiResp<T> respOK(T data, long recordsTotal) {
ApiRespEnum okResp = ApiRespEnum.OK;
ApiResp<T> result = new ApiResp<>();
result.code = okResp.getCode();
result.message = okResp.getMessage();
result.data = data;
result.recordsTotal = recordsTotal;
return result;
}
/**
* 自定义的错误
*
* @param code
* @param msg
* @param <T>
* @return
*/
public static <T> ApiResp<T> respCust(int code, String msg) {
ApiResp<T> result = new ApiResp<>();
result.code = code;
result.message = msg;
return result;
}
/**
* 自定义的错误
*
* @param respEnum
* @param <T>
* @return
*/
public static <T> ApiResp<T> respCust(ApiRespEnum respEnum) {
ApiResp<T> result = new ApiResp<>();
result.code = respEnum.getCode();
result.message = respEnum.getMessage();
return result;
}
/**
* 用户未登录
*
* @param <T>
* @return
*/
public static <T> ApiResp<T> respNeedLogin(String msg) {
ApiResp<T> result = new ApiResp<>();
result.code = 110;
result.message = msg;
return result;
}
/**
* 操作失败
*
* @param <T>
* @return
*/
public static <T> ApiResp<T> respDoFail() {
ApiResp<T> result = new ApiResp<>();
result.code = 121;
result.message = "操作失败";
return result;
}
/**
* 根据bool返回数据
*
* @param <T>
* @return
*/
public static <T> ApiResp<T> respBool(T data, boolean isOk) {
ApiResp<T> result = respOK(data);
if (!isOk) {
result = respDoFail();
}
return result;
}
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public long getRecordsTotal() {
return recordsTotal;
}
public void setRecordsTotal(long recordsTotal) {
this.recordsTotal = recordsTotal;
}
public boolean isEncrypt() {
return encrypt;
}
public void setEncrypt(boolean encrypt) {
this.encrypt = encrypt;
}
public Throwable getException() {
return exception;
}
public void setException(Throwable exception) {
this.exception = exception;
}
}

View File

@@ -0,0 +1,109 @@
package com.tiesheng.util.pojos;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
public class FileUploadPath {
public static String UPLOAD_FOLDER = "/upload/";
/**
* 绝对路径
*/
private String absolutePath;
/**
* 访问路径
*/
private String httpPath;
private FileUploadPath() {
}
/**
* 获得一个文件路径
*
* @param fileName
* @return
*/
public static FileUploadPath get(String fileName) {
FileUploadPath pathBean = new FileUploadPath();
String tempPath = fileName;
if (!StrUtil.startWith(tempPath, UPLOAD_FOLDER)) {
tempPath = UPLOAD_FOLDER + DateUtil.format(DateUtil.date(), "yyyy-MM") + "/" + fileName;
}
pathBean.setHttpPath(tempPath);
pathBean.setAbsolutePath(String.format("%s/static%s", System.getProperty("user.dir"), tempPath));
FileUtil.mkParentDirs(pathBean.getAbsolutePath());
return pathBean;
}
/**
* 随机生成一个文件路径
*
* @return
*/
public static FileUploadPath random() {
return get(IdUtil.simpleUUID());
}
/**
* 随机生成一个文件路径
*
* @return
*/
public static FileUploadPath random(String fileExt) {
return get(IdUtil.simpleUUID() + "." + fileExt);
}
/**
* 获取一个目录
*
* @param folder
* @return
*/
public static FileUploadPath folder(String folder) {
FileUploadPath pathBean = new FileUploadPath();
String tempFolder = folder;
if (!StrUtil.startWith(tempFolder, UPLOAD_FOLDER)) {
tempFolder = UPLOAD_FOLDER + tempFolder;
}
if (!StrUtil.endWith(folder, "/")) {
tempFolder = tempFolder + "/";
}
pathBean.setHttpPath(tempFolder);
pathBean.setAbsolutePath(String.format("%s/static%s", System.getProperty("user.dir"), tempFolder));
FileUtil.mkParentDirs(pathBean.getAbsolutePath());
return pathBean;
}
///////////////////////////////////////////////////////////////////////////
// setter\getter
///////////////////////////////////////////////////////////////////////////
public String getAbsolutePath() {
return absolutePath;
}
public void setAbsolutePath(String absolutePath) {
this.absolutePath = absolutePath;
}
public String getHttpPath() {
return httpPath;
}
public void setHttpPath(String httpPath) {
this.httpPath = httpPath;
}
}