Easy Code Mybatis-plus自用模板

1.idea先安装插件 EasyCode

 2.设置模板信息

      通过设置找到插件

点击添加模板具体配置看如下

     Controller

        

##导入宏定义
$!{define.vm}
$!define
$!init

##设置表后缀(宏定义)
#setTableSuffix("Controller")

##保存文件(宏定义)
#save("/controller", "Controller.java")

##包路径(宏定义)
#setPackageSuffix("controller")

##定义服务名
#set($serviceName = $!tool.append($!tool.firstLowerCase($!tableInfo.name), "Service"))

##定义实体对象名
#set($entityName = $!tool.firstLowerCase($!tableInfo.name))


import $!{tableInfo.savePackageName}.domain.po.$!{tableInfo.name};
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import $!{tableInfo.savePackageName}.domain.dto.$!{tableInfo.name}Dto;
import org.springframework.web.bind.annotation.*;
import $!{tableInfo.savePackageName}.common.tenum.BusinessEnum;
import $!{tableInfo.savePackageName}.common.utils.Response;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;
import java.lang.Long;
##表注释(宏定义)
#tableComment("表控制层")
@RestController
@RequestMapping("$!tool.firstLowerCase($!tableInfo.name)")
public class $!{tableName}  {
    /**
     * 服务对象
     */
    @Resource
    private $!{tableInfo.name}Service $!{serviceName};

   
   /** 
     * 
     * @param $!{entityName}dto 请求参数封装
     * @author $!author 
     * @description //TODO  分页查询所有数据
     * @date $!time.currTime()
     * @return 实例对象
     */
    @PostMapping("/find$!{tableInfo.name}SelectList")
    public Response find$!{tableInfo.name}SelectList(@RequestBody $!{tableInfo.name}Dto $!{entityName}dto ) {
        return Response.ok(BusinessEnum.SUCCESS,$!{serviceName}.find$!{tableInfo.name}SelectList($!{entityName}dto)); 
    }

   
    /** 
     * 
     * @param id 主键
     * @author $!author  
     * @description //TODO  通过主键查询单条数据
     * @date $!time.currTime()
     * @return 单条数据
     */
    @GetMapping("/select$!{tableInfo.name}ById/{id}")
    public Response select$!{tableInfo.name}ById(@PathVariable Long id) {
        return Response.ok(BusinessEnum.SUCCESS,$!{serviceName}.select$!{tableInfo.name}ById(id)); 
    }

    /** 
     * 
     * @param $!{entityName}dto 实体对象
     * @author $!author  
     * @description //TODO  新增数据
     * @date $!time.currTime()
     * @return 新增结果
     */
    @PostMapping
    public Response insert(@RequestBody $!{tableInfo.name}Dto $!{entityName}dto) {
        $!{serviceName}.insert($!{entityName}dto);
        return Response.ok(BusinessEnum.SUCCESS); 
    }

    /** 
     * 
     * @param $!{entityName}dto 实体对象
     * @author $!author  
     * @description //TODO  修改数据
     * @date $!time.currTime()
     * @return 修改结果
     */
    @PutMapping
    public Response update(@RequestBody $!{tableInfo.name}Dto $!{entityName}dto) {
         return Response.ok(BusinessEnum.SUCCESS,$!{serviceName}.update($!{entityName}dto)); 
    }

    /** 
     * 
     * @param idList 主键集合
     * @author $!author  
     * @description //TODO  删除数据
     * @date $!time.currTime()
     * @return 删除结果
     */
    @DeleteMapping
    public Response delete(@RequestParam("idList") List<Long> idList) {
        $!{serviceName}.deleteById(idList);
         return Response.ok(BusinessEnum.SUCCESS); 
    }
}

Service

##导入宏定义
$!{define.vm}
$!define
$!init

##设置表后缀(宏定义)
#setTableSuffix("Service")

##保存文件(宏定义)
#save("/service", "Service.java")

##包路径(宏定义)
#setPackageSuffix("service")

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;
import $!{tableInfo.savePackageName}.domain.dto.$!{tableInfo.name}Dto;
import $!{tableInfo.savePackageName}.domain.po.$!{tableInfo.name};
import java.util.List;
##表注释(宏定义)
#tableComment("表服务接口")
public interface $!{tableName} extends IService<$!tableInfo.name> {
    /** 
     * 
     * @param id 主键
     * @author $!author  
     * @description //TODO  通过ID查询单条数据
     * @date $!time.currTime()
     * @return 实例对象
     */
    public $!{tableInfo.name} select$!{tableInfo.name}ById (Long id);
        
