template.result_model.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of primo-generator-mybatis-plus-maven-plugin Show documentation
Show all versions of primo-generator-mybatis-plus-maven-plugin Show documentation
自动生成增删改查代码插件,通过Maven插件配置,一键生成单表的所有CRUD操作
package ${package.ResultModel};
import ${package.ResultCodeEnum}.ResultCodeEnum;
import java.io.Serializable;
/**
* 前后端交互对象
*
* @author ${author}
* @since ${date}
*/
public class ResultModel implements Serializable {
private static final long serialVersionUID = 8951721595994792067L;
private Integer code;
private String message;
private T data;
public ResultModel(Integer code, String message) {
this.code = code;
this.message = message;
}
public ResultModel(Integer code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public ResultModel(ResultCodeEnum resultCode) {
this.code = resultCode.getCode();
this.message = resultCode.getMessage();
}
public static ResultModel resultModel(Integer code, String message) {
return new ResultModel(code, message);
}
public static ResultModel resultModel(ResultCodeEnum resultCode) {
return new ResultModel(resultCode);
}
public static ResultModel resultModel(Integer code, String message, T t) {
return new ResultModel(code, message, t);
}
/**
* 处理成功
*
* @param t
* @param
* @return
*/
public static ResultModel success(T t) {
ResultModel resultModel = new ResultModel<>(ResultCodeEnum.SUCCESS);
resultModel.setData(t);
return resultModel;
}
public static ResultModel successNoData(String message) {
return new ResultModel(ResultCodeEnum.SUCCESS.getCode(),message);
}
public static ResultModel
© 2015 - 2025 Weber Informatics LLC | Privacy Policy