提交 230a7b52 编写于 作者: sq3536's avatar sq3536

函数方式转换

上级 a03c228b
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
<dependency> <dependency>
<groupId>net.ibizsys.model</groupId> <groupId>net.ibizsys.model</groupId>
<artifactId>ibiz-model</artifactId> <artifactId>ibiz-model</artifactId>
<version>0.2.3</version> <version>0.2.4</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
......
...@@ -28,5 +28,9 @@ public class ApiEntityModel extends BaseModel{ ...@@ -28,5 +28,9 @@ public class ApiEntityModel extends BaseModel{
private ApiModel api; private ApiModel api;
public EntityModel getEntity()
{
return api.getSystem().getEntity(getApiDataEntity().getPSDataEntity().getCodeName());
}
} }
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.StringAdvUtils;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
...@@ -40,6 +41,24 @@ public class AppEntityModel extends BaseModel{ ...@@ -40,6 +41,24 @@ public class AppEntityModel extends BaseModel{
return this; return this;
} }
public EntityModel getEntity()
{
return app.getSystem().getEntity(getAppDataEntity().getPSDataEntity().getCodeName());
}
public String getServiceId()
{
String sybSysServiceType="DEFAULT";
if(getEntity().getDataEntity().getPSSubSysServiceAPI()!=null)
sybSysServiceType=getEntity().getDataEntity().getPSSubSysServiceAPI().getServiceType();
if(getEntity().getDataEntity().getStorageMode()==4 && (!"MIDDLEPLATFORM".equals(sybSysServiceType)) && (!"MASA".equals(sybSysServiceType)))
return getEntity().getDataEntity().getPSSubSysServiceAPI().getServiceCodeName();
else if (getAppDataEntity().getPSSysServiceAPI()!=null)
return app.getSystem().getProjectName()+"-"+ getAppDataEntity().getPSSysServiceAPI().getCodeName().toLowerCase();
else
return null;
}
public Collection<CtrlModel> getCtrls() public Collection<CtrlModel> getCtrls()
{ {
return ctrlsMap.values(); return ctrlsMap.values();
......
...@@ -66,7 +66,7 @@ public class CliOption extends DataObj ...@@ -66,7 +66,7 @@ public class CliOption extends DataObj
} }
public String getProjectName(){ public String getProjectName(){
return this.getStringValue(CodegenConstants.PROJECT_NAME,this.getStringValue("system_id",this.getStringValue("system",this.getStringValue("system_name")))); return this.getStringValue(CodegenConstants.PROJECT_NAME,"");
} }
public CliOption setProjectName(String projectName) public CliOption setProjectName(String projectName)
...@@ -74,6 +74,10 @@ public class CliOption extends DataObj ...@@ -74,6 +74,10 @@ public class CliOption extends DataObj
return this.set(CodegenConstants.PROJECT_NAME,projectName); return this.set(CodegenConstants.PROJECT_NAME,projectName);
} }
public String getProjectDesc(){
return this.getStringValue(CodegenConstants.PROJECT_DESC,getProjectName());
}
public CliOption setProjectDesc(String projectDesc) public CliOption setProjectDesc(String projectDesc)
{ {
return this.set(CodegenConstants.PROJECT_DESC,projectDesc); return this.set(CodegenConstants.PROJECT_DESC,projectDesc);
......
...@@ -61,7 +61,12 @@ public class ModelStorage { ...@@ -61,7 +61,12 @@ public class ModelStorage {
IPSSystem iPSSystem = psModelService.getPSSystem(); IPSSystem iPSSystem = psModelService.getPSSystem();
systemModel = new SystemModel(iPSSystem); systemModel = new SystemModel(iPSSystem);
Assert.notNull(iPSSystem,"加载系统模型错误:"+strPSModelFolderPath); Assert.notNull(iPSSystem,"加载系统模型错误:"+strPSModelFolderPath);
if(!StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_NAME)))
systemModel.setProjectName(config.getAdditionalProperties().get(CodegenConstants.PROJECT_NAME).toString());
if(!StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_DESC)))
systemModel.setProjectDesc(config.getAdditionalProperties().get(CodegenConstants.PROJECT_DESC).toString());
if(!StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PACKAGE_NAME)))
systemModel.setPackageName(config.getAdditionalProperties().get(CodegenConstants.PACKAGE_NAME).toString());
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("加载系统模型错误"+strPSModelFolderPath,e); throw new RuntimeException("加载系统模型错误"+strPSModelFolderPath,e);
...@@ -78,13 +83,9 @@ public class ModelStorage { ...@@ -78,13 +83,9 @@ public class ModelStorage {
CliOption opt=new CliOption(); CliOption opt=new CliOption();
opt.putAll(config.getAdditionalProperties()); opt.putAll(config.getAdditionalProperties());
opt.setTemplateFileType(type); opt.setTemplateFileType(type);
SystemModel systemModel=getSystemModel(); SystemModel systemModel=getSystemModel();
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_NAME)))
opt.setProjectName(systemModel.getProjectName()); opt.setProjectName(systemModel.getProjectName());
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PROJECT_DESC)))
opt.setProjectDesc(systemModel.getProjectDesc()); opt.setProjectDesc(systemModel.getProjectDesc());
if(StringUtils.isEmpty(config.getAdditionalProperties().get(CodegenConstants.PACKAGE_NAME)))
opt.setPackageName(systemModel.getPackageName()); opt.setPackageName(systemModel.getPackageName());
opt.set("system",systemModel); opt.set("system",systemModel);
return opt; return opt;
......
...@@ -51,12 +51,16 @@ public class SystemModel extends BaseModel { ...@@ -51,12 +51,16 @@ public class SystemModel extends BaseModel {
{ {
this.setCodeName(this.pub.getCodeName()); this.setCodeName(this.pub.getCodeName());
this.setName(this.pub.getName()); this.setName(this.pub.getName());
this.setProjectName(this.pub.getCodeName().toLowerCase());
this.setProjectDesc(this.pub.getName());
this.setPackageName(this.pub.getPKGCodeName()); this.setPackageName(this.pub.getPKGCodeName());
} }
else else
{ {
this.setCodeName(system.getCodeName()); this.setCodeName(system.getCodeName());
this.setName(system.getName()); this.setName(system.getName());
this.setProjectName(system.getCodeName().toLowerCase());
this.setProjectDesc(system.getName());
this.setPackageName(system.getCodeName().toLowerCase()); this.setPackageName(system.getCodeName().toLowerCase());
} }
getEntitiesMap(); getEntitiesMap();
...@@ -67,20 +71,15 @@ public class SystemModel extends BaseModel { ...@@ -67,20 +71,15 @@ public class SystemModel extends BaseModel {
return (IPSSystem)opt; return (IPSSystem)opt;
} }
public String getProjectName() private String projectName;
{
return this.codeName.toLowerCase();
}
public String getProjectDesc() private String projectDesc;
{
return this.name;
}
private String packageName; private String packageName;
private boolean enableDS=false; private boolean enableDS=false;
private boolean enableES=false; private boolean enableES=false;
private boolean enableMongo=false;
private boolean enableMQ=false; private boolean enableMQ=false;
private boolean enableOAuth2=false; private boolean enableOAuth2=false;
private boolean enableGlobalTransaction=false; private boolean enableGlobalTransaction=false;
...@@ -89,6 +88,7 @@ public class SystemModel extends BaseModel { ...@@ -89,6 +88,7 @@ public class SystemModel extends BaseModel {
private boolean enableDameng=false; private boolean enableDameng=false;
private boolean enablePostgreSQL=false; private boolean enablePostgreSQL=false;
private boolean enableDyna=false; private boolean enableDyna=false;
private boolean enableWorkflow=false;
private IPSSysSFPub pub; private IPSSysSFPub pub;
...@@ -99,6 +99,10 @@ public class SystemModel extends BaseModel { ...@@ -99,6 +99,10 @@ public class SystemModel extends BaseModel {
getSystem().getAllPSDataEntities().forEach(entity -> { getSystem().getAllPSDataEntities().forEach(entity -> {
if((entity.getStorageMode()==1 || entity.getStorageMode()==2) && "DEFAULT".equals(entity.getDSLink())) if((entity.getStorageMode()==1 || entity.getStorageMode()==2) && "DEFAULT".equals(entity.getDSLink()))
enableDS=true; enableDS=true;
if(entity.getStorageMode()==2)
enableMongo=true;
if(ObjectUtils.isEmpty(entity.getAllPSDEWFs()))
enableWorkflow=true;
if("elasticsearch".equalsIgnoreCase(entity.getUserTag())) if("elasticsearch".equalsIgnoreCase(entity.getUserTag()))
enableES=true; enableES=true;
if(!ObjectUtils.isEmpty(entity.getAllPSDEDataSyncs())) if(!ObjectUtils.isEmpty(entity.getAllPSDEDataSyncs()))
......
...@@ -57,7 +57,12 @@ public class TemplateDefinition { ...@@ -57,7 +57,12 @@ public class TemplateDefinition {
while (m.find()) { while (m.find()) {
String[] pairs=m.group(1).split("@"); String[] pairs=m.group(1).split("@");
if(type.name().equalsIgnoreCase(pairs[0]) if(type.name().equalsIgnoreCase(pairs[0])
||type.value().equalsIgnoreCase(pairs[0])) { ||type.value().equalsIgnoreCase(pairs[0])
||type.name().endsWith(" "+pairs[0])
||type.value().endsWith(" "+pairs[0])
||type.name().startsWith(pairs[0]+".")
||type.value().startsWith(pairs[0]+".")
) {
if(pairs.length>1&&(!StringUtils.isEmpty(pairs[1]))) if(pairs.length>1&&(!StringUtils.isEmpty(pairs[1])))
this.setSubType(pairs[1]); this.setSubType(pairs[1]);
return type; return type;
......
...@@ -153,6 +153,8 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor { ...@@ -153,6 +153,8 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor {
@Override @Override
public File write(Map<String, Object> data, String template, File target) throws IOException { public File write(Map<String, Object> data, String template, File target) throws IOException {
String templateContent = this.engineAdapter.compileTemplate(this, data, template); String templateContent = this.engineAdapter.compileTemplate(this, data, template);
if(StringUtils.isEmpty(templateContent))
return null;
return writeToFile(target.getPath(), templateContent); return writeToFile(target.getPath(), templateContent);
} }
......
...@@ -2,6 +2,7 @@ package cn.ibizlab.codegen.templating.mustache; ...@@ -2,6 +2,7 @@ package cn.ibizlab.codegen.templating.mustache;
import cn.ibizlab.codegen.CodegenConfig; import cn.ibizlab.codegen.CodegenConfig;
import cn.ibizlab.codegen.utils.Inflector; import cn.ibizlab.codegen.utils.Inflector;
import cn.ibizlab.codegen.utils.StringAdvUtils;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template; import com.samskivert.mustache.Template;
...@@ -35,7 +36,7 @@ public class PluralizeLambda implements Mustache.Lambda { ...@@ -35,7 +36,7 @@ public class PluralizeLambda implements Mustache.Lambda {
@Override @Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException { public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String text = Inflector.getInstance().pluralize(fragment.execute()); String text = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(fragment.execute()));
writer.write(text); writer.write(text);
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
{{>(lookup 'SUMMARYCOLUMN') item=column ctrl=ctrl}} {{>(lookup 'SUMMARYCOLUMN') item=column ctrl=ctrl}}
{{/each}} {{/each}}
{{else}} {{else}}
<a-table-summary-cell>\{{state.dataAgg}}.{{item.codeName.lowerCase}}</a-table-summary-cell> <a-table-summary-cell>\{{state.dataAgg}}.{{lowerCase item.codeName}}</a-table-summary-cell>
{{/eq}} {{/eq}}
import {{page.codeName}} from "./{{page.codeName.spinalCase}}.vue"; import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} }; export { {{page.codeName}} };
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
import { Subject } from 'rxjs' import { Subject } from 'rxjs'
import { Ref } from 'vue'; import { Ref } from 'vue';
import { IndexView, IActionParam, IParam } from '@ibiz-core'; import { IndexView, IActionParam, IParam } from '@ibiz-core';
import { ViewConfig } from './{{page.codeName.spinalCase}}-config'; import { ViewConfig } from './{{spinalCase page.codeName}}-config';
{{#page.ctrls}} {{#page.ctrls}}
{{#eq controlType "APPMENU"}} {{#eq controlType "APPMENU"}}
import { {{codeName}}Menu } from '@widgets/app/{{codeName.spinalCase}}-menu'; import { {{codeName}}Menu } from '@widgets/app/{{spinalCase codeName}}-menu';
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
import { import {
......
import {{page.codeName}} from "./{{page.codeName.spinalCase}}.vue"; import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} }; export { {{page.codeName}} };
<script setup lang="ts"> <script setup lang="ts">
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { EditView, IActionParam, IParam } from '@ibiz-core'; import { EditView, IActionParam, IParam } from '@ibiz-core';
import { ViewConfig } from './{{page.codeName.spinalCase}}-config'; import { ViewConfig } from './{{spinalCase page.codeName}}-config';
{{#page.ctrls}} {{#page.ctrls}}
{{#eq controlType "FORM"}} {{#eq controlType "FORM"}}
import { {{codeName}}Form } from '@widgets/{{appEntity.codeName.spinalCase}}/{{codeName.spinalCase}}-form'; import { {{codeName}}Form } from '@widgets/{{spinalCase appEntity.codeName}}/{{spinalCase codeName}}-form';
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
......
import {{page.codeName}} from "./{{page.codeName.spinalCase}}.vue"; import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export { {{page.codeName}} }; export { {{page.codeName}} };
<script setup lang="ts"> <script setup lang="ts">
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { GridView, IActionParam, IParam } from '@ibiz-core'; import { GridView, IActionParam, IParam } from '@ibiz-core';
import { ViewConfig } from './{{page.codeName.spinalCase}}-config'; import { ViewConfig } from './{{spinalCase page.codeName}}-config';
{{#page.ctrls}} {{#page.ctrls}}
{{#eq controlType "GRID"}} {{#eq controlType "GRID"}}
import { {{codeName}}Grid } from '@widgets/{{appEntity.codeName.spinalCase}}/{{codeName.spinalCase}}-grid'; import { {{codeName}}Grid } from '@widgets/{{spinalCase appEntity.codeName}}/{{spinalCase codeName}}-grid';
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
......
...@@ -44,7 +44,7 @@ const routes = [ ...@@ -44,7 +44,7 @@ const routes = [
{ pathName: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}", parameterName: "{{lowerCase codeName}}" }, { pathName: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}", parameterName: "{{lowerCase codeName}}" },
{ pathName: 'views', parameterName: 'view' }, { pathName: 'views', parameterName: 'view' },
], ],
resource: "{{entity.codeName.lowerCase}}", resource: "{{lowerCase entity.codeName}}",
requireAuth: false, requireAuth: false,
}, },
component: () => import("@page/{{#if appView.psAppDataEntity}}{{spinalCase appView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}/{{spinalCase appView.codeName}}.vue"), component: () => import("@page/{{#if appView.psAppDataEntity}}{{spinalCase appView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}/{{spinalCase appView.codeName}}.vue"),
...@@ -68,7 +68,7 @@ const routes = [ ...@@ -68,7 +68,7 @@ const routes = [
{ pathName: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}", parameterName: "{{lowerCase appView.psAppDataEntity.codeName}}" }, { pathName: "{{lowerCase (pluralize appView.psAppDataEntity.codeName)}}", parameterName: "{{lowerCase appView.psAppDataEntity.codeName}}" },
{ pathName: 'views', parameterName: 'view' }, { pathName: 'views', parameterName: 'view' },
], ],
resource: "{{entity.codeName.lowerCase}}", resource: "{{lowerCase entity.codeName}}",
requireAuth: false, requireAuth: false,
}, },
component: () => import("@page/{{#if appView.psAppDataEntity}}{{spinalCase appView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}/{{spinalCase appView.codeName}}.vue"), component: () => import("@page/{{#if appView.psAppDataEntity}}{{spinalCase appView.psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}/{{spinalCase appView.codeName}}.vue"),
......
...@@ -4,20 +4,20 @@ import { Http, EntityService } from '@ibiz-core'; ...@@ -4,20 +4,20 @@ import { Http, EntityService } from '@ibiz-core';
* {{appEntity.logicName}}服务对象基类 * {{appEntity.logicName}}服务对象基类
* *
* @export * @export
* @class {{appEntity.codeName.pascalCase}} * @class {{pascalCase appEntity.codeName}}
* @extends {EntityBaseService} * @extends {EntityBaseService}
*/ */
export class {{appEntity.codeName.pascalCase}}ServiceBase extends EntityService { export class {{pascalCase appEntity.codeName}}ServiceBase extends EntityService {
constructor(opts?: any) { constructor(opts?: any) {
super(opts); super(opts);
} }
protected APPDENAME = "{{appEntity.codeName.pascalCase}}"; protected APPDENAME = "{{pascalCase appEntity.codeName}}";
{{#eq appEntity.keyPSAppDEField.codeName.lowerCase}} {{#if appEntity.keyPSAppDEField}}
protected APPDEKEY = "{{appEntity.keyPSAppDEField.codeName.pascalCase}}"; protected APPDEKEY = "{{pascalCase appEntity.keyPSAppDEField.codeName}}";
{{/eq}} {{/if}}
{{#each appEntity.allPSAppDEMethods as |singleAppMethod| }} {{#each appEntity.allPSAppDEMethods as |singleAppMethod| }}
...@@ -27,36 +27,36 @@ export class {{appEntity.codeName.pascalCase}}ServiceBase extends EntityService ...@@ -27,36 +27,36 @@ export class {{appEntity.codeName.pascalCase}}ServiceBase extends EntityService
* @param {*} [_context={}] * @param {*} [_context={}]
* @param {*} [_data = {}] * @param {*} [_data = {}]
* @returns {Promise<any>} * @returns {Promise<any>}
* @memberof {{appEntity.codeName.pascalCase}}ServiceBase * @memberof {{pascalCase appEntity.codeName}}ServiceBase
*/ */
async {{singleAppMethod.codeName}}(_context: any = {}, _data: any = {}): Promise<any> { async {{singleAppMethod.codeName}}(_context: any = {}, _data: any = {}): Promise<any> {
//{{singleAppMethod}} //{{singleAppMethod}}
//{{singleAppMethod.psDEServiceAPIMethod}} //{{singleAppMethod.psDEServiceAPIMethod}}
//{{singleAppMethod.psDEServiceAPIMethod.requestMethod}} //{{singleAppMethod.psDEServiceAPIMethod.requestMethod}}
{{#eq singleAppMethod.methodType "SELECT" }} {{#eq singleAppMethod.methodType "SELECT" }}
const res = await this.http.post(`/{{appEntity.codeName.pluralize}}/${encodeURIComponent(_context.{{appEntity.codeName.lowerCase}})}{{singleAppMethod.requestPath}}`, _data); const res = await this.http.post(`/{{pluralize appEntity.codeName}}/${encodeURIComponent(_context.{{lowerCase appEntity.codeName}})}{{singleAppMethod.requestPath}}`, _data);
return res; return res;
{{/eq}} {{/eq}}
{{#eq singleAppMethod.methodType "FETCH" }} {{#eq singleAppMethod.methodType "FETCH" }}
const res = await this.http.post(`/{{appEntity.codeName.pluralize}}/${encodeURIComponent(_context.{{appEntity.codeName.lowerCase}})}{{singleAppMethod.requestPath}}`, _data); const res = await this.http.post(`/{{pluralize appEntity.codeName}}/${encodeURIComponent(_context.{{lowerCase appEntity.codeName}})}{{singleAppMethod.requestPath}}`, _data);
return res; return res;
{{/eq}} {{/eq}}
{{#eq singleAppMethod.methodType "GET" }} {{#eq singleAppMethod.methodType "GET" }}
const res = await this.http.get(`/{{appEntity.codeName.pluralize}}/${encodeURIComponent(_context.{{appEntity.codeName.lowerCase}})}{{singleAppMethod.requestPath}}`); const res = await this.http.get(`/{{pluralize appEntity.codeName}}/${encodeURIComponent(_context.{{lowerCase appEntity.codeName}})}{{singleAppMethod.requestPath}}`);
return res; return res;
{{/eq}} {{/eq}}
{{#eq singleAppMethod.codeName "GetDraft" }} {{#eq singleAppMethod.codeName "GetDraft" }}
_data[this.APPDENAME?.toLowerCase()] = undefined; _data[this.APPDENAME?.toLowerCase()] = undefined;
_data[this.APPDEKEY] = undefined; _data[this.APPDEKEY] = undefined;
const res = await this.http.post(`/{{appEntity.codeName.pluralize}}/${encodeURIComponent(_context.{{appEntity.codeName.lowerCase}})}{{singleAppMethod.requestPath}}`, _data); const res = await this.http.post(`/{{pluralize appEntity.codeName}}/${encodeURIComponent(_context.{{lowerCase appEntity.codeName}})}{{singleAppMethod.requestPath}}`, _data);
return res; return res;
{{/eq}} {{/eq}}
{{#eq singleAppMethod.codeName "Update" }} {{#eq singleAppMethod.codeName "Update" }}
const res = await this.http.post(`/{{appEntity.codeName.pluralize}}/${encodeURIComponent(_context.{{appEntity.codeName.lowerCase}})}{{singleAppMethod.requestPath}}`, _data); const res = await this.http.post(`/{{pluralize appEntity.codeName}}/${encodeURIComponent(_context.{{lowerCase appEntity.codeName}})}{{singleAppMethod.requestPath}}`, _data);
return res; return res;
{{/eq}} {{/eq}}
{{#eq singleAppMethod.codeName "Get" }} {{#eq singleAppMethod.codeName "Get" }}
const res = await this.http.get(`/{{appEntity.codeName.pluralize}}/${encodeURIComponent(_context.{{appEntity.codeName.lowerCase}})}{{singleAppMethod.requestPath}}`, _data); const res = await this.http.get(`/{{pluralize appEntity.codeName}}/${encodeURIComponent(_context.{{lowerCase appEntity.codeName}})}{{singleAppMethod.requestPath}}`, _data);
return res; return res;
{{/eq}} {{/eq}}
......
import { {{appEntity.codeName.pascalCase}}ServiceBase } from './{{appEntity.codeName.spinalCase}}-service-base'; import { {{pascalCase appEntity.codeName}}ServiceBase } from './{{spinalCase appEntity.codeName}}-service-base';
/** /**
* ${appEntity.getLogicName()}服务 * ${appEntity.getLogicName()}服务
* *
* @export * @export
* @class {{appEntity.codeName.pascalCase}}Service * @class {{pascalCase appEntity.codeName}}Service
* @extends {{appEntity.codeName.pascalCase}}ServiceBase * @extends {{pascalCase appEntity.codeName}}ServiceBase
*/ */
export class {{appEntity.codeName.pascalCase}}Service extends {{appEntity.codeName.pascalCase}}ServiceBase { export class {{pascalCase appEntity.codeName}}Service extends {{pascalCase appEntity.codeName}}ServiceBase {
/** /**
* Creates an instance of {{appEntity.codeName.pascalCase}}Service. * Creates an instance of {{pascalCase appEntity.codeName}}Service.
* @memberof {{appEntity.codeName.pascalCase}}Service * @memberof {{pascalCase appEntity.codeName}}Service
*/ */
constructor(opts?: any) { constructor(opts?: any) {
{{!-- const { context: context, tag: cacheKey } = opts; --}} {{!-- const { context: context, tag: cacheKey } = opts; --}}
...@@ -22,11 +22,11 @@ export class {{appEntity.codeName.pascalCase}}Service extends {{appEntity.codeNa ...@@ -22,11 +22,11 @@ export class {{appEntity.codeName.pascalCase}}Service extends {{appEntity.codeNa
* *
* @static * @static
* @param 应用上下文 * @param 应用上下文
* @return {*} { {{appEntity.codeName.pascalCase}}Service } * @return {*} { {{pascalCase appEntity.codeName}}Service }
* @memberof {{appEntity.codeName.pascalCase}}Service * @memberof {{pascalCase appEntity.codeName}}Service
*/ */
static getInstance(context?: any): {{appEntity.codeName.pascalCase}}Service { static getInstance(context?: any): {{pascalCase appEntity.codeName}}Service {
return new {{appEntity.codeName.pascalCase}}Service({ context: context }); return new {{pascalCase appEntity.codeName}}Service({ context: context });
} }
} }
export default {{appEntity.codeName.pascalCase}}Service; export default {{pascalCase appEntity.codeName}}Service;
\ No newline at end of file \ No newline at end of file
import {{ctrl.codeName}}Menu from "./{{ctrl.codeName.spinalCase}}-menu.vue"; import {{ctrl.codeName}}Menu from "./{{spinalCase ctrl.codeName}}-menu.vue";
export { {{ctrl.codeName}}Menu }; export { {{ctrl.codeName}}Menu };
<script setup lang="ts"> <script setup lang="ts">
import { Subject } from "rxjs"; import { Subject } from "rxjs";
import { CtrlConfig } from "./{{ctrl.codeName.spinalCase}}-menu-config"; import { CtrlConfig } from "./{{spinalCase ctrl.codeName}}-menu-config";
import { IParam, IActionParam, MenuControl } from "@ibiz-core"; import { IParam, IActionParam, MenuControl } from "@ibiz-core";
interface Props{ interface Props{
context: IParam; context: IParam;
......
import {{ctrl.codeName}}Form from "./{{ctrl.codeName.spinalCase}}-form.vue"; import {{ctrl.codeName}}Form from "./{{spinalCase ctrl.codeName}}-form.vue";
export { {{ctrl.codeName}}Form }; export { {{ctrl.codeName}}Form };
import { ControlVOBase } from '@ibiz-core'; import { ControlVOBase } from '@ibiz-core';
import { ControlService } from './{{ctrl.codeName.lowerCase}}-form-service'; import { ControlService } from './{{lowerCase ctrl.codeName}}-form-service';
export const CtrlConfig = { export const CtrlConfig = {
controlCodeName: '{{ctrl.codeName}}', controlCodeName: '{{ctrl.codeName}}',
......
import { ControlServiceBase } from '@ibiz-core'; import { ControlServiceBase } from '@ibiz-core';
import { {{pascalCase ctrl.psAppDataEntity.codeName}}Service } from '@service/{{spinalCase ctrl.psAppDataEntity.codeName}}/{{spinalCase ctrl.psAppDataEntity.codeName}}-service'; import { {{pascalCase ctrl.psAppDataEntity.codeName}}Service } from '@service/{{spinalCase ctrl.psAppDataEntity.codeName}}/{{spinalCase ctrl.psAppDataEntity.codeName}}-service';
import { ControlVO } from './{{ctrl.codeName.lowerCase}}-form-config'; import { ControlVO } from './{{lowerCase ctrl.codeName}}-form-config';
export class ControlService extends ControlServiceBase { export class ControlService extends ControlServiceBase {
......
{{>@macro/form-detail/include-form.hbs}} {{>@macro/form-detail/include-form.hbs}}
<script setup lang="ts"> <script setup lang="ts">
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { CtrlConfig } from './{{ctrl.codeName.spinalCase}}-form-config'; import { CtrlConfig } from './{{spinalCase ctrl.codeName}}-form-config';
import { FormControl, IActionParam, IParam, ControlAction } from '@ibiz-core'; import { FormControl, IActionParam, IParam, ControlAction } from '@ibiz-core';
interface Props { interface Props {
......
import {{ctrl.codeName}}Grid from "./{{ctrl.codeName.spinalCase}}-grid.vue"; import {{ctrl.codeName}}Grid from "./{{spinalCase ctrl.codeName}}-grid.vue";
export { {{ctrl.codeName}}Grid }; export { {{ctrl.codeName}}Grid };
{{>@macro/grid-detail/include-grid.hbs}} {{>@macro/grid-detail/include-grid.hbs}}
<script setup lang="ts"> <script setup lang="ts">
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { CtrlConfig } from './{{ctrl.codeName.spinalCase}}-grid-config'; import { CtrlConfig } from './{{spinalCase ctrl.codeName}}-grid-config';
import { GridControl, IActionParam, IParam, ControlAction } from '@ibiz-core'; import { GridControl, IActionParam, IParam, ControlAction } from '@ibiz-core';
interface Props { interface Props {
......
{{#eq system.saaSMode 4}}
package {{packageName}}.{{apps}}.config;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class {{app.codeName}}HeaderFilter extends ZuulFilter {
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 0;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() throws ZuulException {
RequestContext ctx = RequestContext.getCurrentContext();
ctx.addZuulRequestHeader("srfsystem", "{{system.codeName}}");
return null;
}
}
{{/eq}}
\ No newline at end of file
package {{packageName}}.{{apps}}.config;
import {{packageName}}.util.security.AuthenticationEntryPoint;
import {{packageName}}.util.security.AuthorizationTokenFilter;
import {{packageName}}.util.service.AuthenticationUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.core.GrantedAuthorityDefaults;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.context.annotation.Profile;
import org.springframework.beans.factory.annotation.Qualifier;
@Profile("{{apps}}-prod")
@Configuration
@EnableWebSecurity
public class {{app.codeName}}SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthenticationEntryPoint unauthorizedHandler;
@Autowired
private AuthenticationUserService userDetailsService;
/**
* 自定义基于JWT的安全过滤器
*/
@Autowired
AuthorizationTokenFilter authenticationTokenFilter;
@Value("${ibiz.auth.path:v7/login}"})
private String loginPath;
@Value("${ibiz.auth.logoutpath:v7/logout}"})
private String logoutPath;
@Value("${ibiz.file.uploadpath:ibizutil/upload}"})
private String uploadpath;
@Value("${ibiz.file.downloadpath:ibizutil/download}"})
private String downloadpath;
@Value("${ibiz.file.previewpath:ibizutil/preview}"})
private String previewpath;
@Value("${ibiz.auth.excludesPattern:}"})
private String[] excludesPattern;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoderBean());
}
@Bean
GrantedAuthorityDefaults grantedAuthorityDefaults() {
// Remove the ROLE_ prefix
return new GrantedAuthorityDefaults("");
}
@Bean
public PasswordEncoder passwordEncoderBean() {
return new BCryptPasswordEncoder();
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
// 禁用 CSRF
.csrf().disable()
// 授权异常
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
// 不创建会话
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
// 过滤请求
.authorizeRequests()
.antMatchers(
HttpMethod.GET,
"/*.html",
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.ico",
"/**/assets/**",
"/**/css/**",
"/**/fonts/**",
"/**/js/**",
"/**/img/**",
"/**/svg/**",
"/"
).permitAll()
// 放行登录请求
.antMatchers( HttpMethod.POST, "/"+loginPath).permitAll()
// 放行注销请求
.antMatchers( HttpMethod.GET, "/"+logoutPath).permitAll()
// 文件操作
.antMatchers("/"+downloadpath+"/**").permitAll()
.antMatchers("/"+uploadpath).permitAll()
.antMatchers("/"+previewpath+"/**");
for (String excludePattern : excludesPattern) {
authenticationTokenFilter.addExcludePattern(excludePattern);
httpSecurity.authorizeRequests().antMatchers(excludePattern).permitAll();
}
// 所有请求都需要认证
httpSecurity.authorizeRequests().anyRequest().authenticated()
// 防止iframe 造成跨域
.and().headers().frameOptions().disable();
httpSecurity
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
}
}
package {{packageName}}.{{apps}};
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClientsConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import {{packageName}}.util.web.SearchContextHandlerMethodArgumentResolver;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@Slf4j
@Import({
FeignClientsConfiguration.class
})
@EnableDiscoveryClient
@Configuration
@EnableFeignClients(basePackages = {"{{packageName}}" })
@EnableZuulProxy
@ComponentScan(basePackages = {"{{packageName}}.{{apps}}","{{packageName}}.util"})
@MapperScan("{{packageName}}.*.mapper")
@SpringBootApplication(exclude = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
{{#unless system.enableMongo}}
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
{{/unless}}
{{#if system.enableDS}}
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure.class
{{/if}}
})
public class {{app.codeName}}Application extends WebMvcConfigurerAdapter {
@Autowired
SearchContextHandlerMethodArgumentResolver resolver;
public static void main(String[] args) {
SpringApplication.run({{app.codeName}}Application.class, args);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
super.addArgumentResolvers(argumentResolvers);
argumentResolvers.add(resolver);
}
}
server:
port: {{#if app.httpPort}}{{app.httpPort}}{{else}}8080{{/if}}
#Log配置
logging:
level:
{{packageName}}: info
#zuul网关路由设置
zuul:
routes:
{{#enableWorkflow}}
wfcore:
path: /wfcore/**
serviceId: ${ibiz.ref.service.wf:ibzwf-api}}
stripPrefix: true
{{/enableWorkflow}}
loginv7:
path: /v7/login
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}}
stripPrefix: false
changepwd:
path: /v7/changepwd
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}}
stripPrefix: false
uaa:
path: /uaa/**
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}}
stripPrefix: false
config:
path: /configs/**
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}}
stripPrefix: false
oucore:
path: /ibzorganizations/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}}
stripPrefix: false
oudict:
path: /dictionarys/**/Ibzou**
serviceId: ${ibiz.ref.service.ou:ibzou-api}}
stripPrefix: false
ou:
path: /ibzdepartments/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}}
stripPrefix: false
uaadict:
path: /dictionarys/**/SysOperator
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}}
stripPrefix: false
dict:
path: /dictionarys/**
serviceId: ${ibiz.ref.service.dict:ibzdict-api}}
stripPrefix: false
disk:
path: /net-disk/**
serviceId: ${ibiz.ref.service.disk:ibzdisk-api}}
stripPrefix: false
ou_sys_org:
path: /sysorganizations/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}}
stripPrefix: false
ou_sys_dept:
path: /sysdepartments/**
serviceId: ${ibiz.ref.service.ou:ibzou-api}}
stripPrefix: false
lite-core:
path: /lite/**
serviceId: ${ibiz.ref.service.lite:ibzlite-api}}
stripPrefix: false
sysauthlog:
path: /sysauthlogs
serviceId: ${ibiz.ref.service.uaa:ibzuaa-api}}
stripPrefix: false
{{#each app.appEntities}}
{{#serviceId}}
{{lowerCase codeName}}:
path: /{{pluralize codeName}}/**
serviceId: ${ibiz.ref.service.{{serviceId}}:{{serviceId}}\}
stripPrefix: false
{{/serviceId}}
{{/each}}
sensitive-headers:
- Cookie,Set-Cookie,Authorization
...@@ -66,7 +66,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -66,7 +66,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
{{/timeType}} {{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}}) @JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
@ApiModelProperty("{{logicName}}") @ApiModelProperty("{{logicName}}")
private {{type.java}} {{codeName.camelCase}}; private {{type.java}} {{camelCase codeName}};
{{/unless}} {{/unless}}
{{/each}} {{/each}}
...@@ -78,7 +78,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -78,7 +78,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
@TableField(exist = false) @TableField(exist = false)
private {{packageName}}.core.{{module}}.domain.{{entityCodeName}} {{codeName.camelCase}}; private {{packageName}}.core.{{module}}.domain.{{entityCodeName}} {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.nesteds}} {{#each entity.nesteds}}
...@@ -97,7 +97,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -97,7 +97,7 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
{{else}} {{else}}
@TableField(exist = false) @TableField(exist = false)
{{/if}} {{/if}}
private List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{codeName.camelCase}}; private List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}};
{{/each}} {{/each}}
{{#each entity.fields}} {{#each entity.fields}}
...@@ -107,9 +107,9 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -107,9 +107,9 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
/** /**
* 设置 [{{logicName}}] * 设置 [{{logicName}}]
*/ */
public {{entity.codeName}} set{{codeName.pascalCase}}({{type.java}} {{codeName.camelCase}}) { public {{entity.codeName}} set{{pascalCase codeName}}({{type.java}} {{camelCase codeName}}) {
this.{{codeName.camelCase}} = {{codeName.camelCase}}; this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{name.lowerCase}}", {{codeName.camelCase}}); this.modify("{{lowerCase name}}", {{camelCase codeName}});
return this; return this;
} }
{{/unless}} {{/unless}}
...@@ -118,12 +118,12 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -118,12 +118,12 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
/** /**
* 格式化日期 [{{logicName}}] * 格式化日期 [{{logicName}}]
*/ */
public String format{{codeName.pascalCase}}() { public String format{{pascalCase codeName}}() {
if (this.{{codeName.camelCase}} == null) { if (this.{{camelCase codeName}} == null) {
return null; return null;
} }
SimpleDateFormat sdf = new SimpleDateFormat("{{format}}"); SimpleDateFormat sdf = new SimpleDateFormat("{{format}}");
return sdf.format({{codeName.camelCase}}); return sdf.format({{camelCase codeName}});
} }
{{/timeType}} {{/timeType}}
...@@ -135,9 +135,9 @@ public class {{entity.codeName}} extends EntityMP implements Serializable ...@@ -135,9 +135,9 @@ public class {{entity.codeName}} extends EntityMP implements Serializable
/** /**
* 设置 [{{entityLogicName}}] * 设置 [{{entityLogicName}}]
*/ */
public {{entity.codeName}} set{{codeName.pascalCase}}(List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{codeName.camelCase}}) { public {{entity.codeName}} set{{pascalCase codeName}}(List<{{packageName}}.core.{{module}}.domain.{{entityCodeName}}> {{camelCase codeName}}) {
this.{{codeName.camelCase}} = {{codeName.camelCase}}; this.{{camelCase codeName}} = {{camelCase codeName}};
this.modify("{{columnName}}", ({{codeName.camelCase}}!=null)?{{codeName.camelCase}}:(new ArrayList())); this.modify("{{columnName}}", ({{camelCase codeName}}!=null)?{{camelCase codeName}}:(new ArrayList()));
return this; return this;
} }
{{/columnName}} {{/columnName}}
......
...@@ -25,37 +25,37 @@ public interface {{entity.codeName}}Mapper extends BaseMapper<{{entity.codeName} ...@@ -25,37 +25,37 @@ public interface {{entity.codeName}}Mapper extends BaseMapper<{{entity.codeName}
{{#entity.dataSets}} {{#entity.dataSets}}
Page<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> search{{codeName.pascalCase}}(IPage page, @Param("srf") {{entity.codeName}}SearchContext context, @Param("ew") Wrapper<{{entity.codeName}}> wrapper); Page<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> search{{pascalCase codeName}}(IPage page, @Param("srf") {{entity.codeName}}SearchContext context, @Param("ew") Wrapper<{{entity.codeName}}> wrapper);
List<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> list{{codeName.pascalCase}}(@Param("srf") {{entity.codeName}}SearchContext context, @Param("ew") Wrapper<{{entity.codeName}}> wrapper); List<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> list{{pascalCase codeName}}(@Param("srf") {{entity.codeName}}SearchContext context, @Param("ew") Wrapper<{{entity.codeName}}> wrapper);
{{/entity.dataSets}} {{/entity.dataSets}}
@Override @Override
{{#enableEntityCache}} {{#enableEntityCache}}
@Cacheable(value = "{{entity.codeName.lowerCase}}", key = "'row:'+#p0") @Cacheable(value = "{{lowerCase entity.codeName}}", key = "'row:'+#p0")
{{/enableEntityCache}} {{/enableEntityCache}}
{{entity.codeName}} selectById(Serializable id); {{entity.codeName}} selectById(Serializable id);
@Override @Override
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", key = "'row:'+#p0.{{entity.keyField.codeName.camelCase}}") @CacheEvict(value = "{{lowerCase entity.codeName}}", key = "'row:'+#p0.{{camelCase entity.keyField.codeName}}")
{{/enableEntityCache}} {{/enableEntityCache}}
int insert({{entity.codeName}} entity); int insert({{entity.codeName}} entity);
@Override @Override
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", key = "'row:'+#p0.{{entity.keyField.codeName.camelCase}}") @CacheEvict(value = "{{lowerCase entity.codeName}}", key = "'row:'+#p0.{{camelCase entity.keyField.codeName}}")
{{/enableEntityCache}} {{/enableEntityCache}}
int updateById(@Param(Constants.ENTITY) {{entity.codeName}} entity); int updateById(@Param(Constants.ENTITY) {{entity.codeName}} entity);
@Override @Override
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", key = "'row:'+#p0.{{entity.keyField.codeName.camelCase}}", condition ="#p0 != null") @CacheEvict(value = "{{lowerCase entity.codeName}}", key = "'row:'+#p0.{{camelCase entity.keyField.codeName}}", condition ="#p0 != null")
{{/enableEntityCache}} {{/enableEntityCache}}
int update(@Param(Constants.ENTITY) {{entity.codeName}} entity, @Param("ew") Wrapper<{{entity.codeName}}> updateWrapper); int update(@Param(Constants.ENTITY) {{entity.codeName}} entity, @Param("ew") Wrapper<{{entity.codeName}}> updateWrapper);
@Override @Override
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", key = "'row:'+#p0") @CacheEvict(value = "{{lowerCase entity.codeName}}", key = "'row:'+#p0")
{{/enableEntityCache}} {{/enableEntityCache}}
int deleteById(Serializable id); int deleteById(Serializable id);
...@@ -92,7 +92,7 @@ public interface {{entity.codeName}}Mapper extends BaseMapper<{{entity.codeName} ...@@ -92,7 +92,7 @@ public interface {{entity.codeName}}Mapper extends BaseMapper<{{entity.codeName}
boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param); boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param);
{{#entity.references}} {{#entity.references}}
List<{{entity.codeName}}> selectBy{{fkField.codeName.pascalCase}}(@Param("{{fkField.codeName.camelCase}}") Serializable {{fkField.codeName.camelCase}}); List<{{entity.codeName}}> selectBy{{pascalCase fkField.codeName}}(@Param("{{camelCase fkField.codeName}}") Serializable {{camelCase fkField.codeName}});
{{/entity.references}} {{/entity.references}}
} }
\ No newline at end of file
...@@ -36,31 +36,31 @@ public interface I{{entity.codeName}}Service extends IService<{{entity.codeName} ...@@ -36,31 +36,31 @@ public interface I{{entity.codeName}}Service extends IService<{{entity.codeName}
boolean create({{entity.codeName}} et); boolean create({{entity.codeName}} et);
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean createBatch(List<{{entity.codeName}}> list); boolean createBatch(List<{{entity.codeName}}> list);
boolean update({{entity.codeName}} et); boolean update({{entity.codeName}} et);
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean updateBatch(List<{{entity.codeName}}> list); boolean updateBatch(List<{{entity.codeName}}> list);
boolean save({{entity.codeName}} et); boolean save({{entity.codeName}} et);
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean saveBatch(List<{{entity.codeName}}> list); boolean saveBatch(List<{{entity.codeName}}> list);
boolean remove({{entity.keyField.type.java}} key); boolean remove({{entity.keyField.type.java}} key);
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean removeBatch(Collection<{{entity.keyField.type.java}}> idList); boolean removeBatch(Collection<{{entity.keyField.type.java}}> idList);
{{#each entity.extActions}} {{#each entity.extActions}}
{{entity.codeName}} {{codeName.camelCase}}({{entity.codeName}} et); {{entity.codeName}} {{camelCase codeName}}({{entity.codeName}} et);
boolean {{codeName.camelCase}}Batch(List<{{entity.codeName}}> list); boolean {{camelCase codeName}}Batch(List<{{entity.codeName}}> list);
{{/each}} {{/each}}
{{#entity.dataSets}} {{#entity.dataSets}}
...@@ -69,15 +69,15 @@ public interface I{{entity.codeName}}Service extends IService<{{entity.codeName} ...@@ -69,15 +69,15 @@ public interface I{{entity.codeName}}Service extends IService<{{entity.codeName}
{{/entity.dataSets}} {{/entity.dataSets}}
{{#entity.references}} {{#entity.references}}
List<{{entity.codeName}}> selectBy{{fkField.codeName.pascalCase}}({{fkField.type.java}} {{fkField.codeName.camelCase}}); List<{{entity.codeName}}> selectBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}});
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean removeBy{{fkField.codeName.pascalCase}}({{fkField.type.java}} {{fkField.codeName.camelCase}}); boolean removeBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}});
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean saveBy{{fkField.codeName.pascalCase}}({{fkField.type.java}} {{fkField.codeName.camelCase}},List<{{entity.codeName}}> list); boolean saveBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}},List<{{entity.codeName}}> list);
{{/entity.references}} {{/entity.references}}
} }
\ No newline at end of file
...@@ -47,12 +47,12 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; ...@@ -47,12 +47,12 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
@Service("{{entity.codeName}}ServiceImpl") @Service("{{entity.codeName}}ServiceImpl")
public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeName}}> implements I{{entity.codeName}}Service { public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeName}}> implements I{{entity.codeName}}Service {
protected I{{entity.codeName}}Service {{entity.codeName.camelCase}}Service = SpringContextHolder.getBean(this.getClass()); protected I{{entity.codeName}}Service {{camelCase entity.codeName}}Service = SpringContextHolder.getBean(this.getClass());
{{#entity.relEntities}} {{#entity.relEntities}}
@Autowired @Autowired
@Lazy @Lazy
protected {{packageName}}.core.{{codeName}}.service.I{{codeName}}Service {{codeName.camelCase}}Service; protected {{packageName}}.core.{{codeName}}.service.I{{codeName}}Service {{camelCase codeName}}Service;
{{/entity.relEntities}} {{/entity.relEntities}}
...@@ -62,7 +62,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -62,7 +62,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
Assert.notNull(et,"数据不存在,{{entity.logicName}}:"+key); Assert.notNull(et,"数据不存在,{{entity.logicName}}:"+key);
{{#entity.nesteds}} {{#entity.nesteds}}
//设置 [{{entityLogicName}}] //设置 [{{entityLogicName}}]
this.set{{codeName.pascalCase}}({{camelCase entityCodeName}}Service.selectBy{{fkField.codeName.pascalCase}}(key)); this.set{{pascalCase codeName}}({{camelCase entityCodeName}}Service.selectBy{{pascalCase fkField.codeName}}(key));
{{/entity.nesteds}} {{/entity.nesteds}}
} }
List<{{entity.codeName}}> getByIds(Collection<{{entity.keyField.type.java}}> idList); List<{{entity.codeName}}> getByIds(Collection<{{entity.keyField.type.java}}> idList);
...@@ -82,7 +82,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -82,7 +82,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
createIndexMajorEntityData(et); createIndexMajorEntityData(et);
{{/entity.isIndexSubDE}} {{/entity.isIndexSubDE}}
{{#if entity.isLogicInheritDE}} {{#if entity.isLogicInheritDE}}
if(!update(et, (Wrapper) et.getUpdateWrapper(true).eq("{{entity.keyField.name.lowerCase}}", et.get{{keyField.codeName.pascalCase}}()))) if(!update(et, (Wrapper) et.getUpdateWrapper(true).eq("{{lowerCase entity.keyField.name}}", et.get{{pascalCase keyField.codeName}}())))
return false; return false;
{{else}} {{else}}
if(!this.retBool(this.baseMapper.insert(et))) if(!this.retBool(this.baseMapper.insert(et)))
...@@ -91,7 +91,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -91,7 +91,7 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
{{#each entity.nesteds}} {{#each entity.nesteds}}
{{#unless listCode}} {{#unless listCode}}
{{#unless columnName}} {{#unless columnName}}
{{camelCase entityCodeName}}Service.saveBy{{fkField.codeName.pascalCase}}(key,et.{{codeName.camelCase}}); {{camelCase entityCodeName}}Service.saveBy{{pascalCase fkField.codeName}}(key,et.{{camelCase codeName}});
{{/unless}} {{/unless}}
{{/unless}} {{/unless}}
{{/each}} {{/each}}
...@@ -107,42 +107,42 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam ...@@ -107,42 +107,42 @@ public class {{entity.codeName}}ServiceImpl extends ServiceImpl<{{entity.codeNam
boolean update({{entity.codeName}} et); boolean update({{entity.codeName}} et);
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean updateBatch(List<{{entity.codeName}}> list); boolean updateBatch(List<{{entity.codeName}}> list);
boolean save({{entity.codeName}} et); boolean save({{entity.codeName}} et);
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean saveBatch(List<{{entity.codeName}}> list); boolean saveBatch(List<{{entity.codeName}}> list);
boolean remove({{entity.keyField.type.java}} key); boolean remove({{entity.keyField.type.java}} key);
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean removeBatch(Collection<{{entity.keyField.type.java}}> idList); boolean removeBatch(Collection<{{entity.keyField.type.java}}> idList);
{{#entity.actions}} {{#entity.actions}}
{{entity.codeName}} {{codeName.camelCase}}({{entity.codeName}} et); {{entity.codeName}} {{camelCase codeName}}({{entity.codeName}} et);
boolean {{codeName.camelCase}}Batch(List<{{entity.codeName}}> list); boolean {{camelCase codeName}}Batch(List<{{entity.codeName}}> list);
{{/entity.actions}} {{/entity.actions}}
{{#entity.dataSets}} {{#entity.dataSets}}
Page<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> search{{codeName.pascalCase}}({{entity.codeName}}SearchContext context); Page<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> search{{pascalCase codeName}}({{entity.codeName}}SearchContext context);
List<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> list{{codeName.pascalCase}}({{entity.codeName}}SearchContext context); List<{{#if enableGroup}}Map{{else}}{{entity.codeName}}{{/if}}> list{{pascalCase codeName}}({{entity.codeName}}SearchContext context);
{{/entity.dataSets}} {{/entity.dataSets}}
{{#entity.references}} {{#entity.references}}
List<{{entity.codeName}}> selectBy{{fkField.codeName.pascalCase}}({{fkField.type.java}} {{fkField.codeName.camelCase}}); List<{{entity.codeName}}> selectBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}});
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean removeBy{{fkField.codeName.pascalCase}}({{fkField.type.java}} {{fkField.codeName.camelCase}}); boolean removeBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}});
{{#enableEntityCache}} {{#enableEntityCache}}
@CacheEvict(value = "{{entity.codeName.lowerCase}}", allEntries = true) @CacheEvict(value = "{{lowerCase entity.codeName}}", allEntries = true)
{{/enableEntityCache}} {{/enableEntityCache}}
boolean saveBy{{fkField.codeName.pascalCase}}({{fkField.type.java}} {{fkField.codeName.camelCase}},List<{{entity.codeName}}> list); boolean saveBy{{pascalCase fkField.codeName}}({{fkField.type.java}} {{camelCase fkField.codeName}},List<{{entity.codeName}}> list);
{{/entity.references}} {{/entity.references}}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 --> <!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="{{entity.codeName}}ResultMap" type="{{packageName}}.core.{{module}}.domain.{{entity.codeName}}" autoMapping="true"> <resultMap id="{{entity.codeName}}ResultMap" type="{{packageName}}.core.{{module}}.domain.{{entity.codeName}}" autoMapping="true">
{{#entity.keyField.phisicalDEField}} {{#entity.keyField.phisicalDEField}}
<id property="{{entity.keyField.codeName.camelCase}}" column="{{entity.keyField.columnName}}" /><!--主键字段映射--> <id property="{{camelCase entity.keyField.codeName}}" column="{{entity.keyField.columnName}}" /><!--主键字段映射-->
{{/entity.keyField.phisicalDEField}} {{/entity.keyField.phisicalDEField}}
{{#each entity.fields}} {{#each entity.fields}}
{{#alias}} {{#alias}}
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
{{/each}} {{/each}}
{{#each entity.nesteds}} {{#each entity.nesteds}}
{{#columnName}} {{#columnName}}
<result property="{{codeName.camelCase}}" column="{{columnName}}" typeHandler="{{packageName}}.core.{{module}}.domain.handlers.{{entityCodeName}}TypeHandler" /> <result property="{{camelCase codeName}}" column="{{columnName}}" typeHandler="{{packageName}}.core.{{module}}.domain.handlers.{{entityCodeName}}TypeHandler" />
{{/columnName}} {{/columnName}}
{{/each}} {{/each}}
{{#each entity.references}} {{#each entity.references}}
<association property="{{codeName.camelCase}}" javaType="{{packageName}}.core.{{module}}.domain.{{entityCodeName}}" column="{{fkField.columnName}}" select="{{packageName}}.core.{{module}}.mapper.{{entityCodeName}}Mapper.selectById" fetchType="lazy"></association> <association property="{{camelCase codeName}}" javaType="{{packageName}}.core.{{module}}.domain.{{entityCodeName}}" column="{{fkField.columnName}}" select="{{packageName}}.core.{{module}}.mapper.{{entityCodeName}}Mapper.selectById" fetchType="lazy"></association>
{{/each}} {{/each}}
</resultMap> </resultMap>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
</select> </select>
{{#each entity.dataQueries}} {{#each entity.dataQueries}}
<sql id="{{codeName.camelCase}}" databaseId="{{dsType}}"> <sql id="{{camelCase codeName}}" databaseId="{{dsType}}">
<![CDATA[ <![CDATA[
{{dsCode}} {{dsCode}}
]]> ]]>
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
{{/each}} {{/each}}
{{#each entity.dataSets}} {{#each entity.dataSets}}
<select id="search{{codeName.pascalCase}}" parameterType="{{packageName}}.core.{{module}}.filter.{{entity.codeName}}SearchContext" resultType={{#if enableGroup}}"java.util.HashMap"{{else}}"{{entity.codeName}}ResultMap"{{/if}}> <select id="search{{pascalCase codeName}}" parameterType="{{packageName}}.core.{{module}}.filter.{{entity.codeName}}SearchContext" resultType={{#if enableGroup}}"java.util.HashMap"{{else}}"{{entity.codeName}}ResultMap"{{/if}}>
{{select}} {{select}}
from ( from (
{{#each queries}} {{#each queries}}
...@@ -72,9 +72,9 @@ ...@@ -72,9 +72,9 @@
{{/each}} {{/each}}
{{#each entity.references as | reference |}} {{#each entity.references as | reference |}}
<select id="selectBy{{reference.fkField.codeName.pascalCase}}" resultMap="{{entity.codeName}}ResultMap"> <select id="selectBy{{pascalCase reference.fkField.codeName}}" resultMap="{{entity.codeName}}ResultMap">
{{#if entity.defaultDataQuery}} {{#if entity.defaultDataQuery}}
<include refid="{{entity.defaultDataQuery.codeName.camelCase}}" /> <include refid="{{camelCase entity.defaultDataQuery.codeName}}" />
{{#if entity.defaultDataQuery.where}} {{#if entity.defaultDataQuery.where}}
and and
{{else}} {{else}}
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
{{else}} {{else}}
select t1.* from {{#if entity.viewName}}{{entity.viewName}}{{else}}{{entity.tableName}}{{/if}} t1 where select t1.* from {{#if entity.viewName}}{{entity.viewName}}{{else}}{{entity.tableName}}{{/if}} t1 where
{{/if}} {{/if}}
{{reference.fkField.columnName}} = #{{{reference.fkField.codeName.camelCase}}} {{reference.fkField.columnName}} = #{{{camelCase reference.fkField.codeName}}}
</select> </select>
{{/each}} {{/each}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册