    /** 
     * 
     * @param $!tool.firstLowerCase($!{tableInfo.name})dto 实例对象
     * @author $!author  
     * @description //TODO  分页查询数据
     * @date $!time.currTime()
     * @return 实例对象
     */
    public IPage find$!{tableInfo.name}SelectList ($!{tableInfo.name}Dto $!tool.firstLowerCase($!{tableInfo.name})dto);
    
    
   /** 
     * 
     * @param $!tool.firstLowerCase($!{tableInfo.name})dto 实例对象
     * @author $!author  
     * @description //TODO  新增数据
     * @date $!time.currTime()
     * @return 实例对象
     */
    public void insert($!{tableInfo.name}Dto $!tool.firstLowerCase($!{tableInfo.name})dto);
    
   /** 
     * 
     * @param $!tool.firstLowerCase($!{tableInfo.name})dto 实例对象
     * @author $!author  
     * @description //TODO  修改数据并返回
     * @date $!time.currTime()
     * @return 实例对象
     */
    public $!{tableInfo.name} update($!{tableInfo.name}Dto $!tool.firstLowerCase($!{tableInfo.name})dto);
    
    
    /**
     *
     * @param idList 主键
     * @author $!author 
     * @description //TODO    通过主键删除数据
     * @date $!time.currTime()
     * @return
     */
    public void deleteById(List<Long> idList);
}

ServiceImpl

##导入宏定义
$!{define.vm}
$!define
$!init

##设置表后缀(宏定义)
#setTableSuffix("ServiceImpl")

##保存文件(宏定义)
#save("/service/impl", "ServiceImpl.java")

##包路径(宏定义)
#setPackageSuffix("service.impl")

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;
import $!{tableInfo.savePackageName}.domain.dto.$!{tableInfo.name}Dto;
import $!{tableInfo.savePackageName}.domain.po.$!{tableInfo.name};
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import $!{tableInfo.savePackageName}.common.utils.copy.ModelUtil;
import $!{tableInfo.savePackageName}.common.tenum.ModelIsDelEnum;
import org.springframework.stereotype.Service;
import java.lang.Long;
import java.util.List;
import java.time.LocalDateTime;
##表注释(宏定义)
#tableComment("表服务实现类")
@Service("$!tool.firstLowerCase($tableInfo.name)Service")
public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}> implements $!{tableInfo.name}Service {
     
        /** 
         * 
         * @param  id 主键
         * @author $!author  
         * @description //TODO  通过ID查询单条数据
         * @date $!time.currTime()
         * @return 实例对象
         */
        @Override
        public $!{tableInfo.name} select$!{tableInfo.name}ById (Long id) {
                LambdaQueryWrapper<$!{tableInfo.name}> $!{tool.firstLowerCase($!{tableInfo.name})}lam =  new LambdaQueryWrapper<$!{tableInfo.name}>();
                $!{tool.firstLowerCase($!{tableInfo.name})}lam.eq($!{tableInfo.name} ::getId ,id);
                return baseMapper.selectOne($!{tool.firstLowerCase($!{tableInfo.name})}lam);
        }
        
        /** 
         * 
         * @param $!tool.firstLowerCase($!{tableInfo.name})dto 实例对象
         * @author $!author  
         * @description //TODO  分页查询数据
         * @date $!time.currTime()
         * @return 实例对象
         */
        @Override
        public IPage find$!{tableInfo.name}SelectList ($!{tableInfo.name}Dto $!tool.firstLowerCase($!{tableInfo.name})dto) {
            IPage<$!{tableInfo.name}> $!tool.firstLowerCase($!{tableInfo.name})Page =new Page<>($!{tool.firstLowerCase($!{tableInfo.name})}dto.getPageNum(), $!{tool.firstLowerCase($!{tableInfo.name})}dto.getPageSize());
            LambdaQueryWrapper<$!{tableInfo.name}> $!tool.firstLowerCase($!{tableInfo.name})Wrapper = new LambdaQueryWrapper<>();
           
            return baseMapper.selectPage($!tool.firstLowerCase($!{tableInfo.name})Page, $!tool.firstLowerCase($!{tableInfo.name})Wrapper);       
        }
        
        /** 
         * 
         * @param $!tool.firstLowerCase($!{tableInfo.name})dto 实例对象
         * @author $!author  
         * @description //TODO  新增数据
         * @date $!time.currTime()
         * @return 实例对象
         */
        @Override
        public void insert($!{tableInfo.name}Dto $!tool.firstLowerCase($!{tableInfo.name})dto) {
                $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}) = ModelUtil.copyModel($!tool.firstLowerCase($!{tableInfo.name})dto, $!{tableInfo.name}.class);
                $!{tool.firstLowerCase($!{tableInfo.name})}.setIsDelete(ModelIsDelEnum.EFFECTIVE.getCode());
                $!{tool.firstLowerCase($!{tableInfo.name})}.setCreatedTime(LocalDateTime.now());
                baseMapper.insert($!tool.firstLowerCase($!{tableInfo.name}));
        }
        
        
        /** 
         * 
         * @param $!tool.firstLowerCase($!{tableInfo.name})dto 实例对象
         * @author $!author  
         * @description //TODO  修改数据并返回
         * @date $!time.currTime()
         * @return 实例对象
         */
        @Override
        public $!{tableInfo.name} update($!{tableInfo.name}Dto $!tool.firstLowerCase($!{tableInfo.name})dto) {
                $!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}) = ModelUtil.copyModel($!tool.firstLowerCase($!{tableInfo.name})dto, $!{tableInfo.name}.class);
                $!{tool.firstLowerCase($!{tableInfo.name})}.setUpdatedTime(LocalDateTime.now());
                baseMapper.updateById($!{tool.firstLowerCase($!{tableInfo.name})});
                return  baseMapper.selectById($!{tool.firstLowerCase($!{tableInfo.name})}.getId());
        }
        
        
        /**
         *
         * @param idList 主键
         * @author $!author 
         * @description //TODO    通过主键删除数据
         * @date $!time.currTime()
         * @return
         */
        @Override
        public void deleteById(List<Long> idList) {
            if(idList!=null && idList.size()>0){
                for(int i = 0;i < idList.size(); i++ ){
                     baseMapper.deleteById(idList.get(i));
                }
            }
        }
}

