提交 1bf03e3f 编写于 作者: WodahsOrez's avatar WodahsOrez

add: 关系路径

上级 7669dc2f
package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.Inflector;
import cn.ibizlab.codegen.utils.StringAdvUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
......@@ -23,6 +26,49 @@ public class AppEntityModel extends BaseModel{
this.setName(appDataEntity.getName());
this.setId(String.format("%1$s-%2$s",app.getCodeName(),appDataEntity.getCodeName()));
// 初始化应用实体资源数据
if(getAppDataEntity().getMinorPSAppDERSs() != null){
// 遍历多个主从关系
getAppDataEntity().getMinorPSAppDERSs().forEach(appDERS ->{
JSONObject appEntityResource = new JSONObject();
String majorCodeName = appDERS.getMajorPSAppDataEntity().getCodeName();
String minorCodeName = appDERS.getMinorPSAppDataEntity().getCodeName();
String path = String.format("%1$s/:%2$s?/%3$s/:%4$s?", Inflector.getInstance().pluralize(majorCodeName),majorCodeName,Inflector.getInstance().pluralize(minorCodeName),minorCodeName).toLowerCase();
appEntityResource.put("majorCodeName",majorCodeName.toLowerCase());
appEntityResource.put("curCodeName",minorCodeName.toLowerCase());
appEntityResource.put("path",path);
// 实体关系路径集合
List deResPaths = new JSONArray();
// 主关系路径节点
JSONObject majorResNode = new JSONObject();
majorResNode.put("pathName", Inflector.getInstance().pluralize(majorCodeName).toLowerCase());
majorResNode.put("parameterName", majorCodeName.toLowerCase());
deResPaths.add(majorResNode);
// 从关系路径节点
JSONObject minorResNode = new JSONObject();
minorResNode.put("pathName", Inflector.getInstance().pluralize(minorCodeName).toLowerCase());
minorResNode.put("parameterName", minorCodeName.toLowerCase());
deResPaths.add(minorResNode);
appEntityResource.put("deResPaths", deResPaths);
appEntityResources.add(appEntityResource);
});
}else{
// 没有主从关系,路径就只有自己本身一个
JSONObject appEntityResource = new JSONObject();
appEntityResource.put("curCodeName",appDataEntity.getCodeName().toLowerCase());
appEntityResource.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
// 路由关系路径集合
List deResPaths = new JSONArray();
// 实体本身关系路径节点
JSONObject curResNode = new JSONObject();
curResNode.put("pathName", Inflector.getInstance().pluralize(appDataEntity.getCodeName()).toLowerCase());
curResNode.put("parameterName", appDataEntity.getCodeName().toLowerCase());
deResPaths.add(curResNode);
appEntityResource.put("deResPaths", deResPaths);
appEntityResource.put("deResPathsString", deResPaths.toString());
appEntityResources.add(appEntityResource);
}
}
public IPSAppDataEntity getAppDataEntity()
......@@ -64,4 +110,10 @@ public class AppEntityModel extends BaseModel{
return ctrlsMap.values();
}
/**
* 应用实体资源数据
*/
private List<JSONObject> appEntityResources =new ArrayList<>();
}
......@@ -61,40 +61,6 @@ public class AppModel extends BaseModel{
});
}
// 初始化应用实体关系数据Set
if(getApplication().getAllPSAppDataEntities()!=null){
getApplication().getAllPSAppDataEntities().forEach(appDataEntity ->{
JSONObject tempObj = new JSONObject();
tempObj.put("appDataEntity",appDataEntity);
if(appDataEntity.getMinorPSAppDERSs() != null){
List deResLinks = new ArrayList<JSONObject>();
appDataEntity.getMinorPSAppDERSs().forEach(appDERS ->{
JSONObject deResLink = new JSONObject();
String majorCodeName = appDERS.getMajorPSAppDataEntity().getCodeName();
String minorCodeName = appDERS.getMinorPSAppDataEntity().getCodeName();
String path = String.format("%1$s/:%2$s?/%3$s/:%4$s?",Inflector.getInstance().pluralize(majorCodeName),majorCodeName,Inflector.getInstance().pluralize(minorCodeName),minorCodeName).toLowerCase();
deResLink.put("majorCodeName",majorCodeName.toLowerCase());
deResLink.put("path",path);
// 路由关系参数数组
List deResParameters = new ArrayList();
JSONObject majorResObj = new JSONObject();
majorResObj.put("pathName", Inflector.getInstance().pluralize(majorCodeName).toLowerCase());
majorResObj.put("parameterName", majorCodeName.toLowerCase());
deResParameters.add(majorResObj);
JSONObject minorResObj = new JSONObject();
minorResObj.put("pathName", Inflector.getInstance().pluralize(minorCodeName).toLowerCase());
minorResObj.put("parameterName", minorCodeName.toLowerCase());
deResParameters.add(minorResObj);
deResLink.put("deResParameters", deResParameters);
deResLinks.add(deResLink);
});
tempObj.put("deResLinks", deResLinks);
}else{
tempObj.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
}
appDeResSet.add(tempObj);
});
}
}
......@@ -145,11 +111,6 @@ public class AppModel extends BaseModel{
*/
private Map<String, JSONObject> appEntityResourceMap =new LinkedHashMap<>();
/**
* 应用实体关系对象Set
*/
private Set<JSONObject> appDeResSet =new HashSet<>();
/**
* 获取应用实体资源数据
* @return
......
{{!-- {
{{#each app.appEntityResources as |appEntityResource|}}
{{#if appEntityResource.appDataEntity.allPSAppViews}}
{{#each appEntityResource.appDataEntity.allPSAppViews as |appView|}}
"{{appView.codeName}}":{
"name": "{{appView.name}}",
"codeName": "{{appView.codeName}}",
"openMode": "{{#if appView.openMode}}{{appView.openMode}}{{else}}INDEXVIEWTAB{{/if}}",
"redirectView": {{appView.redirectView}},
"path": "{{appEntityResource.path}}/views/{{lowerCase appView.codeName}}",
{{#if appView.capPSLanguageRes}}
"captionTag": "{{appView.capPSLanguageRes.lanResTag}}",
{{/if}}
"caption": "{{appView.caption}}",
{{#if appView.psSysImage}}
"imgPath": "{{appView.psSysImage.imagePath}}",
"iconCls": "{{appView.psSysImage.cssClass}}",
{{/if}}
"viewType": "{{appView.viewType}}",
"fileDir": "@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}"
}{{#unless (and @last ../@last)}},{{/unless}}
{{/each}}
{{/if}}
{{/each}}
} --}}
{
{{#each app.appDeResSet as |appDeRes|}}
{{#if appDeRes.deResLinks}}
{{#each appDeRes.appDataEntity.allPSAppViews as |appView|}}
{{#each app.pages as |appView|}}
"{{appView.codeName}}":{
"name": "{{appView.name}}",
"codeName": "{{appView.codeName}}",
"openMode": "{{#if appView.openMode}}{{appView.openMode}}{{else}}INDEXVIEWTAB{{/if}}",
"redirectView": {{appView.redirectView}},
"deResLinks": [
{{#each appDeRes.deResLinks as |deResLink| }}
[
{{#each deResLink.deResParameters as |deResParameter| }}
{ "pathName": "{{deResParameter.pathName}}", "parameterName": "{{deResParameter.parameterName}}" }{{#unless @last}},{{/unless}}
{{/each}}
]{{#unless @last}},{{/unless}}
"deResPaths": [
{{#each appView.appEntity.appEntityResources as |appEntityResource| }}
{{appEntityResource.deResPaths}}{{#unless @last}},{{/unless}}
{{/each}}
],
"parameters": [
{{#if appDeRes.appDataEntity}}
{ "pathName": "{{pluralize appDeRes.appDataEntity.codeName}}", "parameterName": "{{appDeRes.appDataEntity.codeName}}" },
{{/if}}
{ "pathName": "views", "parameterName": "{{lowerCase appView.codeName}}" }
],
{{#if appView.capPSLanguageRes}}
......@@ -58,7 +24,5 @@
"viewType": "{{appView.viewType}}",
"fileDir": "@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}"
}{{#unless (and @last ../@last)}},{{/unless}}
{{/each}}
{{/if}}
{{/each}}
}
<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import {App} from '@service'
onMounted(async ()=>{
await App.init();
// App.openViewService.openView({codeName: 'ExampleEditorEditView'},{context: {},viewParams:{}})
})
</script>
<template>
......
export * from './control-service'
export * from './entity'
export * from './singleton'
\ No newline at end of file
export * from './entity'
\ No newline at end of file
/**
* 单例基类
*
* @export
* @class Singleton
*/
export class Singleton{
/**
* 唯一实例
*
* @private
* @static
* @memberof Singleton
*/
private static readonly instance = new Singleton();
/**
* 获取唯一实例
*
* @static
* @return {*} {Singleton}
* @memberof Singleton
*/
public static getInstance(): Singleton {
return Singleton.instance;
}
}
\ No newline at end of file
export * from './util';
export * from './view-util';
export * from './route-tool';
export { Http } from './net/http';
\ No newline at end of file
import { AppModal } from '@/utils';
import { Http, deepCopy } from '@ibiz-core';
import { OpenViewService } from '@service';
export class App{
/**
* 打开视图服务
* @static
*/
public static openViewService: OpenViewService = OpenViewService.getInstance();
/**
* 打开视图服务
* @static
*/
public static modalService: AppModal = AppModal.getInstance();
/**
* 所有视图信息
*
* @static
*/
public static allViewInfos: any;
/**
* 获取视图信息
*
* @static
* @param codeName 视图codeName
* @return {*}
*/
public static getViewInfo(codeName: string){
return App.allViewInfos[codeName] ? deepCopy(App.allViewInfos[codeName]) : undefined;
}
/**
* 初始化
*
* @static
*/
public static async init(){
const response = await Http.getInstance().get('./assets/json/views.json')
App.allViewInfos = response.data;
}
}
\ No newline at end of file
export * from './open-view/open-view-service';
export * from './app/app';
\ No newline at end of file
import { deepCopy, IParam, Singleton, RouteTool } from "@ibiz-core";
import { useRouter } from "vue-router";
const allViews= require('./views.json')
import { deepCopy, IParam, RouteTool } from '@ibiz-core';
import { App } from '@service';
import router from '@/router';
interface View extends IParam{
codeName: string,
openMode ?: string,
interface View extends IParam {
codeName: string;
openMode?: string;
}
interface Params extends IParam{
context: any,
viewParams: any,
interface Params extends IParam {
context: any;
viewParams: any;
}
/**
......@@ -17,7 +17,26 @@ interface Params extends IParam{
* @export
* @class OpenViewService
*/
export class OpenViewService extends Singleton{
export class OpenViewService {
/**
* 唯一实例
*
* @private
* @static
* @memberof OpenViewService
*/
private static readonly instance = new OpenViewService();
/**
* 获取唯一实例
*
* @static
* @return {*} {OpenViewService}
* @memberof OpenViewService
*/
public static getInstance(): OpenViewService {
return OpenViewService.instance;
}
/**
* 打开视图
......@@ -25,26 +44,24 @@ interface Params extends IParam{
* @param view 视图信息
* @param params 相关参数
*/
public openView(view: View, params: Params){
public openView(view: View, params: Params) {
// 获取详细视图信息
let _view: any = allViews[view.codeName];
if(!_view){
let _view: any = App.getViewInfo(view.codeName);
if (!_view) {
console.error(`应用中不存在${view.codeName}视图`);
return
return;
}
// 拷贝防污染,view的openMode覆盖配置的
_view = deepCopy(_view);
if(view.openMode){
// view的openMode覆盖配置的
if (view.openMode) {
_view.openMode = view.openMode;
}
// 重定向视图走重定向逻辑,其他根据openMode打开
if(_view.redirectView){
if (_view.redirectView) {
this.openRedirectView(_view, params);
}else{
this.openByOpenMode(_view, params)
} else {
this.openByOpenMode(_view, params);
}
}
/**
......@@ -53,30 +70,26 @@ interface Params extends IParam{
* @param view 视图信息
* @param params 相关参数
*/
public openByOpenMode(view: any, params: Params){
public openByOpenMode(view: any, params: Params) {
const { openMode } = view;
const { viewParams, context } = params
const { viewParams, context } = params;
// 路由打开视图
if(openMode == 'INDEXVIEWTAB' || openMode == 'POPUPAPP'){
if (openMode == 'INDEXVIEWTAB' || openMode == 'POPUPAPP') {
// TODO 视图关系参数处理
const router = useRouter();
const routePath = RouteTool.buildUpRoutePath(view, context,viewParams);
if(openMode == 'INDEXVIEWTAB'){
const routePath = RouteTool.buildUpRoutePath(view, context, viewParams, router.currentRoute.value);
if (openMode == 'INDEXVIEWTAB') {
router.push(routePath);
}else{
} else {
window.open('./#' + routePath, '_blank');
}
}else if(openMode == 'POPUPMODAL'){
}else if(openMode.indexOf('DRAWER') !== -1){
} else if (openMode == 'POPUPMODAL') {
} else if (openMode.indexOf('DRAWER') !== -1) {
// TODO PMS上面抽屉DRAWER_TOP
}else if(openMode == 'POPOVER'){
} else if (openMode == 'POPOVER') {
// TODO 打开气泡卡片
}else{
} else {
console.error(`未支持${openMode}打开方式`);
}
}
/**
......@@ -85,7 +98,7 @@ interface Params extends IParam{
* @param view 视图信息
* @param params 相关参数
*/
public openRedirectView(view: any, params: Params){
public openRedirectView(view: any, params: Params) {
// TODO 重定向视图处理
}
}
\ No newline at end of file
}
......@@ -4,7 +4,6 @@ import Antd from 'ant-design-vue';
// import { AppServiceBase, LogUtil } from 'ibiz-core';
import AppModalComponent from "./app-modal.vue";
import IbizLoading from '@components/render/IbizLoading.vue';
import './app-modal.scss';
export class AppModal {
......
......@@ -234,7 +234,3 @@ const handleShowState = ($event: any) => {
></component>
</a-modal>
</template>
<style lang="scss" scoped>
@import './app-modal.scss';
</style>
\ No newline at end of file
......@@ -56,10 +56,10 @@ export class ControlVO extends ControlVOBase {
{{/neq}}
{{/each}}
// 表单里没有映射实体属性的字段
// 表单里没有映射实体属性的字段(srfuf除外)
{{#each ctrl.psDEFormItems as | formItem | }}
{{#eq formItem.psAppDEField null }}
{{#if (and (eq formItem.psAppDEField null) (neq formItem.id "srfuf" )) }}
{{lowerCase formItem.id}}: any;
{{/eq}}
{{/if}}
{{/each}}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册