天天看點

easycode household模闆

一、模闆:household-entity.java

##引入宏定義
$!define

##使用宏定義設定回調(儲存位置與檔案字尾)
#save("/entity", "Entity.java")

##使用宏定義設定包字尾
#setPackageSuffix("entity")

##使用全局變量實作預設包導入
$!autoImport
import cn.ii8080.household.commons.base.AbstractEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * $!{tableInfo.comment}($!{tableInfo.obj.name})表資料實體類
 *
 * <p><span style='color:red;font-weight:bold;'>注意:因為本實體使用了lombok插件,給出的字段已包含get與set方法,你可以點選下方的“序列化表格”了解有那些字段</span></p>
 *
 * @author $!author
 * @since $!time.currTime()
 */
@Data
@EqualsAndHashCode(callSuper=true)
@TableName("$!{tableInfo.obj.name}")
public class $!{tableInfo.name}Entity extends AbstractEntity<$!{tableInfo.name}Entity> {
#set($temp = $tool.newHashSet("id","createTime","updateTime","createBy","updateBy"))
#foreach($item in $temp)
    #set($newList = $tool.newArrayList())
    #foreach($column in $tableInfo.fullColumn)
        #if($column.name!=$item)
            $tool.call($newList.add($column))#end#end
    $tableInfo.setFullColumn($newList) #end
    
#foreach($column in $tableInfo.fullColumn)
#if(${column.comment})
    /**
     * ${column.comment}
     */#end
    
    private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
#end
}
           

二、模闆:household-dao.java

##導入宏定義
$!define

##設定表字尾(宏定義)
#setTableSuffix("Dao")

##儲存檔案(宏定義)
#save("/dao", "Dao.java")

##包路徑(宏定義)
#setPackageSuffix("dao")

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}Entity;

/**
 * $!{tableInfo.comment}($!{tableInfo.obj.name})表資料庫通路層
 *
 * <p><span style='color:red;font-weight:bold;'>重要提示:</span><i><a href='https://mp.baomidou.com/guide/crud-interface.html#mapper-crud-%E6%8E%A5%E5%8F%A3' target='_blank'>BaseMapper使用請參考 mybatis-plus 3.x Mapper CRUD 接口</a></i></p>
 *
 * @author $!author
 * @since $!time.currTime()
 */
public interface $!{tableName} extends BaseMapper<$!{tableInfo.name}Entity> {

}
           

三、模闆:household-service.java

##導入宏定義
$!define

##設定表字尾(宏定義)
#setTableSuffix("Service")

##儲存檔案(宏定義)
#save("/service", "Service.java")

##包路徑(宏定義)
#setPackageSuffix("service")

import com.baomidou.mybatisplus.extension.service.IService;
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}Entity;

##表注釋(宏定義)
/**
 * $!{tableInfo.comment}($!{tableInfo.obj.name})表服務接口
 *
 * <p><span style='color:red;font-weight:bold;'>重要提示:</span><i><a href='https://mp.baomidou.com/guide/crud-interface.html#service-crud-%E6%8E%A5%E5%8F%A3' target='_blank'>IService使用請參考 mybatis-plus 3.x Service CRUD 接口</a></i></p>
 *
 * @author $!author
 * @since $!time.currTime()
 */
public interface $!{tableName} extends IService<$!{tableInfo.name}Entity> {

}
           

四、模闆:household-serviceImpl.java

##導入宏定義
$!define

##設定表字尾(宏定義)
#setTableSuffix("ServiceImpl")

##儲存檔案(宏定義)
#save("/service/impl", "ServiceImpl.java")

##包路徑(宏定義)
#setPackageSuffix("service.impl")

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;
import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name}Entity;
import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;
import org.springframework.stereotype.Service;

/**
 * $!{tableInfo.comment}($!{tableInfo.obj.name})表服務接口實作
 *
 * <p><span style='color:red;font-weight:bold;'>重要提示:</span><i><a href='https://mp.baomidou.com/guide/crud-interface.html#service-crud-%E6%8E%A5%E5%8F%A3' target='_blank'>IService使用請參考 mybatis-plus 3.x Service CRUD 接口</a></i></p>
 *
 * @author $!author
 * @since $!time.currTime()
 */
@Service()
public class $!{tableName} extends ServiceImpl<$!{tableInfo.name}Dao, $!{tableInfo.name}Entity> implements $!{tableInfo.name}Service {
 
}
           

五、模闆:household-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">


</mapper>