Dao

##导入宏定义
$!{define.vm}
$!define
$!init

##设置表后缀(宏定义)
#setTableSuffix("Dao")

##保存文件(宏定义)
#save("/dao", "Dao.java")

##包路径(宏定义)
#setPackageSuffix("dao")

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import $!{tableInfo.savePackageName}.domain.po.$!tableInfo.name;
import org.apache.ibatis.annotations.Mapper;
##表注释(宏定义)
#tableComment("表数据库访问层")
@Mapper
public interface $!{tableName} extends BaseMapper<$!tableInfo.name> {

}

Dto

##引入宏定义
$!{define.vm}
$!define
$!init

##设置表后缀(宏定义)
#setTableSuffix("dto")

##保存文件(宏定义)
#save("/domain/dto", "Dto.java")

##包路径(宏定义)
#setPackageSuffix("domain.dto")
##使用全局变量实现默认包导入
$!autoImport
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
##使用宏定义实现类注释信息
#tableComment("参数封装类")
@Data()
@EqualsAndHashCode()
public class $!{tableInfo.name}Dto  {

    #foreach($column in $tableInfo.fullColumn)
        #if(${column.comment})/**
        * ${column.comment}
        */#end
        
    private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
    
    #end
    /**
    * 页
    */
    private Integer pageNum;
    /**
    * 条
    */
    private Integer pageSize;
    /**
    * 开始时间
    */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;
    /**
    * 结束时间
    */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
    
    public Integer getPageNum() {
        return pageNum == null ? 1 : pageNum;
    }

    public Integer getPageSize() {
        return pageSize == null ? 10 : pageSize;
    }

}

PO

##导入宏定义
$!{define.vm}
$!define
$!init

##保存文件(宏定义)
#save("/domain/po", ".java")

##包路径(宏定义)
#setPackageSuffix("domain.po")

##自动导入包(全局变量)
$!autoImport
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
##表注释(宏定义)
#tableComment("表实体类")
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("serial")
@Data()
public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> implements Serializable {

 private static final long serialVersionUID = $!tool.serial();
 
#foreach($column in $tableInfo.fullColumn)
    #if(${column.comment})/**
    * ${column.comment}
    */#end

    private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end
#foreach($column in $tableInfo.pkColumn)
    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    protected Serializable pkVal() {
        return this.$!column.name;
    }
    #break
#end
}

mapper.xml

##引入mybatis支持
$!mybatisSupport

##设置保存名称与保存位置
$!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml"))
$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))

##拿到主键
#if(!$tableInfo.pkColumn.isEmpty())
    #set($pk = $tableInfo.pkColumn.get(0))
#end

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="$!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao">

    <resultMap type="$!{tableInfo.savePackageName}.domain.po.$!{tableInfo.name}" id="$!{tableInfo.name}Map">
#foreach($column in $tableInfo.fullColumn)
        <result property="$!column.name" column="$!column.obj.name" jdbcType="$!column.ext.jdbcType"/>
