Commit 63821e7a authored by 赵啸非's avatar 赵啸非

修复部分sqlXml生成缺陷

parent 47daf42d
......@@ -84,7 +84,7 @@ public class LoginController extends BaseCRUDJsonController<UserService, UserFor
// }
userEntity = userService.doLogin(loginName, password, ip);
userEntity.setLastLoginAddress(ip);
saveCurrUser(request, response, userEntity);
// saveCurrUser(request, response, userEntity);
recordSysLog(request, userEntity, "用户登录系统成功!");
// 返回拥有的菜单数据
Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId());
......@@ -121,7 +121,7 @@ public class LoginController extends BaseCRUDJsonController<UserService, UserFor
@RequestMapping("logout")
public void logout(HttpServletRequest request, HttpServletResponse response) throws Exception {
recordSysLog(request, "退出登录");
super.removeCurrUser(request, response);
// super.removeCurrUser(request, response);
this.deleteBlackCookie(request, response);
}
......@@ -284,7 +284,7 @@ public class LoginController extends BaseCRUDJsonController<UserService, UserFor
}
}
@Override
// @Override
protected void saveCurrUser(HttpServletRequest request, HttpServletResponse response, IUser user, int maxAge) {
String securityKey = GlobalSysInfo.getPropertyValue(SysConstains.PROP_COOKIE_SECURITY_KEY);
String cookieDomain = GlobalSysInfo.getPropertyValue(SysConstains.PROP_COOKIE_DOMAIN);
......
......@@ -92,6 +92,8 @@ public class GentableColumnEntityExt extends BaseEntityLong {
if ("Long".equals(javaType)) {
if (ObjectUtils.isEmpty(defaultValue)) {
defaultValue = "null";
}else{
defaultValue= defaultValue+"L";
}
} else if ("Integer".equals(javaType)) {
if ("year".equals(columnName)) {
......@@ -107,11 +109,14 @@ public class GentableColumnEntityExt extends BaseEntityLong {
} else if ("String".equals(javaType)) {
if (ObjectUtils.isEmpty(defaultValue)) {
defaultValue = "\"\"";
}else{
defaultValue= "\""+defaultValue+"\"";
}
} else if ("BigDecimal".equals(javaType)) {
defaultValue = "BigDecimal.ZERO";
} else if ("Date".equals(javaType)) {
defaultValue = "new Date()";
// defaultValue = "new Date()";
defaultValue = "null";
} else {
defaultValue = "null";
}
......
......@@ -319,6 +319,7 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
Template template = FreeMarkerUtils.getTemplate(temp);
template.process(data, sw);
zip.putNextEntry(new ZipEntry(zipPath));
IOUtils.write(sw.toString(), zip, Constant.UTF8);
} catch (Exception e) {
log.error("异常", e);
......@@ -509,13 +510,13 @@ public class GentableServiceImpl extends AbstractCRUDServiceImpl<GentableDao, Ge
gentableEntity.getColumns().stream()
.filter(f -> f.getDict() != null)
.map(item -> {
Map enumData = FreeMarkerUtils.prepareSetFreeMarkerDataByEnum(item.getDict(), item.getColumnComment(), item.getColumnName(), item.getJavaType());
Map enumData = FreeMarkerUtils.prepareSetFreeMarkerDataByEnum(item.getDict(), item.getColumnComment(), item.getJavaField(), item.getJavaType());
try {
FreeMarkerUtils.initFreeMarker(genFreePath(temp));
StringWriter sw = new StringWriter();
Template template = FreeMarkerUtils.getTemplate(temp);
template.process(enumData, sw);
String enumFileName = FreeMarkerUtils.getEnumFileName(item.getColumnName());
String enumFileName = FreeMarkerUtils.getEnumFileName(item.getJavaField());
File file = new File(enumFileName);
if (file.exists()) {
return item;
......
......@@ -442,10 +442,6 @@ public class FreeMarkerUtils {
fileName = StringUtils.format("{}/{}/model/{}Query.java", javaPath, businessName, className);
}
// else if (template.contains("entityAndQuery.java.ftl")) {
// fileName = StringUtils.format("{}/{}/model/{}Entity.java", javaPath, businessName, className);
// }
else if (template.contains("dao.java.ftl")) {
fileName = StringUtils.format("{}/{}/dao/{}Dao.java", javaPath, businessName, className);
} else if (template.contains("daoImpl.java.ftl")) {
......
......@@ -64,7 +64,16 @@ public class GenUtils {
}
column.setQueryType("=");
// 设置java字段名
column.setJavaField(StrUtil.toCamelCase(columnName));
boolean upperCase = StrUtil.isUpperCase(columnName);
int i = StrUtil.indexOf(columnName, "_".charAt(0));
if(upperCase&&i==-1){
column.setJavaField(StrUtil.swapCase(columnName));
}else{
column.setJavaField(StrUtil.toCamelCase(columnName));
}
// 设置默认类型
column.setJavaType(GenConstants.TYPE_STRING);
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
......@@ -178,12 +187,18 @@ public class GenUtils {
temp = temp.replaceAll(";", ",");
String[] split = checkSplitStr(temp, ",");
if (split.length > 0) {
Arrays.asList(split).stream().peek(item -> {
HashMap<String, String> map = new HashMap<>();
map.put("num", item.trim());
map.put("value", item.trim());
//判断分割如果存在. 则分割成key value
String[] vals = checkSplitStr(item, ".");
if(vals.length>1){
map.put("num", vals[0].trim());
map.put("value", vals[1].trim());
}else{
map.put("num", item.trim());
map.put("value", item.trim());
}
if (ObjectUtils.isEmpty(column.getDict())) {
column.setDict(new ArrayList<>());
}
......@@ -380,5 +395,12 @@ public class GenUtils {
String name = "aaa";
System.out.println(Arrays.stream(name.split("_")).collect(Collectors.joining(".")));
System.out.println(Arrays.stream("data".split(".")).collect(Collectors.joining("/")));
String colName="TRIGGER_NAMEa";
System.out.println(StrUtil.isUpperCase(colName));
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1047,7 +1047,7 @@
"mock": "{}",
"mock_url": "${appInfo.path}/param/list",
"request": {
"url": "{{baseUrl}}${appInfo.path}/office/param/list",
"url": "{{baseUrl}}${appInfo.path}/param/list",
"description": "字典参数列表查询",
"event": {
"pre_script": "",
......@@ -1504,14 +1504,14 @@
"type":"integer",
"description":"当前页",
"mock":{
"mock":"@integer(1,10)"
"mock":"1"
}
},
"size":{
"type":"integer",
"description":"每页条数,值为-1,查询所有记录",
"mock":{
"mock":"@integer(-1,100)"
"mock":"20"
}
}
<#list table.columns as column>
......
......@@ -56,16 +56,15 @@ client.global.set("${ClassName}_id", JSON.parse(response.body).data.id);
%}
###${functionName}查看
GET {{baseUrl}}/${RequestMapping}/info?id={{${ClassName}_id}}
Accept: application/json
GET {{baseUrl}}/${RequestMapping}/info?id=1
###${functionName}编辑
GET {{baseUrl}}/${RequestMapping}/edit?id={{${ClassName}_id}}
GET {{baseUrl}}/${RequestMapping}/edit?id=1
Accept: application/json
###${functionName}删除
GET {{baseUrl}}/${RequestMapping}/delete?id={{${ClassName}_id}}
GET {{baseUrl}}/${RequestMapping}/delete?id=1
Authorization: {{authToken}}
Accept: application/json
......
......@@ -8,6 +8,8 @@ package ${packageName}.service.impl;
<#else >
<#assign Service = "AbstractCRUDServiceImpl">
</#if>
import org.springframework.beans.BeanUtils;
import java.util.function.Function;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.${Service};
import com.mortals.framework.exception.AppException;
......@@ -60,6 +62,26 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
<#if table.tplCategory=="sub">
@Autowired
private ${subClassName}Service ${subclassName}Service;
@Override
protected void findAfter(${ClassName}Entity params,PageInfo pageInfo, Context context, List<${ClassName}Entity> list) throws AppException {
fillSubData(list);
super.findAfter(params,pageInfo, context, list);
}
@Override
protected void findAfter(${ClassName}Entity params, Context context, List<${ClassName}Entity> list) throws AppException {
fillSubData(list);
super.findAfter(params, context, list);
}
private void fillSubData(List<${ClassName}Entity> list) {
List<${pkColumn.javaType}> idList = list.stream().map(i -> i.get${pkColumn.javaField?cap_first}()).collect(Collectors.toList());
${subClassName}Query ${subclassName}Query = new ${subClassName}Query();
${subclassName}Query.set${subTableFkClassName}List(idList);
Map<${pkColumn.javaType}, List<${subClassName}Entity>> ${subclassName}ListMap = ${subclassName}Service.find(${subclassName}Query).stream().collect(Collectors.groupingBy(${subClassName}Entity::get${subTableFkClassName}));
list.forEach(item -> item.set${subClassName}List(${subclassName}ListMap.get(item.get${pkColumn.javaField?cap_first}())));
}
${Temp}
@Override
protected void saveAfter(${ClassName}Entity entity, Context context) throws AppException {
......@@ -118,6 +140,27 @@ public class ${ClassName}ServiceImpl extends ${Service}<${ClassName}Dao, ${Class
<#elseif table.tplCategory=="subone">
@Autowired
private ${subClassName}Service ${subclassName}Service;
@Override
protected void findAfter(${ClassName}Entity params,PageInfo pageInfo, Context context, List<${ClassName}Entity> list) throws AppException {
fillSubData(list);
super.findAfter(params,pageInfo, context, list);
}
@Override
protected void findAfter(${ClassName}Entity params, Context context, List<${ClassName}Entity> list) throws AppException {
fillSubData(list);
super.findAfter(params, context, list);
}
private void fillSubData(List<${ClassName}Entity> list) {
List<${pkColumn.javaType}> idList = list.stream().map(i -> i.get${pkColumn.javaField?cap_first}()).collect(Collectors.toList());
if(ObjectUtils.isEmpty(idList)) return;
${subClassName}Query ${subclassName}Query = new ${subClassName}Query();
${subclassName}Query.set${subTableFkClassName}List(idList);
Map<${pkColumn.javaType}, ${subClassName}Entity> ${subclassName}Map = ${subclassName}Service.find(${subclassName}Query).stream().collect(Collectors.toMap(${subClassName}Entity::get${subTableFkClassName}, Function.identity(), (n1, n2) -> n1));
list.forEach(item -> item.set${subClassName}Entity(${subclassName}Map.get(item.get${pkColumn.javaField?cap_first}())));
}
${Temp}
@Override
protected void saveAfter(${ClassName}Entity entity, Context context) throws AppException {
......
......@@ -20,15 +20,15 @@
<result property="${column.javaField}" column="${column.columnName}" />
</#if>
</#list>
${SubArray}
<#-- ${SubArray}-->
</resultMap>
<#if table.tplCategory=="sub" ||table.tplCategory=="subone">
<#-- <#if table.tplCategory=="sub" ||table.tplCategory=="subone">
<resultMap type="${subClassName}Entity" id="${subClassName}Entity-Map">
<#list subTable.columns as column>
<result property="${column.javaField}" column="${column.columnName}" />
</#list>
</resultMap>
</#if>
</#if>-->
<#-- 判断是否分表,如果分表 则不指定表名 -->
<#if table.dividedTableType==0 >
......@@ -248,13 +248,13 @@
<#elseif subTableFkType=="String">
<#assign ParameterType>java.lang.String</#assign>
</#if>
<select id="get${subClassName}By${subTableFkClassName}" parameterType="${ParameterType}" resultMap="${subClassName}Entity-Map">
<#-- <select id="get${subClassName}By${subTableFkClassName}" parameterType="${ParameterType}" resultMap="${subClassName}Entity-Map">
select <include refid="_columns_sub"/>
from ${TempSubTable} as b
<trim suffixOverrides="where" suffix="">
where b.${subTableFkName} = <#noparse>#</#noparse>{${pkColumn.columnName}}
</trim>
</select>
</select>-->
</#if>
......@@ -313,6 +313,10 @@
<!-- 条件映射-代参数 -->
<sql id="_condition_param_">
<bind name="conditionParamRef" value="<#noparse>${_conditionParam_}</#noparse>"/>
<if test="permissionSql != null and permissionSql != ''">
<#noparse>${permissionSql}</#noparse>
</if>
<if test="conditionParamRef.containsKey('id')">
<if test="conditionParamRef.id != null">
<#noparse>${_conditionType_}</#noparse> a.${pkColumn.columnName}=<#noparse>#{${_conditionParam_}.id}</#noparse>
......
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