通用优化

This commit is contained in:
zhujunjieit 2018-12-07 22:23:03 +08:00
parent 96aa2727fe
commit 1353b040a8
35 changed files with 145 additions and 227 deletions

View File

@ -51,6 +51,12 @@
<artifactId>ruoyi-exam</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 测试生成的代码-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-test</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 定时任务
<dependency>
<groupId>com.ruoyi</groupId>

View File

@ -127,7 +127,7 @@ gen:
# 作者
author: zhujj
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
packageName: com.ruoyi.exam
packageName: com.ruoyi.test
# 自动去除表前缀默认是true
autoRemovePre: false
# 表前缀(类名不会包含表前缀)

View File

@ -2,7 +2,8 @@ package com.ruoyi.exam.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
import java.util.Date;
/**
@ -16,6 +17,7 @@ public class ExamQuestion
private static final long serialVersionUID = 1L;
/** */
@Id
private String id;
/** 问题标题 */
private String title;

View File

@ -2,7 +2,8 @@ package com.ruoyi.exam.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
import java.util.Date;
/**
@ -16,6 +17,7 @@ public class ExamQuestionCategory
private static final long serialVersionUID = 1L;
/** */
@Id
private String id;
/** 分类 */
private String name;

View File

@ -2,7 +2,8 @@ package com.ruoyi.exam.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
import java.util.Date;
/**
@ -16,6 +17,7 @@ public class ExamQuestionComment
private static final long serialVersionUID = 1L;
/** */
@Id
private String id;
/** 点评内容 */
private Integer content;

View File

@ -2,7 +2,8 @@ package com.ruoyi.exam.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
import java.util.Date;
/**
@ -16,6 +17,7 @@ public class ExamQuestionItem
private static final long serialVersionUID = 1L;
/** */
@Id
private String id;
/** 选项内容 */
private String content;

View File

@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 参数配置表 sys_config
*
@ -16,6 +18,7 @@ public class SysConfig extends BaseEntity
/** 参数主键 */
@Excel(name = "参数主键")
@Id
private Long configId;
/** 参数名称 */

View File

@ -4,6 +4,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 部门表 sys_dept
*
@ -14,6 +16,7 @@ public class SysDept extends BaseEntity
private static final long serialVersionUID = 1L;
/** 部门ID */
@Id
private Long deptId;
/** 父部门ID */

View File

@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 字典数据表 sys_dict_data
*
@ -16,6 +18,7 @@ public class SysDictData extends BaseEntity
/** 字典编码 */
@Excel(name = "字典编码")
@Id
private Long dictCode;
/** 字典排序 */

View File

@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 字典类型表 sys_dict_type
*
@ -16,6 +18,7 @@ public class SysDictType extends BaseEntity
/** 字典主键 */
@Excel(name = "字典主键")
@Id
private Long dictId;
/** 字典名称 */

View File

@ -6,6 +6,8 @@ import java.util.Date;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 系统访问记录表 sys_logininfor
*
@ -17,6 +19,7 @@ public class SysLogininfor extends BaseEntity
/** ID */
@Excel(name = "序号")
@Id
private Long infoId;
/** 用户账号 */

View File

@ -6,6 +6,8 @@ import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 菜单权限表 sys_menu
*
@ -16,6 +18,7 @@ public class SysMenu extends BaseEntity
private static final long serialVersionUID = 1L;
/** 菜单ID */
@Id
private Long menuId;
/** 菜单名称 */

View File

@ -4,6 +4,8 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 通知公告表 sys_notice
*
@ -14,6 +16,7 @@ public class SysNotice extends BaseEntity
private static final long serialVersionUID = 1L;
/** 公告ID */
@Id
private Long noticeId;
/** 公告标题 */

View File

@ -6,6 +6,8 @@ import java.util.Date;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 操作日志记录表 oper_log
*
@ -17,6 +19,7 @@ public class SysOperLog extends BaseEntity
/** 日志主键 */
@Excel(name = "操作序号")
@Id
private Long operId;
/** 操作模块 */

View File