#end
    </resultMap>



</mapper>

模板配置成功idea连接数据库

        

输入数据库的账号密码

第一次用可能要去下载对应连接的jar包

 如果出现市区问题,去Advanced修改这个字段为GMT

点击测试连接,连接成功

选择对应数据表

 选择包路径

我这里是全选了,有需要可以自己来选择

生成成功

ModelUtil
import org.springframework.beans.BeanUtils;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author 洛无异
 * @description //TODO model copy 工具类
 * @date 2021/4/19 11:13
 */
public class ModelUtil {
    public static <K, V> V copyModel(K k, Class<V> vClass){
        try {
            return copyModel(k, vClass.newInstance());
        }catch (Exception e){
            throw new BusinessException(BusinessEnum.SYSTEM_HANDLE_ERROR);
        }
    }

    public static <K, V> V copyModel(K k, Class<V> vClass, ModelUtilsProcessor<K, V> processor){
        try {
            return copyModel(k, vClass.newInstance(), processor);
        }catch (Exception e){
            throw new BusinessException(BusinessEnum.SYSTEM_HANDLE_ERROR);
        }
    }

    public static <K, V> V copyModel(K k, Class<V> vClass, ModelUtilsFilter<K, V> filter) {
        try {
            return copyModel(k, vClass.newInstance(), filter);
        }catch (Exception e){
            throw new BusinessException(BusinessEnum.SYSTEM_HANDLE_ERROR);
        }
    }

    /**
     *
     * 复制kList的每一项到list中
     * @param kList source
     * @param classV  生成的list中每一项的类型
     * @author 洛无异
     * @description //TODO 创建包含kList.size()个ClassV实例的list,并调用org.springframework.beans.BeanUtils,
     * @date 2021/4/19 11:14
     * @return java.util.List<V>
     */
    public static <K, V> List<V> copyModelList(Iterable<K> kList, Class<V> classV)
            {
        List<V> vList = new ArrayList<>();
        try {
            for (K k : kList)
                vList.add(copyModel(k, classV.newInstance()));
        }catch (Exception e){
            throw new BusinessException(BusinessEnum.SYSTEM_HANDLE_ERROR);
        }
        return vList;
    }

    /**
     * 
     * @param kList source
     * @param classV 生成的list中每一项的类型
     * @param processor  每次复制时对BeanUtils.copyProperties(source, target)中的source,target调用方法processor.process(source, target)
     * @author 洛无异 
     * @description //TODO   创建包含kList.size()个ClassV实例的vlist,并调用org.springframework.beans.BeanUtils.copyProperties(), 复制kList的每一项到vlist中,之后再对vlist的每一项执行processor.process(k, v)
     * @date 2021/4/19 11:15 
     * @return java.util.List<V>
     */
    public static <K, V> List<V> copyModelList(Iterable<K> kList, Class<V> classV, ModelUtilsProcessor<K, V> processor)
            throws Exception {
        List<V> vList = new ArrayList<>();
        try {
            for (K k : kList)
                if (processor.filter(k))
                    vList.add(copyModel(k, classV.newInstance(), processor));
        }catch (Exception e){
            throw new BusinessException(BusinessEnum.SYSTEM_HANDLE_ERROR);
        }
        return vList;
    }

    /**
     *
     * @param kList
     * @param classV
     * @param filter
     * @author 洛无异
     * @description //TODO   同上,但是接口换成了默认实现process()的ModelUtilsFilter,便于使用lambda表达式
     * @date 2021/4/19 11:15
     * @return java.util.List<V>
     */
    public static <K, V> List<V> copyModelList(Iterable<K> kList, Class<V> classV, ModelUtilsFilter<K, V> filter)
            throws Exception {
        List<V> vList = new ArrayList<>();
        try {
            for (K k : kList)
                if (filter.filter(k))
                    vList.add(copyModel(k, classV.newInstance(), filter));
        }catch (Exception e){
            throw new BusinessException(BusinessEnum.SYSTEM_HANDLE_ERROR);
        }
        return vList;
    }

    /**
     *
     * @param kList modelList
     * @param classK modelList的类型
     * @author 洛无异
     * @description //TODO 获取kList中的所有id
     * @date 2021/4/19 11:16
     * @return java.util.List<java.lang.String>
     * @throws Exception 如果classV.getId()返回值类型不是string类型的,会抛出异常
     */
    public static <K> List<String> getModelIdList(Iterable<K> kList, Class<K> classK) throws Exception {
        List<String> idList = new ArrayList<>();
        for (K k : kList) {
            Method getId = classK.getMethod("getId");
            Object idobj = getId.invoke(k);
            if (!(idobj instanceof String))
                throw new Exception("The return value of " + classK.toString() + ".getId() is not a String type.");

            String id = (String) idobj;
            idList.add(id);
        }

        return idList;
    }

