# 模板文件

根据框架设计和高可用性要求,我们自研了一套精细化的模板,基于FreeMarker编写,遵循FreeMarker书写规范,如需根据自己需要二次开发的小伙伴可以直接修改,根据层级结构的划分,框架所用到的模板文件包括:常量(Constant)模板控制器(Controller)模板Dao模板编辑页(Edit)模板实体对象(Entity)模板ListVo模板数据列表(Index)模板接口(IService)模板模块JS模板Mapper模板查询条件(Query)模板接口实现(ServiceImpl)模板,下面逐个完整的诠释每个模板文件的内容:

# 常量(Constant)模板

package ${packageName}.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * ${tableAnnotation} 模块常量
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
public class ${entityName}Constant {

<#if model_column?exists>
<#list model_column as model>
    <#if model.hasColumnCommentValue = true>
    /**
     * ${model.columnCommentName}
     */
    <#if model.columnNumberValue = true>
    public static Map<Integer, String> ${entityName?upper_case}_${model.changeColumnName?upper_case}_LIST = new HashMap<Integer, String>() {
        {
    <#if model.columnCommentValue?exists>
        <#list model.columnCommentValue?keys as key>
            put(${key}, "${model.columnCommentValue[key]}");
        </#list>
    </#if>
        }
    };
    <#else>
    public static Map<String, String> ${entityName?upper_case}_${model.changeColumnName?upper_case}_LIST = new HashMap<String, String>() {
    {
    <#if model.columnCommentValue?exists>
        <#list model.columnCommentValue?keys as key>
            put("${key}", "${model.columnCommentValue[key]}");
        </#list>
    </#if>
    }
    };
    </#if>
    </#if>
</#list>
</#if>
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

# 控制器(Controller)模板

package ${packageName}.controller;


import com.javaweb.common.utils.JsonResult;
import com.javaweb.common.annotation.Log;
import com.javaweb.common.enums.BusinessType;
import ${packageName}.entity.${entityName};
import ${packageName}.query.${entityName}Query;
import ${packageName}.service.I${entityName}Service;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.javaweb.common.common.BaseController;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * ${tableAnnotation} 控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Controller
@RequestMapping("/${entityName?lower_case}")
public class ${entityName}Controller extends BaseController {

    @Autowired
    private I${entityName}Service ${entityName?uncap_first}Service;

    /**
     * 获取数据列表
     *
     * @param query 查询条件
     * @return
     */
//    @RequiresPermissions("sys:${entityName?lower_case}:list")
    @ResponseBody
    @PostMapping("/list")
    public JsonResult list(${entityName}Query query) {
        return ${entityName?uncap_first}Service.getList(query);
    }

    /**
     * 添加记录
     *
     * @param entity 实体对象
     * @return
     */
//    @RequiresPermissions("sys:${entityName?lower_case}:add")
    @Log(title = "${tableAnnotation}", businessType = BusinessType.INSERT)
    @ResponseBody
    @PostMapping("/add")
    public JsonResult add(@RequestBody ${entityName} entity) {
        return ${entityName?uncap_first}Service.edit(entity);
    }

    /**
     * 修改记录
     *
     * @param entity 实体对象
     * @return
     */
//    @RequiresPermissions("sys:${entityName?lower_case}:update")
    @Log(title = "${tableAnnotation}", businessType = BusinessType.UPDATE)
    @ResponseBody
    @PostMapping("/update")
    public JsonResult update(@RequestBody ${entityName} entity) {
        return ${entityName?uncap_first}Service.edit(entity);
    }

    /**
     * 获取记录详情
     *
     * @param id    记录ID
     * @param model 模型
     * @return
     */
    @Override
    public String edit(Integer id, Model model) {
        Map<String, Object> info = new HashMap<>();
        if (id != null && id > 0) {
            info = ${entityName?uncap_first}Service.info(id);
        }
        model.addAttribute("info", info);
        return super.edit(id, model);
    }