@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 岗位表 sys_post
*
@ -16,6 +18,7 @@ public class SysPost extends BaseEntity
/** 岗位序号 */
@Excel(name = "岗位序号")
@Id
private Long postId;
/** 岗位编码 */

View File

@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 角色表 sys_role
*
@ -16,6 +18,7 @@ public class SysRole extends BaseEntity
/** 角色ID */
@Excel(name = "角色序号")
@Id
private Long roleId;
/** 角色名称 */

View File

@ -3,6 +3,8 @@ package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Id;
/**
* 角色和部门关联 sys_role_dept
*
@ -11,6 +13,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class SysRoleDept
{
/** 角色ID */
@Id
private Long roleId;
/** 部门ID */

View File

@ -3,6 +3,8 @@ package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Id;
/**
* 角色和菜单关联 sys_role_menu
*
@ -11,6 +13,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class SysRoleMenu
{
/** 角色ID */
@Id
private Long roleId;
/** 菜单ID */

View File

@ -7,6 +7,8 @@ import java.util.List;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
/**
* 用户对象 sys_user
*
@ -18,6 +20,7 @@ public class SysUser extends BaseEntity
/** 用户ID */
@Excel(name = "用户序号")
@Id
private Long userId;
/** 部门ID */

View File

@ -6,6 +6,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import com.ruoyi.common.enums.OnlineStatus;
import javax.persistence.Id;
/**
* 当前在线会话 sys_user_online
*
@ -16,6 +18,7 @@ public class SysUserOnline extends BaseEntity
private static final long serialVersionUID = 1L;
/** 用户会话id */
@Id
private String sessionId;
/** 部门名称 */

View File

@ -3,6 +3,8 @@ package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Id;
/**
* 用户和岗位关联 sys_user_post
*
@ -11,6 +13,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class SysUserPost
{
/** 用户ID */
@Id
private Long userId;
/** 岗位ID */

View File

@ -3,6 +3,8 @@ package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.persistence.Id;
/**
* 用户和角色关联 sys_user_role
*
@ -11,6 +13,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class SysUserRole
{
/** 用户ID */
@Id
private Long userId;
/** 角色ID */

View File

@ -1,9 +1,10 @@
package com.ruoyi.agile.domain;
import com.ruoyi.common.base.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
import javax.persistence.Id;
import java.math.BigDecimal;
/**
@ -17,6 +18,7 @@ public class GenTableColumn extends BaseEntity
private static final long serialVersionUID = 1L;
/** 编号 */
@Id
private String id;
/** 表名 */
private String tableName;

View File

@ -2,9 +2,6 @@ package com.ruoyi.agile.mapper;
import com.ruoyi.agile.domain.GenTable;
import com.ruoyi.framework.web.base.MyMapper;
import com.ruoyi.generator.domain.TableInfo;
import java.util.List;
/**
* 代码生成 数据层

View File

@ -3,6 +3,8 @@ package com.ruoyi.generator.domain;
import com.ruoyi.common.json.JSON;
import com.ruoyi.common.utils.StringUtils;
import javax.persistence.Id;
/**
* ry数据库表列信息
*
@ -11,6 +13,7 @@ import com.ruoyi.common.utils.StringUtils;
public class ColumnInfo
{
/** 字段名称 */
@Id
private String columnName;
/** 字段类型 */

View File

@ -4,6 +4,8 @@ import java.util.List;
import com.ruoyi.common.base.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
import javax.persistence.Id;
/**
* ry 数据库表
*
@ -14,6 +16,7 @@ public class TableInfo extends BaseEntity
private static final long serialVersionUID = 1L;
/** 表名称 */
@Id
private String tableName;
/** 表描述 */

View File

