Browse Source

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

develop
zhousq 12 months 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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
#if($table.sub)
import ${packageName}.domain.${subClassName};
import ${packageName}.domain.${subClassName}Dao;
#end
/**
@ -79,7 +79,7 @@ public interface ${ClassName}Mapper extends BaseMapper<${ClassName}Dao>
* @param ${subclassName}DaoList ${subTable.functionName}列表
* @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
#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);
return rows;
#else
@ -95,7 +95,7 @@ public class ${ClassName}Service extends ServiceImpl<${ClassName}Mapper, ${Class
#end
#end
#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);
#end
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)
{
#if($table.sub)
baseMapper.delete${subClassName}DaoBy${subTableFkClassName}s(${pkColumn.javaField}s);
baseMapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
#end
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})
{
#if($table.sub)
baseMapper.delete${subClassName}DaoBy${subTableFkClassName}(${pkColumn.javaField});
baseMapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
#end
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)
{
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>
#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" />
</resultMap>
<resultMap type="${subClassName}Dao" id="${subClassName}DaoResult">
<resultMap type="${subClassName}Dao" id="${subClassName}Result">
#foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}" />
#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}
</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"/>
<where>
#foreach($column in $columns)
@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</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)
<include refid="select${ClassName}Vo"/>
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) {
String billNo = "";
long serialsize = 4;
//查询订单头
//
CodeRuleDefine codeRuleDefine = codeRuleDefineService.selectCodeRuleDefineByDefineId(0L);
if (codeRuleDefine.getDefHeader().isEmpty()) {
return AjaxResult.error("没有定义过ID为" + String.valueOf(0) + "的编号规则类型!");

Loading…
Cancel
Save