    private static <K, V> V copyModel(K k, V v) {
        BeanUtils.copyProperties(k, v);
        return v;
    }

    private static <K, V> V copyModel(K k, V v, ModelUtilsProcessor<K, V> processor) throws Exception {
        BeanUtils.copyProperties(k, v);
        processor.process(k, v);
        return v;
    }

    private static <K, V> V copyModel(K k, V v, ModelUtilsFilter<K, V> filter) throws Exception {
        BeanUtils.copyProperties(k, v);
        filter.process(k, v);
        return v;
    }
}

ModelUtilsFilter
/**
 *
 * @author 洛无异
 * @description //TODO
 * @date 2021/4/19 11:19
 */
public interface ModelUtilsFilter<K, V> {
    default void process(K k, V v) throws Exception {
    }

    boolean filter(K k) throws Exception;
}

ModelUtilsProcessor
public interface ModelUtilsProcessor<K, V> {
    void process(K k, V v) throws Exception;

    default boolean filter(K k) {
        return true;
    }
}

BusinessException 异常封装类
import lombok.Data;

/**
 *
 * @author 洛无异
 * @description //TODO  自定义异常处理类
 * @date 2021/4/19 11:19
 */
@Data
public class BusinessException extends RuntimeException{

    private static final long serialVersionUID = 8204335493386165578L;
    /**
     * 状态码
     */
    private Integer code;

    /**
     * 信息
     */
    private String msg;


    /**
     * 传入BusinessEnum类
     * @param businessEnum
     */
    public BusinessException(BusinessEnum businessEnum){
        this.code = businessEnum.getCode();
        this.msg = businessEnum.getMsg();
    }

    public BusinessException(int code ,String msg){
        this.code = code;
        this.msg = msg;
    }
    public BusinessException(String msg){
        super(msg);
        this.msg = msg;
    }
BusinessEnum 
import lombok.Getter;
import lombok.Setter;

/**
 * @author 洛无异
 * @description //TODO   自定义异常处理类
 * @date 2021/4/19 11:18
 */
public enum BusinessEnum {

    SUCCESS(0, "成功"),
    PARAMETER_ERROR(1, "参数错误"),
    ERROR(2, "处理失败");


    @Setter
    @Getter
    private Integer code;

    @Setter
    @Getter
    private String msg;

    BusinessEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
}
Response
import com.yzchn.admin.common.enums.ResCodeEnum;
import com.yzchn.admin.util.BusinessEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * @description: 接口返回对象
 * @author: 洛无异
 * @create: 2020-04-23 14:32
 **/
@Data
public class Response<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private String code;
    private String message;
    private T data;
    private boolean success;

    private Response() {

    }

    public Response(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> Response<T> getInstance(ResCodeEnum res) {
        Response<T> instance = new Response();
        instance.setCode(res.getCode());
        instance.setMessage(res.getResMsg());
        return instance;
    }

    public static <T> Response<T> getInstance(ResCodeEnum res, String message) {
        Response<T> instance = new Response();
        instance.setCode(res.getCode());
        instance.setMessage(message);
        return instance;
    }

    public static <T> Response<T> ok(BusinessEnum res, T data) {
        Response<T> instance = new Response();
        instance.setCode(res.getCode().toString());
        instance.setMessage(res.getMsg());
        instance.setSuccess(true);
        instance.setData(data);
        return instance;
    }

    public static <T> Response<T> ok(BusinessEnum res) {
        Response<T> instance = new Response();
        instance.setCode(res.getCode().toString());
        instance.setMessage(res.getMsg());
        instance.setSuccess(true);
        return instance;
    }

    public static <T> Response<T> error(BusinessEnum res, T data) {
        Response<T> instance = new Response();
        instance.setCode(res.getCode().toString());
        instance.setMessage(res.getMsg());
        instance.setSuccess(false);
        return instance;
    }

    public static <T> Response<T> error(BusinessEnum res) {
        Response<T> instance = new Response();
        instance.setCode(res.getCode().toString());
        instance.setMessage(res.getMsg());
        instance.setSuccess(false);
        return instance;
    }

    public static <T> Response<T> error(BusinessEnum res, String message) {
        Response<T> instance = new Response();
        instance.setCode(res.getCode().toString());
        instance.setMessage(message);
        instance.setSuccess(false);
        return instance;
    }

}

记录一下,反正也没人看

  • 7
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值