    /**
     * 删除记录
     *
     * @param id 记录ID
     * @return
     */
//    @RequiresPermissions("sys:${entityName?lower_case}:delete")
    @Log(title = "${tableAnnotation}", businessType = BusinessType.DELETE)
    @Override
    public JsonResult delete(Integer id) {
        return ${entityName?uncap_first}Service.deleteById(id);
    }

<#if model_column?exists>
    <#list model_column as model>
    <#if model.changeColumnName?uncap_first = 'status'>
    /**
     * 设置状态
     *
     * @param entity 实体对象
     * @return
     */
//    @RequiresPermissions("sys:${entityName?lower_case}:status")
    @Log(title = "${tableAnnotation}", businessType = BusinessType.STATUS)
    @ResponseBody
    @PostMapping("/setStatus")
    public JsonResult setStatus(@RequestBody ${entityName} entity) {
        return ${entityName?uncap_first}Service.setStatus(entity);
    }
    </#if>
    </#list>
</#if>
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

# Dao模板

package ${packageName}.mapper;

import ${packageName}.entity.${entityName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * <p>
 * ${tableAnnotation} Mapper 接口
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
public interface ${entityName}Mapper extends BaseMapper<${entityName}> {

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# 编辑页(Edit)模板

<html layout:decorator="public/form" xmlns:miguo="http://www.w3.org/1999/html">
<div layout:fragment="content">
	<form class="layui-form model-form" action="" <#if is_split==true>style="width:80%;"</#if>>
		<input name="id" type="hidden" th:value="${tplTag}{info['id']}?:0">
		<#if hasPid = true>
		<input name="pid" id="pid" type="hidden" th:value="${tplTag}{info['pid']}?:0">
		</#if>
<#if model_column?exists>
	<#list model_column as model>
	<#if is_split==false>
	<#if model.changeColumnName?uncap_first != "createUser" && model.changeColumnName?uncap_first != "createTime" && model.changeColumnName?uncap_first != "updateUser" && model.changeColumnName?uncap_first != "updateTime" && model.changeColumnName?uncap_first != "mark">
		<#if (model.columnType = 'VARCHAR' || model.columnType = 'CHAR' || model.columnType = 'TEXT' || model.columnType = 'MEDIUMTEXT')>
		<#if model.columnImage == true>
		<div class="layui-form-item">
			<label class="layui-form-label">${model.columnComment}:</label>
			<widget:uploadSingleImage name="${model.changeColumnName?uncap_first}|${model.columnComment}|90x90|${entityName?lower_case}|建议上传尺寸450x450" th:value="${tplTag}{info['${model.changeColumnName?uncap_first}']}"/>
		</div>
		<#elseif model.columnTextArea == true>
		<div class="layui-form-item">
			<label class="layui-form-label">${model.columnComment}:</label>
			<div class="layui-input-block">
				<textarea name="${model.changeColumnName?uncap_first}" placeholder="请输入${model.columnComment}" class="layui-textarea" th:text="${tplTag}{info['${model.changeColumnName?uncap_first}']}"></textarea>
				<#if model.columnType = 'TEXT'>
				<widget:kindEditor name="${model.changeColumnName?uncap_first}" type="default" dirname="${entityName?lower_case}" width="100%" height="350"/>
				</#if>
			</div>
		</div>
		<#elseif model.changeColumnName?uncap_first = "mobile">
		<div class="layui-form-item">
			<label class="layui-form-label">手机号码:</label>
			<div class="layui-input-block">
				<input name="mobile" th:value="${tplTag}{info['mobile']}" lay-verify="required|phone" placeholder="请输入手机号码" autocomplete="off" class="layui-input" type="tel">
			</div>
		</div>
		<#elseif model.changeColumnName?uncap_first = "email">
		<div class="layui-form-item">
			<label class="layui-form-label">电子邮箱:</label>
			<div class="layui-input-block">
				<input name="email" th:value="${tplTag}{info['email']}" lay-verify="required|email" placeholder="请输入邮箱" autocomplete="off" class="layui-input" type="text">
			</div>
		</div>
		<#elseif model.changeColumnName?uncap_first = "identity">
		<div class="layui-form-item">
			<label class="layui-form-label">身份证号:</label>
			<div class="layui-input-block">
				<input name="identity" th:value="${tplTag}{info['identity']}" lay-verify="identity" placeholder="请输入身份证号" autocomplete="off" class="layui-input" type="text">
			</div>
		</div>
		<#elseif model.hasColumnCommentValue = true>
		<div class="layui-inline">
			<label class="layui-form-label">${model.columnCommentName}:</label>
			<div class="layui-input-inline">
				<widget:singleSelect name="${model.changeColumnName?uncap_first}|1|${model.columnCommentName}|name|id" data="${model.columnValue}" th:value="${tplTag}{info['${model.changeColumnName?uncap_first}']}?:${model.columnDefaultValue}"/>
			</div>
		</div>
		<#else>
		<div class="layui-form-item">
			<label class="layui-form-label">${model.columnComment}:</label>
			<div class="layui-input-block">
				<input name="${model.changeColumnName?uncap_first}" th:value="${tplTag}{info['${model.changeColumnName?uncap_first}']}" lay-verify="required" autocomplete="off" placeholder="请输入${model.columnComment}" class="layui-input" type="text">
			</div>
		</div>
		</#if>
		</#if>
		<#if (model.columnType = 'DATETIME' || model.columnType = 'DATE' || model.columnType = 'TIME' || model.columnType = 'YEAR' || model.columnType = 'TIMESTAMP') >
		<div class="layui-form-item">
			<label class="layui-form-label">${model.columnComment}:</label>
			<div class="layui-input-block">
				<widget:dateSelect name="${model.changeColumnName?uncap_first}|${model.columnType?lower_case}|请选择${model.columnComment}" th:value="${tplTag}{info['${model.changeColumnName?uncap_first}']}"/>
			</div>
		</div>
		</#if>
		<#if (model.columnType = 'TINYINT UNSIGNED' || model.columnType = 'TINYINT')>
		<#if model.columnSwitch == true>
		<div class="layui-form-item">
			<label class="layui-form-label">${model.columnCommentName}:</label>
			<div class="layui-input-block">
				<widget:switchCheck name="${model.changeColumnName?uncap_first}" data="${model.columnSwitchValue}" th:value="${tplTag}{info['${model.changeColumnName?uncap_first}']} ?: ${model.columnDefaultValue}"/>
			</div>
		</div>
		<#else>
		<div class="layui-form-item">
			<label class="layui-form-label">${model.columnCommentName}:</label>
			<div class="layui-input-block">
				<widget:singleSelect name="${model.changeColumnName?uncap_first}|1|${model.columnCommentName}|name|id" data="${model.columnValue}" th:value="${tplTag}{info['${model.changeColumnName?uncap_first}']}?:${model.columnDefaultValue}"/>
			</div>
		</div>
		</#if>
		</#if>
		<#if (model.columnType = 'INT UNSIGNED' || model.columnType = 'INT' || model.columnType = 'SMALLINT UNSIGNED' || model.columnType = 'SMALLINT' || model.columnType = 'BIGINT UNSIGNED' || model.columnType = 'BIGINT' || model.columnType = 'MEDIUMINT UNSIGNED' || model.columnType = 'MEDIUMINT')>
		<div class="layui-form-item">
			<label class="layui-form-label">${model.columnComment}:</label>
			<div class="layui-input-block">
				<input name="${model.changeColumnName?uncap_first}" th:value="${tplTag}{info['${model.changeColumnName?uncap_first}']}" lay-verify="required|number" autocomplete="off" placeholder="请输入${model.columnComment}" class="layui-input" type="text">
			</div>
		</div>
		</#if>
	</#if>
	<#else>
		<div class="layui-form-item">
		<#if model[0]?exists>
		<#if (model[0].columnType = 'VARCHAR' || model[0].columnType = 'CHAR' || model[0].columnType = 'TEXT' || model[0].columnType = 'MEDIUMTEXT')>
			<#if model[0].columnImage == true>
			<div class="layui-inline">
				<label class="layui-form-label">${model[0].columnComment}:</label>
				<widget:uploadSingleImage name="${model[0].changeColumnName?uncap_first}|${model[0].columnComment}|90x90|${entityName?lower_case}|建议上传尺寸450x450" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}"/>
			</div>
			<#elseif model[0].columnTextArea == true>
			<label class="layui-form-label">${model[0].columnComment}:</label>
			<div class="layui-input-block">
				<textarea name="${model[0].changeColumnName?uncap_first}" placeholder="请输入${model[0].columnComment}" class="layui-textarea" th:text="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}"></textarea>
			<#if model[0].columnType = 'TEXT'>
				<widget:kindEditor name="${model[0].changeColumnName?uncap_first}" type="default" dirname="${entityName?lower_case}" width="100%" height="350"/>
			</#if>
			</div>
			<#elseif model[0].changeColumnName?uncap_first = "mobile">
			<div class="layui-inline">
				<label class="layui-form-label">手机号码:</label>
				<div class="layui-input-inline">
					<input name="mobile" th:value="${tplTag}{info['mobile']}" lay-verify="required|phone" placeholder="请输入手机号码" autocomplete="off" class="layui-input" type="tel">
				</div>
			</div>
			<#elseif model[0].changeColumnName?uncap_first = "email">
			<div class="layui-inline">
				<label class="layui-form-label">电子邮箱:</label>
				<div class="layui-input-inline">
					<input name="email" th:value="${tplTag}{info['email']}" lay-verify="required|email" placeholder="请输入邮箱" autocomplete="off" class="layui-input" type="text">
				</div>
			</div>
			<#elseif model[0].changeColumnName?uncap_first = "identity">
			<div class="layui-inline">
				<label class="layui-form-label">身份证号:</label>
				<div class="layui-input-inline">
					<input name="identity" th:value="${tplTag}{info['identity']}" lay-verify="identity" placeholder="请输入身份证号" autocomplete="off" class="layui-input" type="text">
				</div>
			</div>
			<#elseif model[0].hasColumnCommentValue = true>
				<#if model[1].columnType = 'VARCHAR'>
				<div class="layui-inline">
					<label class="layui-form-label">${model[0].columnCommentName}:</label>
					<div class="layui-input-inline">
						<widget:checkboxSingleSelect name="${model[0].changeColumnName?uncap_first}|name|id" data="${model[0].columnValue}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}"/>
					</div>
				</div>
				<#else>
				<div class="layui-inline">
					<label class="layui-form-label">${model[0].columnCommentName}:</label>
					<div class="layui-input-inline">
						<widget:singleSelect name="${model[0].changeColumnName?uncap_first}|1|${model[0].columnCommentName}|name|id" data="${model[0].columnValue}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}?:${model[0].columnDefaultValue}"/>
					</div>
				</div>
				</#if>
			<#else>
			<div class="layui-inline">
				<label class="layui-form-label">${model[0].columnComment}:</label>
				<div class="layui-input-inline">
					<input name="${model[0].changeColumnName?uncap_first}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}" lay-verify="required" autocomplete="off" placeholder="请输入${model[0].columnComment}" class="layui-input" type="text">
				</div>
			</div>
			</#if>
		</#if>
		<#if (model[0].columnType = 'DATETIME' || model[0].columnType = 'DATE' || model[0].columnType = 'TIME' || model[0].columnType = 'YEAR' || model[0].columnType = 'TIMESTAMP') >
			<div class="layui-inline">
				<label class="layui-form-label">${model[0].columnComment}:</label>
				<div class="layui-input-inline">
					<widget:dateSelect name="${model[0].changeColumnName?uncap_first}|${model[0].columnType?lower_case}|请选择${model[0].columnComment}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}"/>
				</div>
			</div>
		</#if>
		<#if (model[0].columnType = 'TINYINT UNSIGNED' || model[0].columnType = 'TINYINT')>
		<#if model[0].columnSwitch == true>
			<div class="layui-inline">
				<label class="layui-form-label">${model[0].columnCommentName}:</label>
				<div class="layui-input-inline">
					<widget:switchCheck name="${model[0].changeColumnName?uncap_first}" data="${model[0].columnSwitchValue}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']} ?: ${model[0].columnDefaultValue}"/>
				</div>
			</div>
		<#else>
			<div class="layui-inline">
				<label class="layui-form-label">${model[0].columnCommentName}:</label>
				<div class="layui-input-inline">
					<widget:singleSelect name="${model[0].changeColumnName?uncap_first}|1|${model[0].columnCommentName}|name|id" data="${model[0].columnValue}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}?:${model[0].columnDefaultValue}"/>
				</div>
			</div>
		</#if>
		</#if>
		<#if (model[0].columnType = 'INT UNSIGNED' || model[0].columnType = 'INT' || model[0].columnType = 'SMALLINT UNSIGNED' || model[0].columnType = 'SMALLINT' || model[0].columnType = 'BIGINT UNSIGNED' || model[0].columnType = 'BIGINT' || model[0].columnType = 'MEDIUMINT UNSIGNED' || model[0].columnType = 'MEDIUMINT')>
			<div class="layui-inline">
				<label class="layui-form-label">${model[0].columnComment}:</label>
				<div class="layui-input-inline">
					<input name="${model[0].changeColumnName?uncap_first}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}" lay-verify="required|number" autocomplete="off" placeholder="请输入${model[0].columnComment}" class="layui-input" type="text">
				</div>
			</div>
		</#if>
		<#if (model[0].columnType = 'DECIMAL UNSIGNED' || model[0].columnType = 'DECIMAL')>
			<div class="layui-inline">
				<label class="layui-form-label">${model[0].columnComment}:</label>
				<div class="layui-input-inline">
					<input name="${model[0].changeColumnName?uncap_first}" th:value="${tplTag}{info['${model[0].changeColumnName?uncap_first}']}" lay-verify="required" autocomplete="off" placeholder="请输入${model[0].columnComment}" class="layui-input" type="text">
				</div>
			</div>
		</#if>
		</#if>
		<#if model[1]?exists>
		<#if (model[1].columnType = 'VARCHAR' || model[1].columnType = 'CHAR' || model[1].columnType = 'TEXT' || model[1].columnType = 'MEDIUMTEXT')>
		<#if model[1].columnImage == true>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnComment}:</label>
				<widget:uploadSingleImage name="${model[1].changeColumnName?uncap_first}|${model[1].columnComment}|90x90|temp|建议上传尺寸450x450" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}"/>
			</div>
		<#elseif model[1].changeColumnName?uncap_first = "mobile">
			<div class="layui-inline">
				<label class="layui-form-label">手机号码:</label>
				<div class="layui-input-inline">
					<input name="mobile" th:value="${tplTag}{info['mobile']}" lay-verify="required|phone" placeholder="请输入手机号码" autocomplete="off" class="layui-input" type="tel">
				</div>
			</div>
		<#elseif model[1].changeColumnName?uncap_first = "email">
			<div class="layui-inline">
				<label class="layui-form-label">电子邮箱:</label>
				<div class="layui-input-inline">
					<input name="email" th:value="${tplTag}{info['email']}" lay-verify="required|email" placeholder="请输入邮箱" autocomplete="off" class="layui-input" type="text">
				</div>
			</div>
		<#elseif model[1].changeColumnName?uncap_first = "identity">
			<div class="layui-inline">
				<label class="layui-form-label">身份证号:</label>
				<div class="layui-input-inline">
					<input name="identity" th:value="${tplTag}{info['identity']}" lay-verify="identity" placeholder="请输入身份证号" autocomplete="off" class="layui-input" type="text">
				</div>
			</div>
		<#elseif model[1].hasColumnCommentValue = true>
			<#if model[1].columnType = 'VARCHAR'>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnCommentName}:</label>
				<div class="layui-input-inline">
					<widget:checkboxSingleSelect name="${model[1].changeColumnName?uncap_first}|name|id" data="${model[1].columnValue}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}"/>
				</div>
			</div>
			<#else>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnCommentName}:</label>
				<div class="layui-input-inline">
					<widget:singleSelect name="${model[1].changeColumnName?uncap_first}|1|${model[1].columnCommentName}|name|id" data="${model[1].columnValue}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}?:${model[1].columnDefaultValue}"/>
				</div>
			</div>
			</#if>
		<#else>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnComment}:</label>
				<div class="layui-input-inline">
					<input name="${model[1].changeColumnName?uncap_first}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}" lay-verify="required" autocomplete="off" placeholder="请输入${model[1].columnComment}" class="layui-input" type="text">
				</div>
			</div>
		</#if>
		</#if>
		<#if (model[1].columnType = 'DATETIME' || model[1].columnType = 'DATE' || model[1].columnType = 'TIME' || model[1].columnType = 'YEAR' || model[1].columnType = 'TIMESTAMP') >
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnComment}:</label>
				<div class="layui-input-inline">
					<widget:dateSelect name="${model[1].changeColumnName?uncap_first}|${model[1].columnType?lower_case}|请选择${model[1].columnComment}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}"/>
				</div>
			</div>
		</#if>
		<#if (model[1].columnType = 'TINYINT UNSIGNED' || model[1].columnType = 'TINYINT')>
		<#if model[1].columnSwitch == true>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnCommentName}:</label>
				<div class="layui-input-inline">
					<widget:switchCheck name="${model[1].changeColumnName?uncap_first}" data="${model[1].columnSwitchValue}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']} ?: ${model[1].columnDefaultValue}"/>
				</div>
			</div>
		<#else>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnCommentName}:</label>
				<div class="layui-input-inline">
					<widget:singleSelect name="${model[1].changeColumnName?uncap_first}|1|${model[1].columnCommentName}|name|id" data="${model[1].columnValue}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}?:${model[1].columnDefaultValue}"/>
				</div>
			</div>
		</#if>
		</#if>
		<#if (model[1].columnType = 'INT UNSIGNED' || model[1].columnType = 'INT' || model[1].columnType = 'SMALLINT UNSIGNED' || model[1].columnType = 'SMALLINT' || model[1].columnType = 'BIGINT UNSIGNED' || model[1].columnType = 'BIGINT' || model[1].columnType = 'MEDIUMINT UNSIGNED' || model[1].columnType = 'MEDIUMINT')>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnComment}:</label>
				<div class="layui-input-inline">
					<input name="${model[1].changeColumnName?uncap_first}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}" lay-verify="required|number" autocomplete="off" placeholder="请输入${model[1].columnComment}" class="layui-input" type="text">
				</div>
			</div>
		</#if>
		<#if (model[1].columnType = 'DECIMAL UNSIGNED' || model[1].columnType = 'DECIMAL')>
			<div class="layui-inline">
				<label class="layui-form-label">${model[1].columnComment}:</label>
				<div class="layui-input-inline">
					<input name="${model[1].changeColumnName?uncap_first}" th:value="${tplTag}{info['${model[1].changeColumnName?uncap_first}']}" lay-verify="required" autocomplete="off" placeholder="请输入${model[1].columnComment}" class="layui-input" type="text">
				</div>
			</div>
		</#if>
		</#if>
		</div>
	</#if>
	</#list>
</#if>
		<widget:btnSubmit name="submit|立即保存,close|关闭"/>
	</form>
</div>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306

# 实体对象(Entity)模板

package ${packageName}.entity;

import com.baomidou.mybatisplus.annotation.TableName;

import java.math.BigDecimal;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.javaweb.common.common.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;


/**
 * <p>
 * ${tableAnnotation}
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("${tableName}")
public class ${entityName} extends BaseEntity {

<#if model_column?exists>
    <#list model_column as model>
    <#if model.changeColumnName?uncap_first != 'createUser' && model.changeColumnName?uncap_first != 'createTime' && model.changeColumnName?uncap_first != 'updateUser' && model.changeColumnName?uncap_first != 'updateTime' && model.changeColumnName?uncap_first != 'mark'>
    /**
     * ${model.columnComment}
     */
    <#if (model.columnType = 'VARCHAR' || model.columnType = 'CHAR' || model.columnType = 'TEXT' || model.columnType = 'MEDIUMTEXT')>
    private String ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'DATETIME' || model.columnType = 'DATE' || model.columnType = 'TIME' || model.columnType = 'YEAR' || model.columnType = 'TIMESTAMP') >
    <#if model.columnType = 'DATE'>
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
    <#else>
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    </#if>
    private Date ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'TINYINT UNSIGNED' || model.columnType = 'TINYINT')>
    private Integer ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'SMALLINT UNSIGNED' || model.columnType = 'SMALLINT' || model.columnType = 'MEDIUMINT UNSIGNED' || model.columnType = 'MEDIUMINT')>
    private Integer ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'INT UNSIGNED' || model.columnType = 'INT')>
    private Integer ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'BIGINT UNSIGNED' || model.columnType = 'BIGINT')>
    private Integer ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'DECIMAL UNSIGNED' || model.columnType = 'DECIMAL')>
    private BigDecimal ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'FLOAT UNSIGNED' || model.columnType = 'FLOAT')>
    private Float ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'DOUBLE UNSIGNED' || model.columnType = 'DOUBLE')>
    private Double ${model.changeColumnName?uncap_first};

    </#if>
    <#if model.columnType = 'BLOB'>
    private byte[] ${model.changeColumnName?uncap_first};

    </#if>
    </#if>
    </#list>
