模板代码(dot.js语法)
基础模板
实体类
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* @author : Y.P
* @date : 2023-11-28
*/
@Data
@Table(name = "FCA_APPLICATION_SCORE")
public class FcaApplicationScore {
// F主键
@Column(name ="ID")
@Id
private String id ;
// 流水号
@Column(name ="APP_NO")
private String appNo ;
}
{{ var today=new Date();
var fullYear=today.getFullYear();
var month=today.getMonth() + 1;
var days=today.getDate();
var pkVarName = "undefinedId";
var pkDataType = "String";
it.entity.fields.forEach(function(field){
if(field.primaryKey){
pkVarName = it.func.camel(field.defKey,false);
pkDataType = field["type"];
return;
}
});
var pkgName = it.entity.env.base.nameSpace;
var beanClass = it.entity.env.base.codeRoot;
var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
var serviceClass = beanClass+'Service';
var serviceVarName= beanVarName+'Service';
}}
$blankline
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
$blankline
/**
* @author : Y.P
* @date : {{=fullYear}}-{{=month}}-{{=days}}
*/
@Data
@Table(name = "{{=it.entity.defKey}}")
public class {{=beanClass}} {
{{~it.entity.fields:field:index}}
// {{=field.defName}}
@Column(name ="{{=field.defKey}}")
{{? field.primaryKey }}
@Id
{{?}}
private {{? field.type === 'varchar' }}String{{??}}{{=field.type}}{{?}} {{=it.func.camel(field.defKey,false)}} ;
{{~}}
$blankline
}
Mapper
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* FCA_APPLICATION_SCORE
* @author : Y.P
* @date : 2023-12-4
*/
@Mapper
public interface FcaApplicationScoreMapper extends BaseMapper<FcaApplicationScore> {
}
{{ var today=new Date();
var fullYear=today.getFullYear();
var month=today.getMonth() + 1;
var days=today.getDate();
var pkVarName = "undefinedId";
var pkDataType = "String";
it.entity.fields.forEach(function(field){
if(field.primaryKey){
pkVarName = it.func.camel(field.defKey,false);
pkDataType = field["type"];
return;
}
});
var pkgName = it.entity.env.base.nameSpace;
var beanClass = it.entity.env.base.codeRoot;
var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
var serviceClass = beanClass+'Service';
var serviceVarName= beanVarName+'Service';
}}
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
$blankline
/**
* {{=it.entity.defKey}} {{=it.entity.defName}}
* @author : Y.P
* @date : {{=fullYear}}-{{=month}}-{{=days}}
*/
@Mapper
public interface {{=beanClass}}Mapper extends BaseMapper<{{=beanClass}}> {
}
Mapper.XML
<?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">
<resultMap id="BaseResultMap" type=".mapper.CrdOutdataCallrecordMapper">
<resultMap type=".entity.CrdOutdataCallrecord" id="CrdOutdataCallrecordMap">
<result column="ID" jdbcType="VARCHAR" property="id"/>
<result column="SERIAL_NUMBER" jdbcType="VARCHAR" property="serialNumber"/>
<result column="RESOURCE_CODE" jdbcType="VARCHAR" property="resourceCode"/>
<result column="RESOURCE_NAME" jdbcType="VARCHAR" property="resourceName"/>
<result column="RESOURCE_VERSION" jdbcType="VARCHAR" property="resourceVersion"/>
<result column="ORDER_ID" jdbcType="VARCHAR" property="orderId"/>
<result column="REQ_JSON" jdbcType="TEXT" property="reqJson"/>
<result column="RES_JSON" jdbcType="MEDIUMTEXT" property="resJson"/>
<result column="CREATE_TIME" jdbcType="VARCHAR" property="createTime"/>
</resultMap>
<!-- 通过ID查询单条数据 -->
<select id="queryById" resultMap="CrdOutdataCallrecordMap">
select
ID,SERIAL_NUMBER,RESOURCE_CODE,RESOURCE_NAME,RESOURCE_VERSION,ORDER_ID,REQ_JSON,RES_JSON,CREATE_TIME
from crd_outdata_callrecord
where ID =
</select>
<!--分页查询指定行数据-->
<select id="queryAllByLimit" resultMap="CrdOutdataCallrecordMap">
select
ID,SERIAL_NUMBER,RESOURCE_CODE,RESOURCE_NAME,RESOURCE_VERSION,ORDER_ID,REQ_JSON,RES_JSON,CREATE_TIME
from crd_outdata_callrecord
<where>
<if test="id != null and id != ''">
and ID =
</if>
<if test="serialNumber != null and serialNumber != ''">
and SERIAL_NUMBER =
</if>
<if test="resourceCode != null and resourceCode != ''">
and RESOURCE_CODE =
</if>
<if test="resourceName != null and resourceName != ''">
and RESOURCE_NAME =
</if>
<if test="resourceVersion != null and resourceVersion != ''">
and RESOURCE_VERSION =
</if>
<if test="orderId != null and orderId != ''">
and ORDER_ID =
</if>
<if test="reqJson != null and reqJson != ''">
and REQ_JSON =
</if>
<if test="resJson != null and resJson != ''">
and RES_JSON =
</if>
<if test="createTime != null and createTime != ''">
and CREATE_TIME =
</if>
</where>
limit
</select>
<!--新增数据-->
<insert id="insert" keyProperty="ID" useGeneratedKeys="true">
insert into crd_outdata_callrecord
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
ID,
</if>
<if test="serialNumber != null">
SERIAL_NUMBER,
</if>
<if test="resourceCode != null">
RESOURCE_CODE,
</if>
<if test="resourceName != null">
RESOURCE_NAME,
</if>
<if test="resourceVersion != null">
RESOURCE_VERSION,
</if>
<if test="orderId != null">
ORDER_ID,
</if>
<if test="reqJson != null">
REQ_JSON,
</if>
<if test="resJson != null">
RES_JSON,
</if>
<if test="createTime != null">
CREATE_TIME,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
</if>
<if test="serialNumber != null">
</if>
<if test="resourceCode != null">
</if>
<if test="resourceName != null">
</if>
<if test="resourceVersion != null">
</if>
<if test="orderId != null">
</if>
<if test="reqJson != null">
</if>
<if test="resJson != null">
</if>
<if test="createTime != null">
</if>
</trim>
</insert>
<!-- 更新数据 -->
<update id="update">
update crd_outdata_callrecord
<set>
<if test="id != null and id != ''">
ID =
</if>
<if test="serialNumber != null and serialNumber != ''">
SERIAL_NUMBER =
</if>
<if test="resourceCode != null and resourceCode != ''">
RESOURCE_CODE =
</if>
<if test="resourceName != null and resourceName != ''">
RESOURCE_NAME =
</if>
<if test="resourceVersion != null and resourceVersion != ''">
RESOURCE_VERSION =
</if>
<if test="orderId != null and orderId != ''">
ORDER_ID =
</if>
<if test="reqJson != null and reqJson != ''">
REQ_JSON =
</if>
<if test="resJson != null and resJson != ''">
RES_JSON =
</if>
<if test="createTime != null and createTime != ''">
CREATE_TIME =
</if>
</set>
where ID =
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from crd_outdata_callrecord where ID =
</delete>
</mapper>
{{ var today=new Date();
var fullYear=today.getFullYear();
var month=today.getMonth() + 1;
var days=today.getDate();
var pkVarName = "undefinedId";
var pkDataType = "String";
var pkField = "UNDEFINED_ID";
it.entity.fields.forEach(function(field){
if(field.primaryKey){
pkField = field.defKey;
pkVarName = it.func.camel(field.defKey,false);
pkDataType = field["type"];
return;
}
});
var pkgName = it.entity.env.base.nameSpace;
var beanClass = it.entity.env.base.codeRoot;
var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
var serviceClass = beanClass+'Service';
var serviceVarName= beanVarName+'Service';
}}<?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">
<resultMap id="BaseResultMap" type="{{=pkgName}}.mapper.{{=beanClass}}Mapper">
<resultMap type="{{=pkgName}}.entity.{{=beanClass}}" id="{{=beanClass}}Map">
{{~it.entity.fields:field:index}}
<result column="{{=field.defKey}}" jdbcType="{{=field.dbType}}" property="{{=it.func.camel(field.defKey,false)}}"/>
{{~}}
</resultMap>
$blankline
<!-- 通过ID查询单条数据 -->
<select id="queryById" resultMap="{{=beanClass}}Map">
select
{{=it.entity.fields.map(function(e,i){return e.defKey}).join(',')}}
from {{=it.entity.defKey}}
where {{=pkField}} = #{{{=pkVarName}}}
</select>
$blankline
<!--分页查询指定行数据-->
<select id="queryAllByLimit" resultMap="{{=beanClass}}Map">
select
{{=it.entity.fields.map(function(e,i){return e.defKey}).join(',')}}
from {{=it.entity.defKey}}
<where>
{{~it.entity.fields:field:index}}
<if test="{{=it.func.camel(field.defKey,false)}} != null and {{=it.func.camel(field.defKey,false)}} != ''">
and {{=field.defKey}} = #{{{=it.func.camel(field.defKey,false)}}}
</if>
{{~}}
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
$blankline
<!--新增数据-->
<insert id="insert" keyProperty="{{=pkField}}" useGeneratedKeys="true">
insert into {{=it.entity.defKey}}
<trim prefix="(" suffix=")" suffixOverrides=",">
{{~it.entity.fields:field:index}}
<if test="{{=it.func.camel(field.defKey,false)}} != null">
{{=field.defKey}},
</if>
{{~}}
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
{{~it.entity.fields:field:index}}
<if test="{{=it.func.camel(field.defKey,false)}} != null">
#{{{=it.func.camel(field.defKey,false)}},jdbcType={{=field.dbType}}},
</if>
{{~}}
</trim>
</insert>
$blankline
$blankline
<!-- 更新数据 -->
<update id="update">
update {{=it.entity.defKey}}
<set>
{{~it.entity.fields:field:index}}
<if test="{{=it.func.camel(field.defKey,false)}} != null and {{=it.func.camel(field.defKey,false)}} != ''">
{{=field.defKey}} = #{{{=it.func.camel(field.defKey,false)}}},
</if>
{{~}}
</set>
where {{=pkField}} = #{{{=pkVarName}}}
</update>
$blankline
<!--通过主键删除-->
<delete id="deleteById">
delete from {{=it.entity.defKey}} where {{=pkField}} = #{{{=pkVarName}}}
</delete>
</mapper>