CREATE DATABASE IF NOT EXISTS `gen` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; USE `gen`; CREATE TABLE `datasource_config` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `db_type` int(11) NOT NULL DEFAULT '0' COMMENT '数据库类型,1:MySql, 2:Oracle, 3:sqlserver', `driver_class` varchar(64) NOT NULL DEFAULT '' COMMENT '数据库驱动', `db_name` varchar(64) NOT NULL DEFAULT '' COMMENT '数据库名称', `host` varchar(64) NOT NULL DEFAULT '' COMMENT '数据库host', `port` int(11) NOT NULL DEFAULT '0' COMMENT '数据库端口', `username` varchar(64) NOT NULL DEFAULT '' COMMENT '数据库用户名', `password` varchar(64) NOT NULL DEFAULT '' COMMENT '数据库密码', `is_deleted` int(11) NOT NULL DEFAULT '0' COMMENT '是否已删除,1:已删除,0:未删除', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='数据源配置表'; CREATE TABLE `template_config` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(64) NOT NULL DEFAULT '' COMMENT '模板名称', `file_name` varchar(128) NOT NULL DEFAULT '' COMMENT '文件名称', `content` text NOT NULL COMMENT '内容', `is_deleted` int(11) NOT NULL DEFAULT '0' COMMENT '是否删除,1:已删除,0:未删除', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='模板表'; INSERT INTO `template_config` (`id`, `name`, `file_name`, `content`, `is_deleted`) VALUES (1,'entity','${context.javaBeanName}.java','package ${context.packageName}.entity;\n\n#if(${table.hasDateField})\nimport java.util.Date;\n#end\n#if(${table.hasLocalDateField})\nimport java.time.LocalDate;\n#end\n#if(${table.hasLocalDateTimeField})\nimport java.time.LocalDateTime;\n#end\n#if(${table.hasBigDecimalField})\nimport java.math.BigDecimal;\n#end\n\n#if( "${table.comment}" != "" )\n/**\n * ${table.comment}\n */\n#end\npublic class ${context.javaBeanName} {\n#foreach($column in $columns)\n#if( "${column.comment}" != "" )\n /** ${column.comment} */\n#end\n private ${column.javaTypeBox} ${column.javaFieldName};\n#end\n\n#foreach(${column} in ${columns})\n public void set${column.javaFieldNameUF}(${column.javaTypeBox} ${column.javaFieldName}) {\n this.${column.javaFieldName} = ${column.javaFieldName};\n }\n \n public ${column.javaTypeBox} get${column.javaFieldNameUF}() {\n return this.${column.javaFieldName};\n }\n \n#end\n\n @Override\n public boolean equals(Object o) {\n if (this == o) { return true; }\n if (o == null || getClass() != o.getClass()) {return false;}\n ${context.javaBeanName} that = (${context.javaBeanName}) o;\n return ${pk.javaFieldName}.equals(that.${pk.javaFieldName});\n }\n\n @Override\n public int hashCode() {\n return java.util.Objects.hash(${pk.javaFieldName});\n }\n \n @Override\n public String toString() {\n return "${context.javaBeanName}{" +\n#foreach(${column} in ${columns})\n #if($velocityCount == 1)\n "${column.javaFieldName}=" + ${column.javaFieldName} +\n #else\n ",${column.javaFieldName}=\'" + ${column.javaFieldName} + "\'" + \n #end\n#end\n \'}\';\n }\n \n}',0), (2,'mybatis','${context.javaBeanName}Mapper.xml','#set($jq="$")\n\n\n\n \n #foreach($column in $columns) \n \n #end\n \n \n \n \n #foreach($column in $columns)\n #if($velocityCount > 1),#end t.${column.columnName}\n #end\n \n \n \n \n \n \n \n\n \n \n INSERT INTO ${table.tableName}\n \n #foreach($column in $columns) \n #if(!${column.isIdentityPk}) \n ${column.columnName},\n #end \n #end\n \n \n #foreach($column in $columns) \n #if(!${column.isIdentityPk}) \n #{${column.javaFieldName}}, \n #end \n #end\n \n \n \n \n \n INSERT INTO ${table.tableName} \n \n\n #foreach($column in $columns) \n #if(!${column.isIdentityPk}) \n \n ${column.columnName},\n \n #end \n #end\n \n \n #foreach($column in $columns) \n #if(!${column.isIdentityPk}) \n \n #{${column.javaFieldName}}, \n \n #end \n #end\n \n \n\n \n \n UPDATE ${table.tableName}\n \n #foreach($column in $columns) \n #if(!${column.isPk}) \n ${column.columnName}=#{${column.javaFieldName}}, \n #end \n #end\n \n WHERE ${pk.columnName} = #{${pk.javaFieldName}}\n \n \n \n \n \n UPDATE ${table.tableName}\n \n #foreach($column in $columns) \n #if(!${column.isPk}) \n \n ${column.columnName}=#{${column.javaFieldName}}, \n \n #end \n #end\n \n WHERE ${pk.columnName} = #{${pk.javaFieldName}}\n \n\n \n \n \n UPDATE ${table.tableName}\n SET is_deleted=1\n WHERE ${pk.columnName} = #{${pk.javaFieldName}}\n \n\n\n',0), (3,'dao','${context.javaBeanName}Mapper.java','package ${context.packageName}.mapper;\n\nimport java.util.List;\nimport org.apache.ibatis.annotations.Mapper;\nimport ${context.packageName}.entity.${context.javaBeanName};\n\n@Mapper\npublic interface ${context.javaBeanName}Mapper {\n\n /**\n * 查询所有记录\n *\n * @return 返回集合,没有返回空List\n */\n List<${context.javaBeanName}> listAll();\n\n\n /**\n * 根据主键查询\n *\n * @param id 主键\n * @return 返回记录,没有返回null\n */\n ${context.javaBeanName} getById(${pk.javaTypeBox} ${pk.javaFieldName});\n \n /**\n * 新增,插入所有字段\n *\n * @param ${context.javaBeanNameLF} 新增的记录\n * @return 返回影响行数\n */\n int insert(${context.javaBeanName} ${context.javaBeanNameLF});\n \n /**\n * 新增,忽略null字段\n *\n * @param ${context.javaBeanNameLF} 新增的记录\n * @return 返回影响行数\n */\n int insertIgnoreNull(${context.javaBeanName} ${context.javaBeanNameLF});\n \n /**\n * 修改,修改所有字段\n *\n * @param ${context.javaBeanNameLF} 修改的记录\n * @return 返回影响行数\n */\n int update(${context.javaBeanName} ${context.javaBeanNameLF});\n \n /**\n * 修改,忽略null字段\n *\n * @param ${context.javaBeanNameLF} 修改的记录\n * @return 返回影响行数\n */\n int updateIgnoreNull(${context.javaBeanName} ${context.javaBeanNameLF});\n \n /**\n * 删除记录\n *\n * @param ${context.javaBeanNameLF} 待删除的记录\n * @return 返回影响行数\n */\n int delete(${context.javaBeanName} ${context.javaBeanNameLF});\n \n}',0), (4,'vue','${context.javaBeanNameLF}.vue','#set($jq="$") ',0), (5, 'Model-C#', '${context.className}.cs', 'using Newtonsoft.Json; namespace ${context.packageName} { #if( "${table.comment}" != "" ) /// /// ${table.comment} /// #end public class ${context.className} { #foreach($column in $csharpColumns) #if( "${column.comment}" != "" ) /// /// ${column.comment} /// #end [JsonProperty("${column.field}")] public ${column.fieldType} ${column.property} { get; set; } #end } }');