Commit 7bd44234 by fengshuonan

修复代码生成的一处bug

parent cbd69429
...@@ -104,8 +104,9 @@ public class GunsMpVelocityTemplateEngine extends VelocityTemplateEngine { ...@@ -104,8 +104,9 @@ public class GunsMpVelocityTemplateEngine extends VelocityTemplateEngine {
if (customMap != null && customMap.containsKey(tableInfo.getName())) { if (customMap != null && customMap.containsKey(tableInfo.getName())) {
//将字段转化成驼峰式的属性 //将字段转化成驼峰式的属性
List<String> camelFields = FieldUtil.getCamelFields(customMap.get(tableInfo.getName()), tableInfo.getFields()); List<Map<String, Object>> camelFields = FieldUtil.getCamelFieldsUnderLine(customMap.get(tableInfo.getName()), tableInfo.getFields());
objectMap.put("mapperConditions", camelFields); objectMap.put("mapperConditions", camelFields);
} }
return objectMap; return objectMap;
......
...@@ -3,7 +3,9 @@ package cn.stylefeng.guns.generator.core.util; ...@@ -3,7 +3,9 @@ package cn.stylefeng.guns.generator.core.util;
import com.baomidou.mybatisplus.generator.config.po.TableField; import com.baomidou.mybatisplus.generator.config.po.TableField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 字段转化工具类 * 字段转化工具类
...@@ -21,9 +23,9 @@ public class FieldUtil { ...@@ -21,9 +23,9 @@ public class FieldUtil {
* @author fengshuonan * @author fengshuonan
* @Date 2019/5/7 22:14 * @Date 2019/5/7 22:14
*/ */
public static List<String> getCamelFields(String[] underlineFields, List<TableField> tableFields) { public static List<Map<String, Object>> getCamelFieldsUnderLine(String[] underlineFields, List<TableField> tableFields) {
ArrayList<String> newFields = new ArrayList<>(); ArrayList<Map<String, Object>> newFields = new ArrayList<>();
if (underlineFields.length <= 0 || tableFields == null) { if (underlineFields.length <= 0 || tableFields == null) {
return newFields; return newFields;
...@@ -31,7 +33,12 @@ public class FieldUtil { ...@@ -31,7 +33,12 @@ public class FieldUtil {
for (String underlineField : underlineFields) { for (String underlineField : underlineFields) {
for (TableField tableField : tableFields) { for (TableField tableField : tableFields) {
if (underlineField.equals(tableField.getName())) { if (underlineField.equals(tableField.getName())) {
newFields.add(tableField.getPropertyName());
HashMap<String, Object> field = new HashMap<>();
field.put("fieldUnderline", underlineField);
field.put("fieldCamel", tableField.getPropertyName());
newFields.add(field);
} }
} }
} }
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from ${table.name} where 1 = 1 from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions}) #foreach($field in ${mapperConditions})
<if test="paramCondition.${field} != null and paramCondition.${field} != ''"> <if test="paramCondition.${field.fieldCamel} != null and paramCondition.${field.fieldCamel} != ''">
and ${field} like CONCAT('%',#{paramCondition.${field}},'%') and ${field.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel}},'%')
</if> </if>
#end #end
</select> </select>
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from ${table.name} where 1 = 1 from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions}) #foreach($field in ${mapperConditions})
<if test="paramCondition.${field} != null and paramCondition.${field} != ''"> <if test="paramCondition.${field.fieldCamel} != null and paramCondition.${field.fieldCamel} != ''">
and ${field} like CONCAT('%',#{paramCondition.${field}},'%') and ${field.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel}},'%')
</if> </if>
#end #end
</select> </select>
...@@ -61,9 +61,9 @@ ...@@ -61,9 +61,9 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from ${table.name} where 1 = 1 from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions}) #foreach($field in ${mapperConditions})
<if test="paramCondition.${field} != null and paramCondition.${field} != ''"> <if test="paramCondition.${field.fieldCamel} != null and paramCondition.${field.fieldCamel} != ''">
and ${field} like CONCAT('%',#{paramCondition.${field}},'%') and ${field.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel}},'%')
</if> </if>
#end #end
</select> </select>
...@@ -72,8 +72,8 @@ ...@@ -72,8 +72,8 @@
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from ${table.name} where 1 = 1 from ${table.name} where 1 = 1
#foreach($field in ${mapperConditions}) #foreach($field in ${mapperConditions})
<if test="paramCondition.${field} != null and paramCondition.${field} != ''"> <if test="paramCondition.${field.fieldCamel} != null and paramCondition.${field.fieldCamel} != ''">
and ${field} like CONCAT('%',#{paramCondition.${field}},'%') and ${field.fieldUnderline} like CONCAT('%',#{paramCondition.${field.fieldCamel}},'%')
</if> </if>
#end #end
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment