Commit af156523 by danmo

代码生成模板 改为适配 Mybatis-Plus,升级http框架版本

1 parent 3fc123cd
...@@ -13,6 +13,9 @@ public class GenConstants ...@@ -13,6 +13,9 @@ public class GenConstants
/** 树表(增删改查) */ /** 树表(增删改查) */
public static final String TPL_TREE = "tree"; public static final String TPL_TREE = "tree";
/** 主子表(增删改查) */
public static final String TPL_SUB = "sub";
/** 树编码字段 */ /** 树编码字段 */
public static final String TREE_CODE = "treeCode"; public static final String TREE_CODE = "treeCode";
...@@ -32,6 +35,8 @@ public class GenConstants ...@@ -32,6 +35,8 @@ public class GenConstants
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text", public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
"mediumtext", "longtext" }; "mediumtext", "longtext" };
/** 数据库文本类型 */
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
/** 数据库时间类型 */ /** 数据库时间类型 */
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
...@@ -74,6 +79,15 @@ public class GenConstants ...@@ -74,6 +79,15 @@ public class GenConstants
/** 日期控件 */ /** 日期控件 */
public static final String HTML_DATETIME = "datetime"; public static final String HTML_DATETIME = "datetime";
/** 图片上传控件 */
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
/** 文件上传控件 */
public static final String HTML_FILE_UPLOAD = "fileUpload";
/** 富文本控件 */
public static final String HTML_EDITOR = "editor";
/** 字符串类型 */ /** 字符串类型 */
public static final String TYPE_STRING = "String"; public static final String TYPE_STRING = "String";
......
package com.linkwechat.generator.domain; package com.linkwechat.generator.domain;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import org.apache.commons.lang3.ArrayUtils;
import com.linkwechat.common.constant.GenConstants; import com.linkwechat.common.constant.GenConstants;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;
/** /**
* 业务表 gen_table * 业务表 gen_table
...@@ -28,11 +29,17 @@ public class GenTable extends BaseEntity ...@@ -28,11 +29,17 @@ public class GenTable extends BaseEntity
@NotBlank(message = "表描述不能为空") @NotBlank(message = "表描述不能为空")
private String tableComment; private String tableComment;
/** 关联父表的表名 */
private String subTableName;
/** 本表关联父表的外键名 */
private String subTableFkName;
/** 实体类名称(首字母大写) */ /** 实体类名称(首字母大写) */
@NotBlank(message = "实体类名称不能为空") @NotBlank(message = "实体类名称不能为空")
private String className; private String className;
/** 使用的模板(crud单表操作 tree树表操作) */ /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
private String tplCategory; private String tplCategory;
/** 生成包路径 */ /** 生成包路径 */
...@@ -64,6 +71,9 @@ public class GenTable extends BaseEntity ...@@ -64,6 +71,9 @@ public class GenTable extends BaseEntity
/** 主键信息 */ /** 主键信息 */
private GenTableColumn pkColumn; private GenTableColumn pkColumn;
/** 子表信息 */
private GenTable subTable;
/** 表列信息 */ /** 表列信息 */
@Valid @Valid
private List<GenTableColumn> columns; private List<GenTableColumn> columns;
...@@ -116,6 +126,26 @@ public class GenTable extends BaseEntity ...@@ -116,6 +126,26 @@ public class GenTable extends BaseEntity
this.tableComment = tableComment; this.tableComment = tableComment;
} }
public String getSubTableName()
{
return subTableName;
}
public void setSubTableName(String subTableName)
{
this.subTableName = subTableName;
}
public String getSubTableFkName()
{
return subTableFkName;
}
public void setSubTableFkName(String subTableFkName)
{
this.subTableFkName = subTableFkName;
}
public String getClassName() public String getClassName()
{ {
return className; return className;
...@@ -216,6 +246,16 @@ public class GenTable extends BaseEntity ...@@ -216,6 +246,16 @@ public class GenTable extends BaseEntity
this.pkColumn = pkColumn; this.pkColumn = pkColumn;
} }
public GenTable getSubTable()
{
return subTable;
}
public void setSubTable(GenTable subTable)
{
this.subTable = subTable;
}
public List<GenTableColumn> getColumns() public List<GenTableColumn> getColumns()
{ {
return columns; return columns;
...@@ -286,6 +326,16 @@ public class GenTable extends BaseEntity ...@@ -286,6 +326,16 @@ public class GenTable extends BaseEntity
this.parentMenuName = parentMenuName; this.parentMenuName = parentMenuName;
} }
public boolean isSub()
{
return isSub(this.tplCategory);
}
public static boolean isSub(String tplCategory)
{
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
}
public boolean isTree() public boolean isTree()
{ {
return isTree(this.tplCategory); return isTree(this.tplCategory);
......
package com.linkwechat.generator.util; package com.linkwechat.generator.util;
import java.util.Arrays;
import org.apache.commons.lang3.RegExUtils;
import com.linkwechat.common.constant.GenConstants; import com.linkwechat.common.constant.GenConstants;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.generator.config.GenConfig; import com.linkwechat.generator.config.GenConfig;
import com.linkwechat.generator.domain.GenTable; import com.linkwechat.generator.domain.GenTable;
import com.linkwechat.generator.domain.GenTableColumn; import com.linkwechat.generator.domain.GenTableColumn;
import org.apache.commons.lang3.RegExUtils;
import java.util.Arrays;
/** /**
* 代码生成器 工具类 * 代码生成器 工具类
...@@ -40,13 +41,14 @@ public class GenUtils ...@@ -40,13 +41,14 @@ public class GenUtils
column.setCreateBy(table.getCreateBy()); column.setCreateBy(table.getCreateBy());
// 设置java字段名 // 设置java字段名
column.setJavaField(StringUtils.toCamelCase(columnName)); column.setJavaField(StringUtils.toCamelCase(columnName));
// 设置默认类型
column.setJavaType(GenConstants.TYPE_STRING);
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType)) if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
{ {
column.setJavaType(GenConstants.TYPE_STRING);
// 字符串长度超过500设置为文本域 // 字符串长度超过500设置为文本域
Integer columnLength = getColumnLength(column.getColumnType()); Integer columnLength = getColumnLength(column.getColumnType());
String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT; String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
column.setHtmlType(htmlType); column.setHtmlType(htmlType);
} }
else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
...@@ -111,6 +113,21 @@ public class GenUtils ...@@ -111,6 +113,21 @@ public class GenUtils
{ {
column.setHtmlType(GenConstants.HTML_SELECT); column.setHtmlType(GenConstants.HTML_SELECT);
} }
// 图片字段设置图片上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
{
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
}
// 文件字段设置文件上传控件
else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
{
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
}
// 内容字段设置富文本控件
else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
{
column.setHtmlType(GenConstants.HTML_EDITOR);
}
} }
/** /**
......
...@@ -63,6 +63,10 @@ public class VelocityUtils ...@@ -63,6 +63,10 @@ public class VelocityUtils
{ {
setTreeVelocityContext(velocityContext, genTable); setTreeVelocityContext(velocityContext, genTable);
} }
if (GenConstants.TPL_SUB.equals(tplCategory))
{
setSubVelocityContext(velocityContext, genTable);
}
return velocityContext; return velocityContext;
} }
...@@ -96,6 +100,24 @@ public class VelocityUtils ...@@ -96,6 +100,24 @@ public class VelocityUtils
} }
} }
public static void setSubVelocityContext(VelocityContext context, GenTable genTable)
{
GenTable subTable = genTable.getSubTable();
String subTableName = genTable.getSubTableName();
String subTableFkName = genTable.getSubTableFkName();
String subClassName = genTable.getSubTable().getClassName();
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
context.put("subTable", subTable);
context.put("subTableName", subTableName);
context.put("subTableFkName", subTableFkName);
context.put("subTableFkClassName", subTableFkClassName);
context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
context.put("subClassName", subClassName);
context.put("subclassName", StringUtils.uncapitalize(subClassName));
context.put("subImportList", getImportList(genTable.getSubTable()));
}
/** /**
* 获取模板信息 * 获取模板信息
* *
...@@ -199,6 +221,37 @@ public class VelocityUtils ...@@ -199,6 +221,37 @@ public class VelocityUtils
return basePackage; return basePackage;
} }
/**
* 根据列类型获取导入包
*
* @param genTable 业务表对象
* @return 返回需要导入的包列表
*/
public static HashSet<String> getImportList(GenTable genTable)
{
List<GenTableColumn> columns = genTable.getColumns();
GenTable subGenTable = genTable.getSubTable();
HashSet<String> importList = new HashSet<String>();
if (StringUtils.isNotNull(subGenTable))
{
importList.add("java.util.List");
}
for (GenTableColumn column : columns)
{
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
{
importList.add("java.util.Date");
importList.add("com.fasterxml.jackson.annotation.JsonFormat");
}
else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType()))
{
importList.add("java.math.BigDecimal");
}
}
return importList;
}
/** /**
* 根据列类型获取导入包 * 根据列类型获取导入包
* *
......
...@@ -116,5 +116,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -116,5 +116,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{tableId} #{tableId}
</foreach> </foreach>
</delete> </delete>
<delete id="deleteGenTableColumns">
delete from gen_table_column where column_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.columnId}
</foreach>
</delete>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
package ${packageName}.controller; package ${packageName}.controller;
import java.util.List; import java.util.List;
import java.util.Arrays;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -11,15 +14,15 @@ import org.springframework.web.bind.annotation.PathVariable; ...@@ -11,15 +14,15 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import Log; import com.ruoyi.common.annotation.Log;
import BaseController; import com.ruoyi.common.core.controller.BaseController;
import AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import BusinessType; import com.ruoyi.common.enums.BusinessType;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
import ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
#if($table.crud) #if($table.crud || $table.sub)
import TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
#elseif($table.tree) #elseif($table.tree)
#end #end
...@@ -29,29 +32,27 @@ import TableDataInfo; ...@@ -29,29 +32,27 @@ import TableDataInfo;
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController @RestController
@RequestMapping("/${moduleName}/${businessName}") @RequestMapping("/${moduleName}/${businessName}" )
public class ${ClassName}Controller extends BaseController public class ${ClassName}Controller extends BaseController {
{
@Autowired private final I${ClassName}Service i${ClassName}Service;
private I${ClassName}Service ${className}Service;
/** /**
* 查询${functionName}列表 * 查询${functionName}列表
*/ */
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@GetMapping("/list") @GetMapping("/list")
#if($table.crud) #if($table.crud || $table.sub)
public TableDataInfo list(${ClassName} ${className}) public TableDataInfo list(${ClassName} ${className}) {
{
startPage(); startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); List<${ClassName}> list = i${ClassName}Service.queryList(${className});
return getDataTable(list); return getDataTable(list);
} }
#elseif($table.tree) #elseif($table.tree)
public AjaxResult list(${ClassName} ${className}) public AjaxResult list(${ClassName} ${className}) {
{ List<${ClassName}> list = i${ClassName}Service.queryList(${className});
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return AjaxResult.success(list); return AjaxResult.success(list);
} }
#end #end
...@@ -59,56 +60,51 @@ public class ${ClassName}Controller extends BaseController ...@@ -59,56 +60,51 @@ public class ${ClassName}Controller extends BaseController
/** /**
* 导出${functionName}列表 * 导出${functionName}列表
*/ */
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')" )
@Log(title = "${functionName}", businessType = BusinessType.EXPORT) @Log(title = "${functionName}" , businessType = BusinessType.EXPORT)
@GetMapping("/export") @GetMapping("/export" )
public AjaxResult export(${ClassName} ${className}) public AjaxResult export(${ClassName} ${className}) {
{ List<${ClassName}> list = i${ClassName}Service.queryList(${className});
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
return util.exportExcel(list, "${businessName}"); return util.exportExcel(list, "${businessName}" );
} }
/** /**
* 获取${functionName}详细信息 * 获取${functionName}详细信息
*/ */
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')" )
@GetMapping(value = "/{${pkColumn.javaField}}") @GetMapping(value = "/{${pkColumn.javaField}}" )
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}" ) ${pkColumn.javaType} ${pkColumn.javaField}) {
{ return AjaxResult.success(i${ClassName}Service.getById(${pkColumn.javaField}));
return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
} }
/** /**
* 新增${functionName} * 新增${functionName}
*/ */
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')" )
@Log(title = "${functionName}", businessType = BusinessType.INSERT) @Log(title = "${functionName}" , businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody ${ClassName} ${className}) public AjaxResult add(@RequestBody ${ClassName} ${className}) {
{ return toAjax(i${ClassName}Service.save(${className}) ? 1 : 0);
return toAjax(${className}Service.insert${ClassName}(${className}));
} }
/** /**
* 修改${functionName} * 修改${functionName}
*/ */
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')" )
@Log(title = "${functionName}", businessType = BusinessType.UPDATE) @Log(title = "${functionName}" , businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody ${ClassName} ${className}) public AjaxResult edit(@RequestBody ${ClassName} ${className}) {
{ return toAjax(i${ClassName}Service.updateById(${className}) ? 1 : 0);
return toAjax(${className}Service.update${ClassName}(${className}));
} }
/** /**
* 删除${functionName} * 删除${functionName}
*/ */
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')" )
@Log(title = "${functionName}", businessType = BusinessType.DELETE) @Log(title = "${functionName}" , businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}") @DeleteMapping("/{${pkColumn.javaField}s}" )
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
{ return toAjax(i${ClassName}Service.removeByIds(Arrays.asList(${pkColumn.javaField}s)) ? 1 : 0);
return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
} }
} }
package ${packageName}.domain; package ${packageName}.domain;
#foreach ($import in $importList) import com.fasterxml.jackson.annotation.JsonFormat;
import ${import}; import lombok.Data;
#end import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder; import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel;
import Excel; import com.baomidou.mybatisplus.annotation.TableId;
#if($table.crud) import com.baomidou.mybatisplus.annotation.TableName;
import BaseEntity; import com.baomidou.mybatisplus.annotation.IdType;
#elseif($table.tree) import com.baomidou.mybatisplus.annotation.TableField;
import TreeEntity; import java.io.Serializable;
#end import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.math.BigDecimal;
/** /**
* ${functionName}对象 ${tableName} * ${functionName}对象 ${tableName}
...@@ -18,17 +21,16 @@ import TreeEntity; ...@@ -18,17 +21,16 @@ import TreeEntity;
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
#if($table.crud) @Data
#set($Entity="BaseEntity") @NoArgsConstructor
#elseif($table.tree) @Accessors(chain = true)
#set($Entity="TreeEntity") @TableName("${tableName}")
#end public class ${ClassName} implements Serializable {
public class ${ClassName} extends ${Entity}
{ private static final long serialVersionUID=1L;
private static final long serialVersionUID = 1L;
#foreach ($column in $columns) #foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */ /** $column.columnComment */
#if($column.list) #if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf("(")) #set($parentheseIndex=$column.columnComment.indexOf("("))
...@@ -38,48 +40,22 @@ public class ${ClassName} extends ${Entity} ...@@ -38,48 +40,22 @@ public class ${ClassName} extends ${Entity}
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()") @Excel(name = "${comment}" , readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date') #elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "${comment}" , width = 30, dateFormat = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
#else #else
@Excel(name = "${comment}") @Excel(name = "${comment}")
#end #end
#end #end
#if($column.isPk==1)
@TableId(value = "$column.columnName")
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#end
#end
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else #else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) private $column.javaType $column.javaField;
#end
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}()
{
return $column.javaField;
}
#end #end
#end #end
@Override @TableField(exist = false)
public String toString() { private Map<String, Object> params = new HashMap<>();
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $columns)
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
.append("${column.javaField}", get${AttrName}())
#end
.toString();
}
} }
package ${packageName}.mapper; package ${packageName}.mapper;
import java.util.List;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/** /**
* ${functionName}Mapper接口 * ${functionName}Mapper接口
* *
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
public interface ${ClassName}Mapper public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
{
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int update${ClassName}(${ClassName} ${className});
/**
* 删除${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的数据ID
* @return 结果
*/
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
} }
package ${packageName}.service; package ${packageName}.service;
import java.util.List;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/** /**
* ${functionName}Service接口 * ${functionName}Service接口
* *
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
public interface I${ClassName}Service public interface I${ClassName}Service extends IService<${ClassName}> {
{
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int update${ClassName}(${ClassName} ${className});
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID
* @return 结果
*/
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/** /**
* 删除${functionName}信息 * 查询列表
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return 结果
*/ */
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}); List<${ClassName}> queryList(${ClassName} ${className});
} }
package ${packageName}.service.impl; package ${packageName}.service.impl;
import java.util.List;
#foreach ($column in $columns)
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
import DateUtils;
#break
#end
#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
import java.util.List;
import java.util.Map;
/** /**
* ${functionName}Service业务层处理 * ${functionName}Service业务层处理
* *
* @author ${author} * @author ${author}
* @date ${datetime} * @date ${datetime}
*/ */
@Service @Service
public class ${ClassName}ServiceImpl implements I${ClassName}Service public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service {
{
@Autowired
private ${ClassName}Mapper ${className}Mapper;
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}ID
* @return ${functionName}
*/
@Override @Override
public ${ClassName} select${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) public List<${ClassName}> queryList(${ClassName} ${className}) {
{ LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
return ${className}Mapper.select${ClassName}ById(${pkColumn.javaField}); #foreach($column in $columns)
} #set($queryType=$column.queryType)
#set($javaField=$column.javaField)
/** #set($javaType=$column.javaType)
* 查询${functionName}列表 #set($columnName=$column.columnName)
* #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
* @param ${className} ${functionName} #if($column.query)
* @return ${functionName} #if($column.queryType == "EQ")
*/ #if($javaType == 'String')
@Override if (StringUtils.isNotBlank(${className}.get$AttrName())){
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName());
{ }
return ${className}Mapper.select${ClassName}List(${className}); #else
} if (${className}.get$AttrName() != null){
lqw.eq(${ClassName}::get$AttrName ,${className}.get$AttrName());
/** }
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
@Override
public int insert${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'createTime')
${className}.setCreateTime(DateUtils.getNowDate());
#end #end
#elseif($queryType == "NE")
#if($javaType == 'String')
if (StringUtils.isNotBlank(${className}.get$AttrName())){
lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName());
}
#else
if (${className}.get$AttrName() != null){
lqw.ne(${ClassName}::get$AttrName ,${className}.get$AttrName());
}
#end #end
return ${className}Mapper.insert${ClassName}(${className}); #elseif($queryType == "GT")
} #if($javaType == 'String')
if (StringUtils.isNotBlank(${className}.get$AttrName())){
/** lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName());
* 修改${functionName} }
* #else
* @param ${className} ${functionName} if (${className}.get$AttrName() != null){
* @return 结果 lqw.gt(${ClassName}::get$AttrName ,${className}.get$AttrName());
*/ }
@Override
public int update${ClassName}(${ClassName} ${className})
{
#foreach ($column in $columns)
#if($column.javaField == 'updateTime')
${className}.setUpdateTime(DateUtils.getNowDate());
#end #end
#elseif($queryType == "GTE")
#if($javaType == 'String')
if (StringUtils.isNotBlank(${className}.get$AttrName())){
lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName());
}
#else
if (${className}.get$AttrName() != null){
lqw.ge(${ClassName}::get$AttrName ,${className}.get$AttrName());
}
#end #end
return ${className}Mapper.update${ClassName}(${className}); #elseif($queryType == "LT")
} #if($javaType == 'String')
if (StringUtils.isNotBlank(${className}.get$AttrName())){
/** lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName());
* 批量删除${functionName} }
* #else
* @param ${pkColumn.javaField}s 需要删除的${functionName}ID if (${className}.get$AttrName() != null){
* @return 结果 lqw.lt(${ClassName}::get$AttrName ,${className}.get$AttrName());
*/ }
@Override #end
public int delete${ClassName}ByIds(${pkColumn.javaType}[] ${pkColumn.javaField}s) #elseif($queryType == "LTE")
{ #if($javaType == 'String')
return ${className}Mapper.delete${ClassName}ByIds(${pkColumn.javaField}s); if (StringUtils.isNotBlank(${className}.get$AttrName())){
} lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName());
}
/** #else
* 删除${functionName}信息 if (${className}.get$AttrName() != null){
* lqw.le(${ClassName}::get$AttrName ,${className}.get$AttrName());
* @param ${pkColumn.javaField} ${functionName}ID }
* @return 结果 #end
*/ #elseif($queryType == "LIKE")
@Override #if($javaType == 'String')
public int delete${ClassName}ById(${pkColumn.javaType} ${pkColumn.javaField}) if (StringUtils.isNotBlank(${className}.get$AttrName())){
{ lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName());
return ${className}Mapper.delete${ClassName}ById(${pkColumn.javaField}); }
#else
if (${className}.get$AttrName() != null){
lqw.like(${ClassName}::get$AttrName ,${className}.get$AttrName());
}
#end
#elseif($queryType == "BETWEEN")
Map<String, Object> params = ${className}.getParams();
if (params.get("begin$AttrName") != null && params.get("end$AttrName") != null) {
lqw.between(${ClassName}::get$AttrName ,params.get("begin$AttrName"),params.get("end$AttrName"));
}
#end
#end
#end
return this.list(lqw);
} }
} }
-- 菜单 SQL -- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单'); values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
-- 按钮父菜单ID -- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID(); SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL -- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}查询', @parentId, '1', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}新增', @parentId, '2', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}修改', @parentId, '3', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}删除', @parentId, '4', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', ''); values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}导出', @parentId, '5', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
\ No newline at end of file \ No newline at end of file
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');
\ No newline at end of file \ No newline at end of file
...@@ -38,20 +38,33 @@ ...@@ -38,20 +38,33 @@
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "datetime") #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="${column.javaField}">
<el-date-picker clearable size="small" style="width: 200px" <el-date-picker clearable size="small"
v-model="queryParams.${column.javaField}" v-model="queryParams.${column.javaField}"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
placeholder="选择${comment}"> placeholder="选择${comment}">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
<el-form-item label="${comment}">
<el-date-picker
v-model="daterange${AttrName}"
size="small"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
></el-date-picker>
</el-form-item>
#end #end
#end #end
#end #end
<el-form-item> <el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -60,6 +73,7 @@ ...@@ -60,6 +73,7 @@
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="primary" type="primary"
plain
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
...@@ -139,6 +153,18 @@ ...@@ -139,6 +153,18 @@
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-input v-model="form.${field}" placeholder="请输入${comment}" /> <el-input v-model="form.${field}" placeholder="请输入${comment}" />
</el-form-item> </el-form-item>
#elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment}">
<imageUpload v-model="form.${field}"/>
</el-form-item>
#elseif($column.htmlType == "fileUpload")
<el-form-item label="${comment}">
<fileUpload v-model="form.${field}"/>
</el-form-item>
#elseif($column.htmlType == "editor")
<el-form-item label="${comment}">
<editor v-model="form.${field}" :min-height="192"/>
</el-form-item>
#elseif($column.htmlType == "select" && "" != $dictType) #elseif($column.htmlType == "select" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}"> <el-select v-model="form.${field}" placeholder="请选择${comment}">
...@@ -193,10 +219,10 @@ ...@@ -193,10 +219,10 @@
</el-form-item> </el-form-item>
#elseif($column.htmlType == "datetime") #elseif($column.htmlType == "datetime")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-date-picker clearable size="small" style="width: 200px" <el-date-picker clearable size="small"
v-model="form.${field}" v-model="form.${field}"
type="date" type="datetime"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择${comment}"> placeholder="选择${comment}">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
...@@ -221,10 +247,48 @@ ...@@ -221,10 +247,48 @@
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}"; import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
import ImageUpload from '@/components/ImageUpload';
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
import FileUpload from '@/components/FileUpload';
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
import Editor from '@/components/Editor';
#break
#end
#end
export default { export default {
name: "${BusinessName}", name: "${BusinessName}",
components: { Treeselect }, components: {
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
ImageUpload,
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
FileUpload,
#break
#end
#end
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
Editor,
#break
#end
#end
Treeselect
},
data() { data() {
return { return {
// 遮罩层 // 遮罩层
...@@ -249,6 +313,10 @@ export default { ...@@ -249,6 +313,10 @@ export default {
#if(${column.dictType} != '') #if(${column.dictType} != '')
// $comment字典 // $comment字典
${column.javaField}Options: [], ${column.javaField}Options: [],
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
// $comment时间范围
daterange${AttrName}: [],
#end #end
#end #end
// 查询参数 // 查询参数
...@@ -273,7 +341,7 @@ export default { ...@@ -273,7 +341,7 @@ export default {
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
$column.javaField: [ $column.javaField: [
{ required: true, message: "$comment不能为空", trigger: "#if($column.htmlType == "select")"change"#else"blur"#end" } { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
]#if($velocityCount != $columns.size()),#end ]#if($velocityCount != $columns.size()),#end
#end #end
...@@ -295,6 +363,21 @@ export default { ...@@ -295,6 +363,21 @@ export default {
/** 查询${functionName}列表 */ /** 查询${functionName}列表 */
getList() { getList() {
this.loading = true; this.loading = true;
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
this.queryParams.params = {};
#break
#end
#end
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
if (null != this.daterange${AttrName} && '' != this.daterange${AttrName}) {
this.queryParams.params["begin${AttrName}"] = this.daterange${AttrName}[0];
this.queryParams.params["end${AttrName}"] = this.daterange${AttrName}[1];
}
#end
#end
list${BusinessName}(this.queryParams).then(response => { list${BusinessName}(this.queryParams).then(response => {
this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}"); this.${businessName}List = this.handleTree(response.data, "${treeCode}", "${treeParentCode}");
this.loading = false; this.loading = false;
...@@ -363,6 +446,12 @@ export default { ...@@ -363,6 +446,12 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
#foreach ($column in $columns)
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
this.daterange${AttrName} = [];
#end
#end
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
...@@ -402,19 +491,15 @@ export default { ...@@ -402,19 +491,15 @@ export default {
#end #end
if (this.form.${pkColumn.javaField} != null) { if (this.form.${pkColumn.javaField} != null) {
update${BusinessName}(this.form).then(response => { update${BusinessName}(this.form).then(response => {
if (response.code === 200) { this.msgSuccess("修改成功");
this.msgSuccess("修改成功"); this.open = false;
this.open = false; this.getList();
this.getList();
}
}); });
} else { } else {
add${BusinessName}(this.form).then(response => { add${BusinessName}(this.form).then(response => {
if (response.code === 200) { this.msgSuccess("新增成功");
this.msgSuccess("新增成功"); this.open = false;
this.open = false; this.getList();
this.getList();
}
}); });
} }
} }
...@@ -431,7 +516,7 @@ export default { ...@@ -431,7 +516,7 @@ export default {
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}).catch(function() {}); })
} }
} }
}; };
......
...@@ -10,86 +10,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -10,86 +10,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#end #end
</resultMap> </resultMap>
<sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
</sql>
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
<where>
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
#elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
#elseif($queryType == "GT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt; #{$javaField}</if>
#elseif($queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt;= #{$javaField}</if>
#elseif($queryType == "LT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt; #{$javaField}</if>
#elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
#end
#end
#end
</where>
</select>
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</select>
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
#end
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
#end
#end
</trim>
</insert>
<update id="update${ClassName}" parameterType="${ClassName}">
update ${tableName}
<trim prefix="SET" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $pkColumn.columnName)
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
#end
#end
</trim>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</update>
<delete id="delete${ClassName}ById" parameterType="${pkColumn.javaType}">
delete from ${tableName} where ${pkColumn.columnName} = #{${pkColumn.javaField}}
</delete>
<delete id="delete${ClassName}ByIds" parameterType="String">
delete from ${tableName} where ${pkColumn.columnName} in
<foreach item="${pkColumn.javaField}" collection="array" open="(" separator="," close=")">
#{${pkColumn.javaField}}
</foreach>
</delete>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<poi.version>3.17</poi.version> <poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version> <velocity.version>1.7</velocity.version>
<jwt.version>0.9.0</jwt.version> <jwt.version>0.9.0</jwt.version>
<forest.version>1.5.0-RC2</forest.version> <forest.version>1.5.0-RC3</forest.version>
<lombok.version>1.18.16</lombok.version> <lombok.version>1.18.16</lombok.version>
<reflectasm.version>1.11.9</reflectasm.version> <reflectasm.version>1.11.9</reflectasm.version>
<hutool.version>5.4.1</hutool.version> <hutool.version>5.4.1</hutool.version>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!