</#if>
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

# ListVo模板

package ${packageName}.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * ${tableAnnotation}列表Vo
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Data
public class ${entityName}ListVo {

    /**
     * ${tableAnnotation}ID
     */
    private Integer id;

<#if model_column?exists>
    <#list model_column as model>
    <#if model.changeColumnName?uncap_first != 'mark'>
    /**
     * ${model.columnComment}
     */
    <#if (model.columnType = 'VARCHAR' || model.columnType = 'CHAR' || model.columnType = 'TEXT' || model.columnType = 'MEDIUMTEXT')>
    private String ${model.changeColumnName?uncap_first};
    <#if model.hasColumnCommentValue = true>

    /**
    * ${model.columnCommentName}描述
    */
    private String ${model.changeColumnName?uncap_first}Name;
    </#if>

    <#if model.columnImage == true>
    /**
     * ${model.columnComment}
     */
    private String ${model.changeColumnName?uncap_first}Url;

    </#if>
    </#if>
    <#if (model.columnType = 'DATETIME' || model.columnType = 'DATE' || model.columnType = 'TIME' || model.columnType = 'YEAR' || model.columnType = 'TIMESTAMP') >
    <#if model.columnType = 'DATE'>
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
    <#else>
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    </#if>
    private Date ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'TINYINT UNSIGNED' || model.columnType = 'TINYINT')>
    private Integer ${model.changeColumnName?uncap_first};
    <#if model.hasColumnCommentValue = true>

    /**
     * ${model.columnCommentName}描述
     */
    private String ${model.changeColumnName?uncap_first}Name;
    </#if>

    </#if>
    <#if (model.columnType = 'SMALLINT UNSIGNED' || model.columnType = 'SMALLINT' || model.columnType = 'MEDIUMINT UNSIGNED' || model.columnType = 'MEDIUMINT')>
    private Integer ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'INT UNSIGNED' || model.columnType = 'INT')>
    private Integer ${model.changeColumnName?uncap_first};

    <#if (model.changeColumnName = 'CreateUser' || model.changeColumnName = 'UpdateUser')>
    /**
     * ${model.columnComment}名称
     */
    private String ${model.changeColumnName?uncap_first}Name;

    </#if>
    </#if>
    <#if (model.columnType = 'BIGINT UNSIGNED' || model.columnType = 'BIGINT')>
    private Integer ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'DECIMAL UNSIGNED' || model.columnType = 'DECIMAL')>
    private BigDecimal ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'FLOAT UNSIGNED' || model.columnType = 'FLOAT')>
    private Float ${model.changeColumnName?uncap_first};

    </#if>
    <#if (model.columnType = 'DOUBLE UNSIGNED' || model.columnType = 'DOUBLE')>
    private Double ${model.changeColumnName?uncap_first};

    </#if>
    <#if model.columnType = 'BLOB'>
    private byte[] ${model.changeColumnName?uncap_first};

    </#if>
    </#if>
    </#list>
