service 新增 getAndValid(entity) 替换 get(pkClass, pkValue, isNewRecord)

方法,为了更好支持复合主键和服务接口
This commit is contained in:
thinkgem
2020-03-08 00:50:26 +08:00
parent 8a7f73a7b8
commit b3d1d1b344
4 changed files with 17 additions and 6 deletions

View File

@@ -73,7 +73,10 @@ public class EmpUserController extends BaseController {
@ModelAttribute
public EmpUser get(String userCode, boolean isNewRecord) {
return empUserService.get(userCode, isNewRecord);
EmpUser empUser = new EmpUser();
empUser.setUserCode(userCode);
empUser.setIsNewRecord(isNewRecord);
return empUserService.getAndValid(empUser);
}
@RequiresPermissions("sys:empUser:view")

View File

@@ -63,8 +63,12 @@ public class ${ClassName}Controller extends BaseController {
<% if (table.pkList.~size == 1){ %>
return ${className}Service.get(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrName}<% } %>, isNewRecord);
<% }else{ %>
return ${className}Service.get(new Class<?>[]{<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType}.class<% } %>},
new Object[]{<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrName}<% } %>}, isNewRecord);
${ClassName} ${className} = new ${ClassName}();
<% for(pk in table.pkList){ %>
${className}.set${@StringUtils.cap(pk.simpleAttrName)}(${pk.simpleAttrName});
<% } %>
${className}.setIsNewRecord(isNewRecord);
return ${className}Service.getAndValid(${className});
<% } %>
}

View File

@@ -199,7 +199,7 @@ public class ${ClassName} extends ${table.isTreeEntity?'Tree':'Data'}Entity<${Cl
%>
public ${ClassName}() {
this(null);
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
}
<%

View File

@@ -61,8 +61,12 @@ public class ${ClassName}Controller extends BaseController {
<% if (table.pkList.~size == 1){ %>
return ${className}Service.get(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrName}<% } %>, isNewRecord);
<% }else{ %>
return ${className}Service.get(new Class<?>[]{<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrType}.class<% } %>},
new Object[]{<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}${pk.simpleAttrName}<% } %>}, isNewRecord);
${ClassName} ${className} = new ${ClassName}();
<% for(pk in table.pkList){ %>
${className}.set${@StringUtils.cap(pk.simpleAttrName)}(${pk.simpleAttrName});
<% } %>
${className}.setIsNewRecord(isNewRecord);
return ${className}Service.getAndValid(${className});
<% } %>
}