@ -31,8 +31,8 @@ import com.ruoyi.generator.util.VelocityInitializer;
* @author ruoyi
*/
@Service
public class GenServiceImpl extends AbstractBaseServiceImpl<GenMapper,TableInfo> implements IGenService {
private static final Logger log = LoggerFactory.getLogger(GenServiceImpl.class);
public class GenServiceImpl extends AbstractBaseServiceImpl<GenMapper, TableInfo> implements IGenService {
private static final Logger log = LoggerFactory.getLogger( GenServiceImpl.class );
/**
@ -42,10 +42,9 @@ public class GenServiceImpl extends AbstractBaseServiceImpl<GenMapper,TableInfo>
* @return 数据库表列表
*/
@Override
public List<TableInfo> selectTableList(TableInfo tableInfo)
{
public List<TableInfo> selectTableList(TableInfo tableInfo) {
startPage();
return mapper.selectTableList(tableInfo);
return mapper.selectTableList( tableInfo );
}
/**
@ -55,17 +54,16 @@ public class GenServiceImpl extends AbstractBaseServiceImpl<GenMapper,TableInfo>
* @return 数据
*/
@Override
public byte[] generatorCode(String tableName)
{
public byte[] generatorCode(String tableName) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
ZipOutputStream zip = new ZipOutputStream( outputStream );
// 查询表信息
TableInfo table = mapper.selectTableByName(tableName);
TableInfo table = mapper.selectTableByName( tableName );
// 查询列信息
List<ColumnInfo> columns = mapper.selectTableColumnsByName(tableName);
List<ColumnInfo> columns = mapper.selectTableColumnsByName( tableName );
// 生成代码
generatorCode(table, columns, zip);
IOUtils.closeQuietly(zip);
generatorCode( table, columns, zip );
IOUtils.closeQuietly( zip );
return outputStream.toByteArray();
}
@ -76,63 +74,56 @@ public class GenServiceImpl extends AbstractBaseServiceImpl<GenMapper,TableInfo>
* @return 数据
*/
@Override
public byte[] generatorCode(String[] tableNames)
{
public byte[] generatorCode(String[] tableNames) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
for (String tableName : tableNames)
{
ZipOutputStream zip = new ZipOutputStream( outputStream );
for (String tableName : tableNames) {
// 查询表信息
TableInfo table = mapper.selectTableByName(tableName);
TableInfo table = mapper.selectTableByName( tableName );
// 查询列信息
List<ColumnInfo> columns = mapper.selectTableColumnsByName(tableName);
List<ColumnInfo> columns = mapper.selectTableColumnsByName( tableName );
// 生成代码
generatorCode(table, columns, zip);
generatorCode( table, columns, zip );
}
IOUtils.closeQuietly(zip);
IOUtils.closeQuietly( zip );
return outputStream.toByteArray();
}
/**
* 生成代码
*/
public void generatorCode(TableInfo table, List<ColumnInfo> columns, ZipOutputStream zip)
{
public void generatorCode(TableInfo table, List<ColumnInfo> columns, ZipOutputStream zip) {
// 表名转换成Java属性名
String className = GenUtils.tableToJava(table.getTableName());
table.setClassName(className);
table.setClassname(StringUtils.uncapitalize(className));
String className = GenUtils.tableToJava( table.getTableName() );
table.setClassName( className );
table.setClassname( StringUtils.uncapitalize( className ) );
// 列信息
table.setColumns(GenUtils.transColums(columns));
table.setColumns( GenUtils.transColums( columns ) );
// 设置主键
table.setPrimaryKey(table.getColumnsLast());
table.setPrimaryKey( table.getColumnsLast() );
VelocityInitializer.initVelocity();
String packageName = Global.getPackageName();
String moduleName = GenUtils.getModuleName(packageName);
String moduleName = GenUtils.getModuleName( packageName );
VelocityContext context = GenUtils.getVelocityContext(table);
VelocityContext context = GenUtils.getVelocityContext( table );
// 获取模板列表
List<String> templates = GenUtils.getTemplates();
for (String template : templates)
{
for (String template : templates) {
// 渲染模板
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw);
try
{
Template tpl = Velocity.getTemplate( template, Constants.UTF8 );
tpl.merge( context, sw );
try {
// 添加到zip
zip.putNextEntry(new ZipEntry(GenUtils.getFileName(template, table, moduleName)));
IOUtils.write(sw.toString(), zip, Constants.UTF8);
IOUtils.closeQuietly(sw);
zip.putNextEntry( new ZipEntry( GenUtils.getFileName( template, table, moduleName ) ) );
IOUtils.write( sw.toString(), zip, Constants.UTF8 );
IOUtils.closeQuietly( sw );
zip.closeEntry();
}
catch (IOException e)
{
log.error("渲染模板失败,表名:" + table.getTableName(), e);
} catch (IOException e) {
log.error( "渲染模板失败,表名:" + table.getTableName(), e );
}
}
}

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.agile.mapper.GenTableColumnMapper">
<mapper namespace="com.ruoyi.agile.mapper.GenTableColumnAllMapper">
<resultMap type="GenTableColumn" id="GenTableColumnResult">
<result property="id" column="id" />

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.agile.mapper.GenTableMapper">
<mapper namespace="com.ruoyi.agile.mapper.GenTableAllMapper">
<resultMap type="GenTable" id="GenTableResult">
<result property="id" column="id" />

View File

@ -49,7 +49,7 @@ public class ${className}Controller extends BaseController
@ResponseBody
public TableDataInfo list(${className} ${classname})
{
List<${className}> list = ${classname}Service.select${className}List(${classname});
List<${className}> list = ${classname}Service.select${className}Page(${classname});
return getDataTable(list);
}
@ -85,7 +85,7 @@ public class ${className}Controller extends BaseController
@ResponseBody
public AjaxResult addSave(${className} ${classname})
{
return toAjax(${classname}Service.insert${className}(${classname}));
return toAjax(${classname}Service.insert(${classname}));
}
/**
@ -94,7 +94,7 @@ public class ${className}Controller extends BaseController
@GetMapping("/edit/{${primaryKey.attrname}}")
public String edit(@PathVariable("${primaryKey.attrname}") ${primaryKey.attrType} ${primaryKey.attrname}, ModelMap mmap)
{
${className} ${classname} = ${classname}Service.select${className}ById(${primaryKey.attrname});
${className} ${classname} = ${classname}Service.selectById(${primaryKey.attrname});
mmap.put("${classname}", ${classname});
return prefix + "/edit";
}
@ -108,7 +108,7 @@ public class ${className}Controller extends BaseController
@ResponseBody
public AjaxResult editSave(${className} ${classname})
{
return toAjax(${classname}Service.update${className}(${classname}));
return toAjax(${classname}Service.updateById(${classname}));
}
/**
@ -120,7 +120,7 @@ public class ${className}Controller extends BaseController
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(${classname}Service.delete${className}ByIds(ids));
return toAjax(${classname}Service.deleteByIds(ids));
}
}

View File

@ -12,13 +12,6 @@ import com.ruoyi.framework.web.base.MyMapper;
*/
public interface ${className}Mapper extends MyMapper<${className}>
{
/**
* 查询${tableComment}信息
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @return ${tableComment}信息
*/
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
/**
* 查询${tableComment}列表
@ -28,36 +21,4 @@ public interface ${className}Mapper extends MyMapper<${className}>
*/
public List<${className}> select${className}List(${className} ${classname});
/**
* 新增${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
public int insert${className}(${className} ${classname});
/**
* 修改${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
public int update${className}(${className} ${classname});
/**
* 删除${tableComment}
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @return 结果
*/
public int delete${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
/**
* 批量删除${tableComment}
*
* @param ${primaryKey.attrname}s 需要删除的数据ID
* @return 结果
*/
public int delete${className}ByIds(String[] ${primaryKey.attrname}s);
}

View File

@ -12,13 +12,12 @@ import com.ruoyi.framework.web.base.AbstractBaseService;
public interface I${className}Service extends AbstractBaseService<${className}>
{
/**
* 查询${tableComment}信息
* 查询${tableComment}分页列表
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @return ${tableComment}信息
* @param ${classname} ${tableComment}信息
* @return ${tableComment}集合
*/
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname});
public List<${className}> select${className}Page(${className} ${classname});
/**
* 查询${tableComment}列表
*
@ -27,28 +26,5 @@ public interface I${className}Service extends AbstractBaseService<${className}>
*/
public List<${className}> select${className}List(${className} ${classname});
/**
* 新增${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
public int insert${className}(${className} ${classname});
/**
* 修改${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
public int update${className}(${className} ${classname});
/**
* 删除${tableComment}信息
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int delete${className}ByIds(String ids);
}

View File

@ -20,17 +20,6 @@ public class ${className}ServiceImpl extends AbstractBaseServiceImpl<${className
@Autowired
private ${className}Mapper ${classname}Mapper;
/**
* 查询${tableComment}信息
*
* @param ${primaryKey.attrname} ${tableComment}ID
* @return ${tableComment}信息
*/
@Override
public ${className} select${className}ById(${primaryKey.attrType} ${primaryKey.attrname})
{
return ${classname}Mapper.select${className}ById(${primaryKey.attrname});
}
/**
* 查询${tableComment}列表
@ -40,45 +29,20 @@ public class ${className}ServiceImpl extends AbstractBaseServiceImpl<${className
*/
@Override
public List<${className}> select${className}List(${className} ${classname})
{
return ${classname}Mapper.select${className}List(${classname});
}
/**
* 查询${tableComment}分页列表
*
* @param ${classname} ${tableComment}信息
* @return ${tableComment}集合
*/
@Override
public List<${className}> select${className}Page(${className} ${classname})
{
startPage();
return ${classname}Mapper.select${className}List(${classname});
}
/**
* 新增${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
@Override
public int insert${className}(${className} ${classname})
{
return ${classname}Mapper.insert${className}(${classname});
}
/**
* 修改${tableComment}
*
* @param ${classname} ${tableComment}信息
* @return 结果
*/
@Override
public int update${className}(${className} ${classname})
{
return ${classname}Mapper.update${className}(${classname});
}
/**
* 删除${tableComment}对象
*
* @param ids 需要删除的数据ID
* @return 结果
*/
@Override
public int delete${className}ByIds(String ids)
{
return ${classname}Mapper.delete${className}ByIds(Convert.toStrArray(ids));
}
}

View File

@ -5,6 +5,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity;
#foreach ($column in $columns)
#if($column.attrType == 'Date')
import javax.persistence.Id;
import java.util.Date;
#break
#end
@ -22,6 +23,7 @@ public class ${className}
#foreach ($column in $columns)
/** $column.columnComment */
@Id
private $column.attrType $column.attrname;
#end

View File

@ -11,11 +11,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="select${className}Vo">
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end
</sql>
<select id="select${className}List" parameterType="${className}" resultMap="${className}Result">
select
<include refid="select${className}Vo"/>
from ${tableName}
<where>
#foreach($column in $columns)
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname.trim() != '' #end"> and $column.columnName = #{$column.attrname}</if>
@ -23,50 +25,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="select${className}ById" parameterType="${primaryKey.attrType}" resultMap="${className}Result">
<include refid="select${className}Vo"/>
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
</select>
<insert id="insert${className}" parameterType="${className}"#if($primaryKey.extra == 'auto_increment') useGeneratedKeys="true" keyProperty="$primaryKey.attrname"#end>
insert into ${tableName}
<trim prefix="(" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName,</if>
#end
#end
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName || $primaryKey.extra != 'auto_increment')
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">#{$column.attrname},</if>
#end
#end
</trim>
</insert>
<update id="update${className}" parameterType="${className}">
update ${tableName}
<trim prefix="SET" suffixOverrides=",">
#foreach($column in $columns)
#if($column.columnName != $primaryKey.columnName)
<if test="$column.attrname != null #if($column.attrType == 'String' ) and $column.attrname != '' #end ">$column.columnName = #{$column.attrname},</if>
#end
#end
</trim>
where ${primaryKey.columnName} = #{${primaryKey.attrname}}
</update>
<delete id="delete${className}ById" parameterType="${primaryKey.attrType}">
delete from ${tableName} where ${primaryKey.columnName} = #{${primaryKey.attrname}}
</delete>
<delete id="delete${className}ByIds" parameterType="String">
delete from ${tableName} where ${primaryKey.columnName} in
<foreach item="${primaryKey.attrname}" collection="array" open="(" separator="," close=")">
#{${primaryKey.attrname}}
</foreach>
</delete>
</mapper>