</#if>
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

# 数据列表(Index)模板

<html layout:decorator="public/layout" xmlns:miguo="http://www.w3.org/1999/html">
<div layout:fragment="content">

    <!-- 表格工具栏 -->
    <form class="layui-form toolbar">
        <div class="layui-form-item">
<#if model_column?exists>
    <#list model_column as model>
        <#if model.columnName = 'name'>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="name" placeholder="请输入${model.columnComment}" autocomplete="off" class="layui-input">
                </div>
            </div>
        </#if>
        <#if model.columnName = 'title'>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="title" placeholder="请输入${model.columnComment}" autocomplete="off" class="layui-input">
                </div>
            </div>
        </#if>
        <#if model.columnName = 'mobile'>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="mobile" placeholder="请输入手机号码" autocomplete="off" class="layui-input">
                </div>
            </div>
        </#if>
        <#if model.hasColumnCommentValue = true>
            <!-- ${model.columnCommentName}下拉单选 -->
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <widget:singleSelect name="${model.changeColumnName?uncap_first}|0|${model.columnCommentName}|name|id" data="${model.columnValue}" value="0"/>
                </div>
            </div>
        </#if>
    </#list>
</#if>
            <div class="layui-inline">
                <div class="layui-input-inline" style="width: auto;">
                    <widget:btnQuery name="查询"/>
                    <widget:btnAdd name="添加${tableAnnotation}"/>
                    <widget:btnDAll name="批量删除"/>
                </div>
            </div>
        </div>
    </form>

    <!-- 数据表格 -->
    <table class="layui-hide" id="tableList" lay-filter="tableList"></table>

    <!-- 表格操作列 -->
    <script type="text/html" id="toolBar">
        <widget:btnEdit name="编辑"/>
        <widget:btnDel name="删除"/>
        <#if hasPid = true>
        {{#  if(d.pid == 0){ }}
        <widget:btnAddZ name="添加"/>
        {{#  } }}
        </#if>
    </script>

<#if model_column?exists>
    <#list model_column as model>
    <#if (model.changeColumnName?uncap_first = 'status' && model.columnSwitch == true)>
    <!-- 状态 -->
    <script type="text/html" id="statusTpl">
        <input type="checkbox" name="status" value="{{ d.id }}" lay-skin="switch" lay-text="${model.columnSwitchValue}" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }} >
    </script>
    </#if>
    </#list>
</#if>
</div>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

# 接口(IService)模板

package ${packageName}.service;

import ${packageName}.entity.${entityName};
import com.javaweb.common.common.IBaseService;

/**
 * <p>
 * ${tableAnnotation} 服务类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
public interface I${entityName}Service extends IBaseService<${entityName}> {

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# 模块JS模板

/**
 * ${tableAnnotation}
 * @auth ${author}
 * @date ${date}
 */
layui.use(['func'], function () {

    //声明变量
    var func = layui.func
        , $ = layui.$;

    if (A == 'index') {
        //【TABLE列数组】
        var cols = [
            <#if hasPid = true>
              {field: 'id', width: 80, title: 'ID', align: 'center', sort: true}
            <#else>
              {type: 'checkbox', fixed: 'left'}
            , {field: 'id', width: 80, title: 'ID', align: 'center', sort: true, fixed: 'left'}
            </#if>
<#if model_column?exists>
    <#list model_column as model>
    <#if model.columnName != 'mark'>
        <#if (model.columnType = 'DATETIME' || model.columnType = 'DATE' || model.columnType = 'TIME' || model.columnType = 'YEAR' || model.columnType = 'TIMESTAMP')>
            , {field: '${model.changeColumnName?uncap_first}', width: 180, title: '${model.columnComment}', align: 'center'}
        <#elseif model.hasColumnCommentValue = true>
            <#if (model.changeColumnName?uncap_first = 'status' && model.columnSwitch == true)>
            , {field: 'status', width: 100, title: '状态', align: 'center', templet: '#statusTpl'}
            <#else>
            , {field: '${model.changeColumnName?uncap_first}', width: 100, title: '${model.columnCommentName}', align: 'center', templet(d) {
            <#assign column = "d.${model.changeColumnName?uncap_first}">
                var cls = "";
                <#if model.columnCommentValue?exists>
                <#list model.columnCommentValue?keys as key>
                <#if key = "1">
                if (${column} == 1) {
                    // ${model.columnCommentValue[key]}
                    cls = "layui-btn-normal";
                } <#elseif key = "2">else if (${column} == 2) {
                    // ${model.columnCommentValue[key]}
                    cls = "layui-btn-danger";
                } <#elseif key = "3">else if (${column} == 3) {
                    // ${model.columnCommentValue[key]}
                    cls = "layui-btn-warm";
                } <#elseif key = "4">else if (${column} == 4) {
                    // ${model.columnCommentValue[key]}
                    cls = "layui-btn-primary";
                } <#elseif key = "5">else if (${column} == 5) {
                    // ${model.columnCommentValue[key]}
                    cls = "layui-btn-disabled";
                }
                </#if>
                </#list>

				return '<span class="layui-btn ' + cls + ' layui-btn-xs">'+d.${model.changeColumnName?uncap_first}Name+'</span>';
                </#if>
            }}
            </#if>
        <#elseif model.columnImage == true>
            , {field: '${model.changeColumnName?uncap_first}', width: 100, title: '${model.columnComment}', align: 'center', templet: function (d) {
                var ${model.changeColumnName?uncap_first}Str = "";
                if (d.${model.changeColumnName?uncap_first}Url) {
                    ${model.changeColumnName?uncap_first}Str = '<a href="' + d.${model.changeColumnName?uncap_first}Url + '" target="_blank"><img src="' + d.${model.changeColumnName?uncap_first}Url + '" height="26" /></a>';
                }
                return ${model.changeColumnName?uncap_first}Str;
              }
            }
        <#elseif (model.changeColumnName?uncap_first = "createUser" || model.changeColumnName?uncap_first = "updateUser")>
            , {field: '${model.changeColumnName?uncap_first}Name', width: 100, title: '${model.columnComment}', align: 'center'}
        <#else>
            , {field: '${model.changeColumnName?uncap_first}', width: 100, title: '${model.columnComment}', align: 'center'}
        </#if>
    </#if>
    </#list>
</#if>
            <#if hasPid = true>
            , {width: 200, title: '功能操作', align: 'left', toolbar: '#toolBar'}
            <#else>
            , {fixed: 'right', width: 150, title: '功能操作', align: 'center', toolbar: '#toolBar'}
            </#if>
        ];

        //【渲染TABLE】
    <#if hasPid = true>
        func.treetable(cols, "tableList");
    <#else>
        func.tableIns(cols, "tableList");
    </#if>

        //【设置弹框】
    <#if (model_column?size > 11)>
        func.setWin("${tableAnnotation}");
    <#else>
        func.setWin("${tableAnnotation}", 500, 300);
    </#if>

<#if model_column?exists>
   <#list model_column as model>
        <#if model.changeColumnName?uncap_first = 'status'>
        //【设置状态】
        func.formSwitch('status', null, function (data, res) {
            console.log("开关回调成功");
        });
        </#if>
    </#list>
</#if>
    }
});

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

