607 lines
24 KiB
Plaintext
607 lines
24 KiB
Plaintext
{
|
|
"Mybatis mapper template": {
|
|
"scope": "xml",
|
|
"prefix": "mybatis-mapper",
|
|
"isFileTemplate": true,
|
|
"body": [
|
|
"<?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=\"${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.dal.mapper.${5:ModuleShortName}${7:Entity}Mapper\">",
|
|
"\t<!-- //////////////////// INSERT //////////////////// -->",
|
|
"\t<!--",
|
|
"\t\tint insert(${5:ModuleShortName}${7:Entity}Info po);",
|
|
"\t-->",
|
|
"\t<insert id=\"insert\" useGeneratedKeys=\"true\" keyColumn=\"id\" keyProperty=\"id\">",
|
|
"\t\tINSERT INTO ${4:module_short_name}_${6:entity}",
|
|
"\t\t(",
|
|
"\t\t\temail, phone_num, username, password, salt, avatar, sex, nickname, remarks, status,",
|
|
"\t\t\t# TODO: other columns",
|
|
"\t\t\tcreated_by, created_time, updated_by, updated_time, version",
|
|
"\t\t)",
|
|
"\t\tVALUES",
|
|
"\t\t(",
|
|
"\t\t\t#{email}, #{phoneNum}, #{username}, #{password}, #{salt}, #{avatar}, #{sex}, #{nickname}, #{remarks}, #{status},",
|
|
"\t\t\t# TODO: other properties",
|
|
"\t\t\t#{createdBy}, #{createdTime}, #{updatedBy}, #{updatedTime}, #{version}",
|
|
"\t\t)",
|
|
"\t</insert>",
|
|
"",
|
|
"\t<!-- //////////////////// DELETE //////////////////// -->",
|
|
"\t<!--",
|
|
"\t\tint delete(${5:ModuleShortName}${7:Entity}Info po);",
|
|
"\t-->",
|
|
"\t<update id=\"delete\">",
|
|
"\t\tUPDATE ${4:module_short_name}_${6:entity}",
|
|
"\t\tSET deleted = id,",
|
|
"\t\t\tversion = version + 1",
|
|
"\t\tWHERE deleted = 0 AND id = #{id} AND version = #{version}",
|
|
"\t</update>",
|
|
"",
|
|
"\t<!-- //////////////////// UPDATE //////////////////// -->",
|
|
"\t<!--",
|
|
"\t\tint update(${5:ModuleShortName}${7:Entity}Info po);",
|
|
"\t-->",
|
|
"\t<update id=\"update\">",
|
|
"\t\tUPDATE ${4:module_short_name}_${6:entity}",
|
|
"\t\tSET email\t\t= #{email},",
|
|
"\t\t\tphone_num\t= #{phoneNum},",
|
|
"\t\t\tusername\t = #{username},",
|
|
"\t\t\tpassword\t = #{password},",
|
|
"\t\t\tsalt\t\t = #{salt},",
|
|
"\t\t\tavatar\t = #{avatar},",
|
|
"\t\t\tsex\t\t = #{sex},",
|
|
"\t\t\tnickname\t = #{nickname},",
|
|
"\t\t\tremarks\t = #{remarks},",
|
|
"\t\t\tstatus\t = #{status},",
|
|
"\t\t\t# TODO: other columns",
|
|
"\t\t\t# created_by = #{createdBy},",
|
|
"\t\t\t# created_time = #{createdTime},",
|
|
"\t\t\tupdated_by = #{updatedBy},",
|
|
"\t\t\tupdated_time = #{updatedTime},",
|
|
"\t\t\tversion = version + 1",
|
|
"\t\tWHERE deleted = 0 AND id = #{id} AND version = #{version}",
|
|
"\t</update>",
|
|
"",
|
|
"\t<!-- //////////////////// SELECT //////////////////// -->",
|
|
"",
|
|
"\t<sql id=\"SELECT_${5:ModuleShortName}${7:Entity}PO\">",
|
|
"\t\tSELECT",
|
|
"\t\t\t${8:a}.id\t\t AS ${8:a}_id,",
|
|
"\t\t\t${8:a}.email\t\tAS ${8:a}_email,",
|
|
"\t\t\t${8:a}.phone_num\tAS ${8:a}_phone_num,",
|
|
"\t\t\t${8:a}.username\t AS ${8:a}_username,",
|
|
"\t\t\t${8:a}.password\t AS ${8:a}_password,",
|
|
"\t\t\t${8:a}.salt\t\t AS ${8:a}_salt,",
|
|
"\t\t\t${8:a}.avatar\t AS ${8:a}_avatar,",
|
|
"\t\t\t${8:a}.sex\t\t AS ${8:a}_sex,",
|
|
"\t\t\t${8:a}.nickname\t AS ${8:a}_nickname,",
|
|
"\t\t\t${8:a}.remarks\t AS ${8:a}_remarks,",
|
|
"\t\t\t${8:a}.status\t AS ${8:a}_status,",
|
|
"\t\t\t# TODO: other columns",
|
|
"\t\t\t${8:a}.created_by AS ${8:a}_created_by,",
|
|
"\t\t\t${8:a}.created_time AS ${8:a}_created_time,",
|
|
"\t\t\t${8:a}.updated_by AS ${8:a}_updated_by,",
|
|
"\t\t\t${8:a}.updated_time AS ${8:a}_updated_time,",
|
|
"\t\t\t${8:a}.version\t AS ${8:a}_version",
|
|
"\t\tFROM ${4:module_short_name}_${6:entity} AS ${8:a}",
|
|
"\t</sql>",
|
|
"",
|
|
"\t<resultMap id=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\" type=\"${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.info.${5:ModuleShortName}${7:Entity}Info\">",
|
|
"\t\t<id column=\"${8:a}_id\" property=\"id\" javaType=\"Long\" />",
|
|
"\t\t<result column=\"${8:a}_email\" property=\"email\" />",
|
|
"\t\t<result column=\"${8:a}_phone_num\" property=\"phoneNum\" />",
|
|
"\t\t<result column=\"${8:a}_username\" property=\"username\" />",
|
|
"\t\t<result column=\"${8:a}_password\" property=\"password\" />",
|
|
"\t\t<result column=\"${8:a}_salt\" property=\"salt\" />",
|
|
"\t\t<result column=\"${8:a}_avatar\" property=\"avatar\" />",
|
|
"\t\t<result column=\"${8:a}_sex\" property=\"sex\" />",
|
|
"\t\t<result column=\"${8:a}_nickname\" property=\"nickname\" />",
|
|
"\t\t<result column=\"${8:a}_remarks\" property=\"remarks\" />",
|
|
"\t\t<result column=\"${8:a}_status\" property=\"status\" />",
|
|
"\t\t<!-- TODO: other columns -->",
|
|
"\t\t<result column=\"${8:a}_created_by\" property=\"createdBy\" javaType=\"Long\" />",
|
|
"\t\t<result column=\"${8:a}_created_time\" property=\"createdTime\" javaType=\"java.time.LocalDateTime\" />",
|
|
"\t\t<result column=\"${8:a}_updated_by\" property=\"updatedBy\" javaType=\"Long\" />",
|
|
"\t\t<result column=\"${8:a}_updated_time\" property=\"updatedTime\" javaType=\"java.time.LocalDateTime\" />",
|
|
"\t\t<result column=\"${8:a}_version\" property=\"version\" javaType=\"Long\" />",
|
|
"\t</resultMap>",
|
|
"",
|
|
"\t<!--",
|
|
"\t\t${5:ModuleShortName}${7:Entity}Info findById(Long id);",
|
|
"\t-->",
|
|
"\t<select id=\"findById\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
|
"\t\tWHERE ${8:a}.deleted = 0 AND ${8:a}.id = #{id}",
|
|
"\t\tLIMIT 1",
|
|
"\t</select>",
|
|
"",
|
|
"\t<!--",
|
|
"\t\tCollection<${5:ModuleShortName}${7:Entity}Info> findByIdIn(Collection<Long> ids);",
|
|
"\t-->",
|
|
"\t<select id=\"findByIdIn\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
|
"\t\tWHERE ${8:a}.deleted = 0 AND ${8:a}.id IN",
|
|
"\t\t<foreach collection=\"ids\" item=\"id\" open=\"(\" close=\")\" separator=\",\">",
|
|
"\t\t\t#{id}",
|
|
"\t\t</foreach>",
|
|
"\t</select>",
|
|
"",
|
|
"\t<!--",
|
|
"\t\tCollection<${5:ModuleShortName}${7:Entity}Info> query(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
|
"\t-->",
|
|
"\t<select id=\"query\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
|
"\t\t,",
|
|
"\t\t(SELECT id FROM ${4:module_short_name}_${6:entity} WHERE deleted = 0",
|
|
"\t\t<if test=\"id != null\">",
|
|
"\t\t\tAND id = #{id}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"email != null\">",
|
|
"\t\t\tAND email = #{email}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"phoneNum != null\">",
|
|
"\t\t\tAND phone_num = #{phoneNum}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"username != null\">",
|
|
"\t\t\tAND username = #{username}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"sex != null\">",
|
|
"\t\t\tAND sex = #{sex}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"nickname != null\">",
|
|
"\t\t\tAND nickname = #{nickname}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"remarks != null\">",
|
|
"\t\t\tAND remarks LIKE '%#{remarks}%'",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"status != null\">",
|
|
"\t\t\tAND status = #{status}",
|
|
"\t\t</if>",
|
|
"\t\t<!-- TODO: other params -->",
|
|
"\t\t<if test=\"createdBy != null\">",
|
|
"\t\t\tAND created_by = #{createdBy}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"createdTimeStart != null\">",
|
|
"\t\t\tAND created_time > #{createdTimeStart}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"createdTimeEnd != null\">",
|
|
"\t\t\tAND created_time < #{createdTimeEnd}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"updatedBy != null\">",
|
|
"\t\t\tAND updated_by = #{updatedBy}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"updatedTimeStart != null\">",
|
|
"\t\t\tAND updated_time > #{updatedTimeStart}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"updatedTimeEnd != null\">",
|
|
"\t\t\tAND updated_time < #{updatedTimeEnd}",
|
|
"\t\t</if>",
|
|
"\t\tLIMIT #{size} OFFSET #{offset}) b",
|
|
"\t\tWHERE ${8:a}.id = b.id",
|
|
"\t</select>",
|
|
"",
|
|
"\t<!--",
|
|
"\t\tlong count(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
|
"\t-->",
|
|
"\t<select id=\"count\" resultType=\"long\">",
|
|
"\t\tSELECT COUNT(*) FROM ${4:module_short_name}_${6:entity} WHERE deleted = 0",
|
|
"\t\t<if test=\"id != null\">",
|
|
"\t\t\tAND id = #{id}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"email != null\">",
|
|
"\t\t\tAND email = #{email}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"phoneNum != null\">",
|
|
"\t\t\tAND phone_num = #{phoneNum}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"username != null\">",
|
|
"\t\t\tAND username = #{username}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"sex != null\">",
|
|
"\t\t\tAND sex = #{sex}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"nickname != null\">",
|
|
"\t\t\tAND nickname = #{nickname}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"remarks != null\">",
|
|
"\t\t\tAND remarks LIKE '%#{remarks}%'",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"status != null\">",
|
|
"\t\t\tAND status = #{status}",
|
|
"\t\t</if>",
|
|
"\t\t<!-- TODO: other params -->",
|
|
"\t\t<if test=\"createdBy != null\">",
|
|
"\t\t\tAND created_by = #{createdBy}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"createdTimeStart != null\">",
|
|
"\t\t\tAND created_time > #{createdTimeStart}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"createdTimeEnd != null\">",
|
|
"\t\t\tAND created_time < #{createdTimeEnd}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"updatedBy != null\">",
|
|
"\t\t\tAND updated_by = #{updatedBy}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"updatedTimeStart != null\">",
|
|
"\t\t\tAND updated_time > #{updatedTimeStart}",
|
|
"\t\t</if>",
|
|
"\t\t<if test=\"updatedTimeEnd != null\">",
|
|
"\t\t\tAND updated_time < #{updatedTimeEnd}",
|
|
"\t\t</if>",
|
|
"\t</select>",
|
|
"",
|
|
"\t<!--",
|
|
"\t\tCollection<${5:ModuleShortName}${7:Entity}Info> findBy${10:Entity2}Id(Long ${11:entity2}Id);",
|
|
"\t-->",
|
|
"\t<select id=\"findBy${10:Entity2}Id\" resultMap=\"${5:ModuleShortName}${7:Entity}PO_ResultMap\">",
|
|
"\t\t<include refid=\"SELECT_${5:ModuleShortName}${7:Entity}PO\" />",
|
|
"\t\tWHERE ${8:a}.deleted = 0",
|
|
"\t\t\tAND ${8:a}.id IN (SELECT ${6:entity}_id FROM ${4:module_short_name}_${6:entity}_${11:entity2} WHERE ${11:entity2}_id = #{${11:entity2}Id})",
|
|
"\t</select>",
|
|
"",
|
|
"\t<!--",
|
|
"\t\tint clear${10:Entity2}s(Long id);",
|
|
"\t-->",
|
|
"\t<delete id=\"clear${10:Entity2}s\">",
|
|
"\t\tDELETE FROM ${4:module_short_name}_${6:entity}_${11:entity2} WHERE ${6:entity}_id = #{id}",
|
|
"\t</delete>",
|
|
"",
|
|
"\t<!--",
|
|
"\t\tint bind${10:Entity2}s(Long id, Collection<Long> ${11:entity2}s);",
|
|
"\t-->",
|
|
"\t<insert id=\"bind${10:Entity2}s\">",
|
|
"\t\tINSERT INTO ${4:module_short_name}_${6:entity}_${11:entity2}(${6:entity}_id, ${11:entity2}_id)",
|
|
"\t\tVALUES",
|
|
"\t\t<foreach collection=\"${11:entity2}s\" item=\"${11:entity2}_id\" separator=\",\">",
|
|
"\t\t\t(#{id}, #{${11:entity2}_id})",
|
|
"\t\t</foreach>",
|
|
"\t</insert>",
|
|
"",
|
|
"</mapper>",
|
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseDomain /////////////// -->",
|
|
"<!--",
|
|
"package ${1:xyz.zhouxy}.${2:plusone}.common.domain;",
|
|
"",
|
|
"import java.time.LocalDateTime;",
|
|
"",
|
|
"/**",
|
|
" * Entity 和 Info 的父类",
|
|
" * ",
|
|
" * @author ZhouXY108 <luquanlion@outlook.com>",
|
|
" */",
|
|
"public abstract class BaseDomain implements Serializable {",
|
|
"\tprotected Long id;",
|
|
"",
|
|
"\tprotected Long createdBy;",
|
|
"\tprotected LocalDateTime createdTime;",
|
|
"\tprotected Long updatedBy;",
|
|
"\tprotected LocalDateTime updatedTime;",
|
|
"\tprotected Long version;",
|
|
"",
|
|
"\tprotected BaseDomain() {",
|
|
"\t}",
|
|
"",
|
|
"\tprotected BaseDomain(BaseDomain prototype) {",
|
|
"\t\tthis.id = prototype.id;",
|
|
"\t\tthis.createdBy = prototype.createdBy;",
|
|
"\t\tthis.createdTime = prototype.createdTime;",
|
|
"\t\tthis.updatedBy = prototype.updatedBy;",
|
|
"\t\tthis.updatedTime = prototype.updatedTime;",
|
|
"\t\tthis.version = prototype.version;",
|
|
"\t}",
|
|
"",
|
|
"\t// TODO: getters & setters",
|
|
"",
|
|
"} -->",
|
|
"",
|
|
"",
|
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.info.${5:ModuleShortName}${7:Entity}Info /////////////// -->",
|
|
"<!-- ",
|
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.info;",
|
|
"",
|
|
"import ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseDomain;",
|
|
"",
|
|
"/**",
|
|
" * ${5:ModuleShortName}${7:Entity} 的基本属性",
|
|
" * ",
|
|
" * @author ZhouXY108 <luquanlion@outlook.com>",
|
|
" */",
|
|
"public class ${5:ModuleShortName}${7:Entity}Info extends BaseDomain {",
|
|
"\tprivate String username;",
|
|
"\tprivate String email;",
|
|
"\tprivate String phoneNum;",
|
|
"\tprivate String password;",
|
|
"\tprivate String salt;",
|
|
"",
|
|
"\tprivate ${7:Entity}Status status;",
|
|
"",
|
|
"\tprivate String remarks;",
|
|
"\tprivate String nickname;",
|
|
"\tprivate Sex sex;",
|
|
"\tprivate String avatar;",
|
|
"",
|
|
"\t// TODO: other columns",
|
|
"",
|
|
"\tpublic ${5:ModuleShortName}${7:Entity}Info() {",
|
|
"\t}",
|
|
"",
|
|
"\tpublic ${5:ModuleShortName}${7:Entity}Info(BaseDomain prototype) {",
|
|
"\t\tsuper(prototype);",
|
|
"\t}",
|
|
"",
|
|
"\t// ==============================================================",
|
|
"",
|
|
"\t// TODO: getters & setters",
|
|
"",
|
|
"\t// ==============================================================",
|
|
"",
|
|
"\tpublic PasswordWithSalt getPwd() {",
|
|
"\t\treturn new PasswordWithSalt(password, salt);",
|
|
"\t}",
|
|
"",
|
|
"\tpublic void setPwd(PasswordWithSalt password) {",
|
|
"\t\tthis.password = password.getPassword();",
|
|
"\t\tthis.salt = password.getSalt();",
|
|
"\t}",
|
|
"}",
|
|
" -->",
|
|
"",
|
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseQueryParams /////////////// -->",
|
|
"<!-- ",
|
|
"package ${1:xyz.zhouxy}.${2:plusone}.common.domain;",
|
|
"/**",
|
|
" * 查询参数的基本属性",
|
|
" * ",
|
|
" * @author ZhouXY108 <luquanlion@outlook.com>",
|
|
" */",
|
|
"public abstract class BaseQueryParams {",
|
|
"\tprotected Long id;",
|
|
"\tprotected Long createdBy;",
|
|
"\tprotected LocalDateTime createdTimeStart;",
|
|
"\tprotected LocalDateTime createdTimeEnd;",
|
|
"\tprotected Long updatedBy;",
|
|
"\tprotected LocalDateTime updatedTimeStart;",
|
|
"\tprotected LocalDateTime updatedTimeEnd;",
|
|
"",
|
|
"\tprotected Integer size;",
|
|
"\tprotected Long pageNum;",
|
|
"",
|
|
"\tprotected Long getOffset() {",
|
|
"\t\treturn (pageNum - 1) * size;",
|
|
"\t}",
|
|
"",
|
|
"\t// TODO: getters & setters",
|
|
"}",
|
|
" -->",
|
|
"",
|
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.query.${5:ModuleShortName}${7:Entity}Query /////////////// -->",
|
|
"<!--",
|
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.query;",
|
|
"",
|
|
"import ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseQueryParams;",
|
|
"",
|
|
"/**",
|
|
" * ${5:ModuleShortName}${7:Entity} 的查询参数",
|
|
" * ",
|
|
" * @author ZhouXY108 <luquanlion@outlook.com>",
|
|
" */",
|
|
"public class ${5:ModuleShortName}${7:Entity}Query extends BaseQueryParams {",
|
|
"\tprivate String email;",
|
|
"\tprivate String phoneNum;",
|
|
"\tprivate String username;",
|
|
"\tprivate Sex sex;",
|
|
"\tprivate String nickname;",
|
|
"\tprivate String remarks;",
|
|
"\tprivate ${7:Entity}Status status;",
|
|
"",
|
|
"\t// TODO: other params",
|
|
"}",
|
|
" -->",
|
|
"",
|
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.entity.${5:ModuleShortName}${7:Entity} /////////////// -->",
|
|
"<!-- ",
|
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.business.domain.entity;",
|
|
"",
|
|
"import ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseDomain;",
|
|
"",
|
|
"/**",
|
|
" * ${5:ModuleShortName}${7:Entity} 实体",
|
|
" *",
|
|
" * @author ZhouXY108 <luquanlion@outlook.com>",
|
|
" */",
|
|
"public class ${5:ModuleShortName}${7:Entity} extends BaseDomain {",
|
|
"\tprivate String username;",
|
|
"\tprivate String email;",
|
|
"\tprivate String phoneNum;",
|
|
"\tprivate PasswordWithSalt password;",
|
|
"",
|
|
"\tprivate ${7:Entity}Status status;",
|
|
"",
|
|
"\tprivate String remarks;",
|
|
"\tprivate String nickname;",
|
|
"\tprivate Sex sex;",
|
|
"\tprivate String avatar;",
|
|
"\t// TODO: other columns",
|
|
"",
|
|
"\tprivate final Map<Long, ${9:ModuleShortName2}${10:Entity2}> ${11:entity2}Refs = new HashMap<>();",
|
|
"\t// TODO: other entities",
|
|
"",
|
|
"\tpublic ${5:ModuleShortName}${7:Entity}() {",
|
|
"\t}",
|
|
"",
|
|
"\tpublic ${5:ModuleShortName}${7:Entity}(${5:ModuleShortName}${7:Entity}Info prototype) {",
|
|
"\t\tsuper(prototype);",
|
|
"\t\tthis.username = prototype.getUsername();",
|
|
"\t\tthis.email = prototype.getEmail();",
|
|
"\t\tthis.phoneNum = prototype.getPhoneNum();",
|
|
"\t\tthis.password = prototype.getPwd();",
|
|
"\t\tthis.status = prototype.getStatus();",
|
|
"\t\tthis.remarks = prototype.getremarks();",
|
|
"\t\tthis.nickname = prototype.getNickname();",
|
|
"\t\tthis.sex = prototype.getSex();",
|
|
"\t\tthis.avatar = prototype.getAvatar();",
|
|
"\t}",
|
|
"",
|
|
"\tpublic ${5:ModuleShortName}${7:Entity}Info buildInfo() {",
|
|
"\t\tvar info = new ${5:ModuleShortName}${7:Entity}Info(this);",
|
|
"\t\tinfo.setUsername(this.username);",
|
|
"\t\tinfo.setEmail(this.email);",
|
|
"\t\tinfo.setPhoneNum(this.phoneNum);",
|
|
"\t\tinfo.setPwd(this.password);",
|
|
"\t\tinfo.setStatus(this.status);",
|
|
"\t\tinfo.setremarks(this.remarks);",
|
|
"\t\tinfo.setNickname(this.nickname);",
|
|
"\t\tinfo.setSex(this.sex);",
|
|
"\t\tinfo.setAvatar(this.avatar);",
|
|
"\t\treturn info;",
|
|
"\t}",
|
|
"",
|
|
"\tpublic void bind${10:Entity2}s(Collection<${9:ModuleShortName2}${10:Entity2}> ${11:entity2}s) {",
|
|
"\t\tthis.${11:entity2}Refs.clear();",
|
|
"\t\tfor (var ${11:entity2} : ${11:entity2}s) {",
|
|
"\t\t\tthis.${11:entity2}Refs.put(${11:entity2}.getId(), ${11:entity2});",
|
|
"\t\t}",
|
|
"\t}",
|
|
"",
|
|
"\tpublic static final class Builder extends BaseEntityBuilder<${5:ModuleShortName}${7:Entity}> {",
|
|
"\t\tprivate final String username;",
|
|
"\t\tprivate final String email;",
|
|
"\t\tprivate final String phoneNum;",
|
|
"\t\tprivate final PasswordWithSalt password;",
|
|
"\t\tprivate String remarks;",
|
|
"\t\tprivate String nickname;",
|
|
"\t\tprivate Sex sex;",
|
|
"\t\tprivate String avatar;",
|
|
"\t\tprivate final ${7:Entity}Status status;",
|
|
"\t\t// TODO: other columns",
|
|
"",
|
|
"\t\tprivate Collection<${9:ModuleShortName2}${10:Entity2}> ${11:entity2}s;",
|
|
"\t\t// TODO: other entities",
|
|
"",
|
|
"\t\tpublic Builder(String username, String email, String phoneNum, PasswordWithSalt password, ${7:Entity}Status status,",
|
|
"\t\t\t\tLong createdBy) {",
|
|
"\t\t\tsuper(createdBy);",
|
|
"\t\t\tthis.username = username;",
|
|
"\t\t\tthis.email = email;",
|
|
"\t\t\tthis.phoneNum = phoneNum;",
|
|
"\t\t\tthis.password = password;",
|
|
"\t\t\tthis.status = status;",
|
|
"\t\t}",
|
|
"",
|
|
"\t\tpublic Builder remarks(String remarks) {",
|
|
"\t\t\tthis.remarks = remarks;",
|
|
"\t\t\treturn this;",
|
|
"\t\t}",
|
|
"",
|
|
"\t\tpublic Builder ${6:entity}Info(String nickname, Sex sex, String avatar) {",
|
|
"\t\t\tthis.nickname = nickname;",
|
|
"\t\t\tthis.sex = sex;",
|
|
"\t\t\tthis.avatar = avatar;",
|
|
"\t\t\treturn this;",
|
|
"\t\t}",
|
|
"",
|
|
"\t\tpublic Builder ${11:entity2}s(Collection<${9:ModuleShortName2}${10:Entity2}> ${11:entity2}s) {",
|
|
"\t\t\tthis.${11:entity2}s = ${11:entity2}s;",
|
|
"\t\t\treturn this;",
|
|
"\t\t}",
|
|
"",
|
|
"\t\t@Override",
|
|
"\t\tpublic ${5:ModuleShortName}${7:Entity} build() {",
|
|
"\t\t\t${5:ModuleShortName}${7:Entity} entity = new ${5:ModuleShortName}${7:Entity}();",
|
|
"\t\t\tentity.username = this.username;",
|
|
"\t\t\tentity.email = this.email;",
|
|
"\t\t\tentity.phoneNum = this.phoneNum;",
|
|
"\t\t\tentity.password = this.password;",
|
|
"\t\t\tentity.remarks = this.remarks;",
|
|
"\t\t\tentity.nickname = this.nickname;",
|
|
"\t\t\tentity.sex = this.sex;",
|
|
"\t\t\tentity.avatar = this.avatar;",
|
|
"\t\t\tentity.status = this.status;",
|
|
"\t\t\t// TODO: other columns",
|
|
"\t\t\t// TODO: bind other entities",
|
|
"\t\t\tentity.bind${10:Entity2}s(${11:entity2}s);",
|
|
"\t\t\treturn super.build(entity);",
|
|
"\t\t}",
|
|
"\t}",
|
|
"}",
|
|
" -->",
|
|
"",
|
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.common.domain.BaseEntityBuilder /////////////// -->",
|
|
"<!-- ",
|
|
"package ${1:xyz.zhouxy}.${2:plusone}.common.domain;",
|
|
"",
|
|
"/**",
|
|
" * BaseEntityBuilder",
|
|
" * ",
|
|
" * @author ZhouXY108 <luquanlion@outlook.com>",
|
|
" */",
|
|
"public abstract class BaseEntityBuilder<E extends BaseDomain> {",
|
|
"",
|
|
"\tprotected final Long createdBy;",
|
|
"",
|
|
"\tprotected BaseEntityBuilder(Long createdBy) {",
|
|
"\t\tthis.createdBy = createdBy;",
|
|
"\t}",
|
|
"",
|
|
"\tprotected E build(E entity) {",
|
|
"\t\tentity.createdBy = this.createdBy;",
|
|
"\t\tentity.updatedBy = this.createdBy;",
|
|
"\t\tvar now = LocalDateTime.now();",
|
|
"\t\tentity.createdTime = now;",
|
|
"\t\tentity.updatedTime = now;",
|
|
"\t\tentity.version = 0L;",
|
|
"\t\treturn entity;",
|
|
"\t}",
|
|
"",
|
|
"\tprotected abstract E build();",
|
|
"}",
|
|
" -->",
|
|
"",
|
|
"<!-- /////////////// ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.dal.mapper.${5:ModuleShortName}${7:Entity}Mapper /////////////// -->",
|
|
"<!--",
|
|
"package ${1:xyz.zhouxy}.${2:plusone}.${3:module}.${6:entity}.dal.mapper;",
|
|
"",
|
|
"public interface ${5:ModuleShortName}${7:Entity}Mapper {",
|
|
"\tint insert(${5:ModuleShortName}${7:Entity}Info po);",
|
|
"",
|
|
"\tdefault int insertAll(Collection<${5:ModuleShortName}${7:Entity}Info> pos) {",
|
|
"\t\tint i = 0;",
|
|
"\t\tfor (var po : pos) {",
|
|
"\t\t\ti += insert(po);",
|
|
"\t\t}",
|
|
"\t\treturn i;",
|
|
"\t}",
|
|
"",
|
|
"\tint delete(${5:ModuleShortName}${7:Entity}Info po);",
|
|
"",
|
|
"\tdefault int deleteAll(Collection<${5:ModuleShortName}${7:Entity}Info> pos) {",
|
|
"\t\tint i = 0;",
|
|
"\t\tfor (var po : pos) {",
|
|
"\t\t\ti += delete(po);",
|
|
"\t\t}",
|
|
"\t\treturn i;",
|
|
"\t}",
|
|
"",
|
|
"\tint update(${5:ModuleShortName}${7:Entity}Info po);",
|
|
"",
|
|
"\t${5:ModuleShortName}${7:Entity}Info findById(Long id);",
|
|
"",
|
|
"\tCollection<${5:ModuleShortName}${7:Entity}Info> findByIdIn(Collection<Long> ids);",
|
|
"",
|
|
"\tCollection<${5:ModuleShortName}${7:Entity}Info> query(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
|
"",
|
|
"\tlong count(${5:ModuleShortName}${7:Entity}Query queryParams);",
|
|
"",
|
|
"\tCollection<${5:ModuleShortName}${7:Entity}Info> findBy${10:Entity2}Id(Long ${11:entity2}Id);",
|
|
"",
|
|
"\tint clear${10:Entity2}s(Long id);",
|
|
"",
|
|
"\tint bind${10:Entity2}s(Long id, Collection<Long> ${11:entity2}s);",
|
|
"",
|
|
"}",
|
|
"-->",
|
|
"",
|
|
],
|
|
"description": "Mybatis mapper 模板"
|
|
}
|
|
} |