Browse Source

2023-11-29 修复代码生成器的bug

develop
zhousq 1 year ago
parent
commit
63678035fd
  1. 4
      lzbi-generator/src/main/resources/vm/java/mapper.java.vm
  2. 10
      lzbi-generator/src/main/resources/vm/java/service.java.vm
  3. 8
      lzbi-generator/src/main/resources/vm/xml/mapper.xml.vm
  4. 2
      lzbi-module/src/main/java/com/lzbi/serial/controller/CodeRuleSerialController.java

4
lzbi-generator/src/main/resources/vm/java/mapper.java.vm

@ -4,7 +4,7 @@ import java.util.List;
import ${packageName}.domain.${ClassName}Dao; import ${packageName}.domain.${ClassName}Dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
#if($table.sub) #if($table.sub)
import ${packageName}.domain.${subClassName}; import ${packageName}.domain.${subClassName}Dao;
#end #end
/** /**
@ -79,7 +79,7 @@ public interface ${ClassName}Mapper extends BaseMapper<${ClassName}Dao>
* @param ${subclassName}DaoList ${subTable.functionName}列表 * @param ${subclassName}DaoList ${subTable.functionName}列表
* @return 结果 * @return 结果
*/ */
public int batch${subClassNameDao}(List<${subClassName}Dao> ${subclassName}DaoList); public int batch${subClassName}Dao(List<${subClassName}Dao> ${subclassName}DaoList);
/** /**

10
lzbi-generator/src/main/resources/vm/java/service.java.vm

@ -69,7 +69,7 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class
#end #end
#end #end
#if($table.sub) #if($table.sub)
int rows = ${className}Mapper.insert${ClassName}Dao(${className}Dao); int rows = baseMapper.insert${ClassName}Dao(${className}Dao);
insert${subClassName}Dao(${className}Dao); insert${subClassName}Dao(${className}Dao);
return rows; return rows;
#else #else
@ -95,7 +95,7 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class
#end #end
#end #end
#if($table.sub) #if($table.sub)
${className}Mapper.delete${subClassName}DaoBy${subTableFkClassName}(${className}Dao.get${pkColumn.capJavaField}()); baseMapper.delete${subClassName}By${subTableFkClassName}(${className}Dao.get${pkColumn.capJavaField}());
insert${subClassName}Dao(${className}Dao); insert${subClassName}Dao(${className}Dao);
#end #end
return baseMapper.update${ClassName}Dao(${className}Dao); return baseMapper.update${ClassName}Dao(${className}Dao);
@ -114,7 +114,7 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class
public int delete${ClassName}DaoBy${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) public int delete${ClassName}DaoBy${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
{ {
#if($table.sub) #if($table.sub)
baseMapper.delete${subClassName}DaoBy${subTableFkClassName}s(${pkColumn.javaField}s); baseMapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
#end #end
return baseMapper.delete${ClassName}DaoBy${pkColumn.capJavaField}s(${pkColumn.javaField}s); return baseMapper.delete${ClassName}DaoBy${pkColumn.capJavaField}s(${pkColumn.javaField}s);
} }
@ -132,7 +132,7 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class
public int delete${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) public int delete${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{ {
#if($table.sub) #if($table.sub)
baseMapper.delete${subClassName}DaoBy${subTableFkClassName}(${pkColumn.javaField}); baseMapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
#end #end
return baseMapper.delete${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaField}); return baseMapper.delete${ClassName}DaoBy${pkColumn.capJavaField}(${pkColumn.javaField});
} }
@ -157,7 +157,7 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class
} }
if (list.size() > 0) if (list.size() > 0)
{ {
baseMapper.batch${subClassName}Dao(list); baseMapper.batch${subClassName}list);
} }
} }
} }

8
lzbi-generator/src/main/resources/vm/xml/mapper.xml.vm

@ -11,11 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
#if($table.sub) #if($table.sub)
<resultMap id="${ClassName}Dao${subClassName}DaoResult" type="${ClassName}Dao" extends="${ClassName}Result"> <resultMap id="${ClassName}${subClassName}DaoResult" type="${ClassName}Dao" extends="${ClassName}Result">
<collection property="${subclassName}DaoList" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" /> <collection property="${subclassName}DaoList" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
</resultMap> </resultMap>
<resultMap type="${subClassName}Dao" id="${subClassName}DaoResult"> <resultMap type="${subClassName}Dao" id="${subClassName}Result">
#foreach ($column in $subTable.columns) #foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}" /> <result property="${column.javaField}" column="sub_${column.columnName}" />
#end #end
@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName} select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
</sql> </sql>
<select id="select${ClassName}DaoList" parameterType="${ClassName}Dao" resultMap="${ClassName}DaoResult"> <select id="select${ClassName}DaoList" parameterType="${ClassName}Dao" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/> <include refid="select${ClassName}Vo"/>
<where> <where>
#foreach($column in $columns) #foreach($column in $columns)
@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="select${ClassName}DaoBy${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}Dao${subClassName}DaoResult#else${ClassName}DaoResult#end"> <select id="select${ClassName}DaoBy${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}DaoResult#else${ClassName}Result#end">
#if($table.crud || $table.tree) #if($table.crud || $table.tree)
<include refid="select${ClassName}Vo"/> <include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}} where ${pkColumn.columnName} = #{${pkColumn.javaField}}

2
lzbi-module/src/main/java/com/lzbi/serial/controller/CodeRuleSerialController.java

@ -91,7 +91,7 @@ public class CodeRuleSerialController extends BaseController {
public AjaxResult getBillNo(@PathVariable String node) { public AjaxResult getBillNo(@PathVariable String node) {
String billNo = ""; String billNo = "";
long serialsize = 4; long serialsize = 4;
//查询订单头 //
CodeRuleDefine codeRuleDefine = codeRuleDefineService.selectCodeRuleDefineByDefineId(0L); CodeRuleDefine codeRuleDefine = codeRuleDefineService.selectCodeRuleDefineByDefineId(0L);
if (codeRuleDefine.getDefHeader().isEmpty()) { if (codeRuleDefine.getDefHeader().isEmpty()) {
return AjaxResult.error("没有定义过ID为" + String.valueOf(0) + "的编号规则类型!"); return AjaxResult.error("没有定义过ID为" + String.valueOf(0) + "的编号规则类型!");

Loading…
Cancel
Save