# Mapper模板

<?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="${packageName}.mapper.${entityName}Mapper">

</mapper>

1
2
3
4
5
6

# 查询条件(Query)模板

package ${packageName}.query;

import com.javaweb.common.common.BaseQuery;
import lombok.Data;

/**
 * <p>
 * ${tableAnnotation}查询条件
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Data
public class ${entityName}Query extends BaseQuery {

<#if model_column?exists>
    <#list model_column as model>
    <#if model.columnName = 'name'>
    /**
     * ${model.columnComment}
     */
    private String ${model.changeColumnName?uncap_first};

    </#if>
    <#if model.columnName = 'title'>
    /**
     * ${model.columnComment}
     */
    private String ${model.changeColumnName?uncap_first};

    </#if>
    <#if model.columnName = 'mobile'>
    /**
     * ${model.columnComment}
     */
    private String ${model.changeColumnName?uncap_first};

    </#if>
    <#if model.hasColumnCommentValue = true>
    /**
     * ${model.columnComment}
     */
    <#if model.columnNumberValue = true>
    private Integer ${model.changeColumnName?uncap_first};
    <#else>
    private String ${model.changeColumnName?uncap_first};
    </#if>

    </#if>
    </#list>
</#if>
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

# 接口实现(ServiceImpl)模板

package ${packageName}.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.javaweb.common.common.BaseQuery;
import com.javaweb.shiro.common.BaseServiceImpl;
import com.javaweb.common.config.CommonConfig;
import com.javaweb.common.utils.CommonUtils;
import com.javaweb.common.utils.JsonResult;
import com.javaweb.common.utils.StringUtils;
import ${packageName}.constant.${entityName}Constant;
import ${packageName}.entity.${entityName};
import ${packageName}.mapper.${entityName}Mapper;
import ${packageName}.query.${entityName}Query;
import ${packageName}.service.I${entityName}Service;
import com.javaweb.system.utils.AdminUtils;
import ${packageName}.vo.${entityName}ListVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * ${tableAnnotation} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
public class ${entityName}ServiceImpl extends BaseServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {

    @Autowired
    private ${entityName}Mapper ${entityName?uncap_first}Mapper;

    /**
     * 获取数据列表
     *
     * @param query 查询条件
     * @return
     */
    @Override
    public JsonResult getList(BaseQuery query) {
        ${entityName}Query ${entityName?uncap_first}Query = (${entityName}Query) query;
        // 查询条件
        QueryWrapper<${entityName}> queryWrapper = new QueryWrapper<>();
<#if model_column?exists>
    <#list model_column as model>
        <#if model.columnName = 'name'>
        // ${model.columnComment}
        if (!StringUtils.isEmpty(${entityName?uncap_first}Query.getName())) {
            queryWrapper.like("name", ${entityName?uncap_first}Query.getName());
        }
        </#if>
        <#if model.columnName = 'title'>
        // ${model.columnComment}
        if (!StringUtils.isEmpty(${entityName?uncap_first}Query.getTitle())) {
            queryWrapper.like("title", ${entityName?uncap_first}Query.getTitle());
        }
        </#if>
        <#if model.columnName = 'mobile'>
        // ${model.columnComment}
        if (!StringUtils.isEmpty(${entityName?uncap_first}Query.getMobile())) {
            queryWrapper.like("mobile", ${entityName?uncap_first}Query.getMobile());
        }
        </#if>
        <#if model.hasColumnCommentValue = true>
        // ${model.columnComment}
        <#if model.columnNumberValue = true>
        if (${entityName?uncap_first}Query.get${model.changeColumnName}() != null && ${entityName?uncap_first}Query.get${model.changeColumnName}() > 0) {
            queryWrapper.eq("${model.columnName}", ${entityName?uncap_first}Query.get${model.changeColumnName}());
        }
        <#else>
        if (!StringUtils.isEmpty(${entityName?uncap_first}Query.get${model.changeColumnName}())) {
            queryWrapper.eq("${model.columnName}", ${entityName?uncap_first}Query.get${model.changeColumnName}());
        }
        </#if>
        </#if>
    </#list>
</#if>
        queryWrapper.eq("mark", 1);
        queryWrapper.orderByDesc("id");

        // 查询数据
        IPage<${entityName}> page = new Page<>(${entityName?uncap_first}Query.getPage(), ${entityName?uncap_first}Query.getLimit());
        IPage<${entityName}> data = ${entityName?uncap_first}Mapper.selectPage(page, queryWrapper);
        List<${entityName}> ${entityName?uncap_first}List = data.getRecords();
        List<${entityName}ListVo> ${entityName?uncap_first}ListVoList = new ArrayList<>();
        if (!${entityName?uncap_first}List.isEmpty()) {
            ${entityName?uncap_first}List.forEach(item -> {
                ${entityName}ListVo ${entityName?uncap_first}ListVo = new ${entityName}ListVo();
                // 拷贝属性
                BeanUtils.copyProperties(item, ${entityName?uncap_first}ListVo);
    <#if model_column?exists>
        <#list model_column as model>
            <#if model.hasColumnCommentValue = true>
                // ${model.columnCommentName}描述
                <#if model.columnNumberValue = true>
                if (${entityName?uncap_first}ListVo.get${model.changeColumnName}() != null && ${entityName?uncap_first}ListVo.get${model.changeColumnName}() > 0) {
                    ${entityName?uncap_first}ListVo.set${model.changeColumnName}Name(${entityName}Constant.${entityName?upper_case}_${model.changeColumnName?upper_case}_LIST.get(${entityName?uncap_first}ListVo.get${model.changeColumnName}()));
                }
                <#else>
                if (!StringUtils.isEmpty(${entityName?uncap_first}ListVo.get${model.changeColumnName}())) {
                    ${entityName?uncap_first}ListVo.set${model.changeColumnName}Name(${entityName}Constant.${entityName?upper_case}_${model.changeColumnName?upper_case}_LIST.get(${entityName?uncap_first}ListVo.get${model.changeColumnName}()));
                }
                </#if>
            </#if>
           <#if model.columnImage == true>
                // ${model.columnComment}地址
                if (!StringUtils.isEmpty(${entityName?uncap_first}ListVo.get${model.changeColumnName}())) {
                    ${entityName?uncap_first}ListVo.set${model.changeColumnName}Url(CommonUtils.getImageURL(${entityName?uncap_first}ListVo.get${model.changeColumnName}()));
                }
            </#if>
            <#if (model.changeColumnName?uncap_first = "createUser" || model.changeColumnName?uncap_first = "updateUser")>
                // ${model.columnComment}名称
                if (${entityName?uncap_first}ListVo.get${model.changeColumnName}() != null && ${entityName?uncap_first}ListVo.get${model.changeColumnName}() > 0) {
                    ${entityName?uncap_first}ListVo.set${model.changeColumnName}Name(AdminUtils.getName((${entityName?uncap_first}ListVo.get${model.changeColumnName}())));
                }
            </#if>
        </#list>
    </#if>
                ${entityName?uncap_first}ListVoList.add(${entityName?uncap_first}ListVo);
            });
        }
        return JsonResult.success("操作成功", ${entityName?uncap_first}ListVoList, data.getTotal());
    }

    /**
     * 获取记录详情
     *
     * @param id 记录ID
     * @return
     */
    @Override
    public Object getInfo(Serializable id) {
        ${entityName} entity = (${entityName}) super.getInfo(id);
    <#if model_column?exists>
        <#list model_column as model>
        <#if model.columnImage == true>
        // ${model.columnComment}解析
        if (!StringUtils.isEmpty(entity.get${model.changeColumnName}())) {
            entity.set${model.changeColumnName}(CommonUtils.getImageURL(entity.get${model.changeColumnName}()));
        }
        </#if>
        </#list>
    </#if>
        return entity;
    }

    /**
     * 添加或编辑记录
     *
     * @param entity 实体对象
     * @return
     */
    @Override
    public JsonResult edit(${entityName} entity) {
<#if model_column?exists>
    <#list model_column as model>
      <#if model.columnImage == true>
        // ${model.columnComment}
        if (entity.get${model.changeColumnName}().contains(CommonConfig.imageURL)) {
            entity.set${model.changeColumnName}(entity.get${model.changeColumnName}().replaceAll(CommonConfig.imageURL, ""));
        }
        </#if>
    </#list>
</#if>
        return super.edit(entity);
    }

    /**
     * 删除记录
     *
     * @param id 记录ID
     * @return
     */
    @Override
    public JsonResult deleteById(Integer id) {
        if (id == null || id == 0) {
            return JsonResult.error("记录ID不能为空");
        }
        ${entityName} entity = this.getById(id);
        if (entity == null) {
            return JsonResult.error("记录不存在");
        }
        return super.delete(entity);
    }

<#if model_column?exists>
    <#list model_column as model>
    <#if model.changeColumnName?uncap_first = 'status'>
    /**
     * 设置状态
     *
     * @param entity 实体对象
     * @return
     */
    @Override
    public JsonResult setStatus(${entityName} entity) {
        if (entity.getId() == null || entity.getId() <= 0) {
            return JsonResult.error("记录ID不能为空");
        }
        if (entity.getStatus() == null) {
            return JsonResult.error("记录状态不能为空");
        }
        return super.setStatus(entity);
    }
    </#if>
    </#list>
</#if>
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216