提交 086dcbd6 编写于 作者: ibizdev's avatar ibizdev

zoo457790531 发布系统代码 [ibz-dst,应用]

上级 0dd5b3d3
......@@ -271,6 +271,44 @@ mock.onPost(new RegExp(/^\/metamodels\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).re
return [status, data];
});
// ExportFile
mock.onPost(new RegExp(/^\/metamodels\/?([a-zA-Z0-9\-\;]{0,35})\/exportfile$/)).reply((config: any) => {
console.groupCollapsed("实体:metamodel 方法: ExportFile");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['id'];
const matchArray:any = new RegExp(/^\/metamodels\/([a-zA-Z0-9\-\;]{1,35})\/exportfile$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.id, tempValue.id));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['id'] == tempValue['id'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Save
mock.onPost(new RegExp(/^\/metamodels\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:metamodel 方法: Save");
......
......@@ -181,6 +181,34 @@ export default class MetaModelServiceBase extends EntityService {
return res;
}
/**
* ExportFile接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaModelServiceBase
*/
public async ExportFile(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = Http.getInstance().post(`/metamodels/${context.metamodel}/exportfile`,data,isloading);
return res;
}
/**
* ExportFileBatch接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MetaModelServiceBase
*/
public async ExportFileBatch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
return await Http.getInstance().post(`/metamodel/exportfilebatch`,tempData,isloading);
}
/**
* Save接口方法
*
......
/**
* 导出文件
*
* @export
* @class ExportFileUILogicBase
*/
export default class ExportFileUILogicBase {
/**
* Creates an instance of exportFileBase.
*
* @param {*} [opts={}]
* @memberof ExportFileUILogicBase
*/
constructor(opts: any = {}) {
}
}
\ No newline at end of file
import { Http,Util } from '@/utils';
import ExportFileUILogicBase from './export-file-ui-logic-base';
/**
* 导出文件
*
* @export
* @class ExportFileUILogic
*/
export default class ExportFileUILogic extends ExportFileUILogicBase{
/**
* Creates an instance of ExportFileUILogic
*
* @param {*} [opts={}]
* @memberof ExportFileUILogic
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
......@@ -119,6 +119,87 @@ export default class MetaModelUIServiceBase extends UIService {
public initDeMainStateOPPrivsMap(){
}
/**
* 导出文件
*
* @param {any[]} args 当前数据
* @param {any} context 行为附加上下文
* @param {*} [params] 附加参数
* @param {*} [$event] 事件源
* @param {*} [xData] 执行行为所需当前部件
* @param {*} [actionContext] 执行行为上下文
* @param {*} [srfParentDeName] 父实体名称
* @returns {Promise<any>}
*/
public async MetaModel_exportFile(args: any[],context:any = {}, params:any = {}, $event?: any, xData?: any,actionContext?: any,srfParentDeName?:string){
let data: any = {};
let parentContext:any = {};
let parentViewParam:any = {};
const _this: any = actionContext;
const _args: any[] = Util.deepCopy(args);
const actionTarget: string | null = 'MULTIKEY';
Object.assign(context, { metamodel: '%metamodel%' });
Object.assign(params, { id: '%metamodel%' });
Object.assign(params, { name: '%name%' });
if(_this.context){
parentContext = _this.context;
}
if(_this.viewparams){
parentViewParam = _this.viewparams;
}
context = UIActionTool.handleContextParam(actionTarget,_args,parentContext,parentViewParam,context);
data = UIActionTool.handleActionParam(actionTarget,_args,parentContext,parentViewParam,params);
if(Object.is(actionTarget,"MULTIKEY")){
let tempDataArray:Array<any> = [];
if((_args.length >1) && (Object.keys(data).length >0)){
for(let i =0;i<_args.length;i++){
let tempObject:any = {};
Object.keys(data).forEach((key:string) =>{
Object.assign(tempObject,{[key]:data[key].split(',')[i]});
})
tempDataArray.push(tempObject);
}
}else{
tempDataArray.push(data);
}
data = tempDataArray;
}
context = Object.assign({},actionContext.context,context);
let parentObj:any = {srfparentdename:srfParentDeName?srfParentDeName:null,srfparentkey:srfParentDeName?context[srfParentDeName.toLowerCase()]:null};
if(!Object.is(actionTarget,"MULTIKEY")){
Object.assign(data,parentObj);
}
Object.assign(context,parentObj);
// 直接调实体服务需要转换的数据
if(context && context.srfsessionid){
context.srfsessionkey = context.srfsessionid;
delete context.srfsessionid;
}
const backend = () => {
const curService:MetaModelService = new MetaModelService();
curService.ExportFileBatch(context,data, true).then((response: any) => {
if (!response || response.status !== 200) {
actionContext.$Notice.error({ title: '错误', desc: response.message });
return;
}
actionContext.$Notice.success({ title: '成功', desc: '导出文件成功' });
const _this: any = actionContext;
return response;
}).catch((response: any) => {
if (response && response.status && response.data) {
actionContext.$Notice.error({ title: (actionContext.$t('app.commonWords.wrong') as string), desc: response.data.message });
return;
}
if (!response || !response.status || !response.data) {
actionContext.$Notice.error({ title: (actionContext.$t('app.commonWords.wrong') as string), desc: (actionContext.$t('app.commonWords.sysException') as string) });
return;
}
return response;
});
};
backend();
}
/**
* 获取指定数据的重定向页面
......
......@@ -31,5 +31,15 @@ public class MetaModelExService extends MetaModelServiceImpl {
public MetaModel change(MetaModel et) {
return super.change(et);
}
/**
* [ExportFile:导出文件] 行为扩展:导出文件zip格式
* @param et
* @return
*/
@Override
@Transactional
public MetaModel exportFile(MetaModel et) {
return super.exportFile(et);
}
}
......@@ -39,6 +39,8 @@ public interface IMetaModelService extends IService<MetaModel> {
MetaModel change(MetaModel et);
boolean changeBatch(List<MetaModel> etList);
boolean checkKey(MetaModel et);
MetaModel exportFile(MetaModel et);
boolean exportFileBatch(List<MetaModel> etList);
boolean save(MetaModel et);
@CacheEvict(value = "metamodel",allEntries = true)
void saveBatch(List<MetaModel> list);
......
......@@ -149,6 +149,22 @@ public class MetaModelServiceImpl extends ServiceImpl<MetaModelMapper, MetaModel
public boolean checkKey(MetaModel et) {
return (!ObjectUtils.isEmpty(et.getId())) && (!Objects.isNull(this.getById(et.getId())));
}
@Override
@Transactional
public MetaModel exportFile(MetaModel et) {
//自定义代码
return et;
}
@Override
@Transactional
public boolean exportFileBatch(List<MetaModel> etList) {
for(MetaModel et : etList) {
exportFile(et);
}
return true;
}
@Override
@Transactional
public boolean save(MetaModel et) {
......
......@@ -328,7 +328,7 @@
<!--输出实体[META_MODEL]数据结构 -->
<changeSet author="root" id="tab-meta_model-18-12">
<changeSet author="root" id="tab-meta_model-20-12">
<createTable tableName="IBZMODEL">
<column name="MODELID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_META_MODEL_MODELID"/>
......
......@@ -120,7 +120,7 @@
"delogicname":"模型",
"sysmoudle":{"id":"LITE","name":"lite"},
"dedataset":[{"id":"Default" , "name":"数据集"}],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"Change" , "name":"change" , "type":"USERCUSTOM" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"deaction":[{"id":"Create" , "name":"Create" , "type":"BUILTIN" },{"id":"Update" , "name":"Update" , "type":"BUILTIN" },{"id":"Remove" , "name":"Remove" , "type":"BUILTIN" },{"id":"Get" , "name":"Get" , "type":"BUILTIN" },{"id":"GetDraft" , "name":"GetDraft" , "type":"BUILTIN" },{"id":"Change" , "name":"change" , "type":"USERCUSTOM" },{"id":"CheckKey" , "name":"CheckKey" , "type":"BUILTIN" },{"id":"ExportFile" , "name":"导出文件" , "type":"USERCUSTOM" },{"id":"Save" , "name":"Save" , "type":"BUILTIN" }],
"datascope":[{"id":"all","name":"全部数据"}]
}
, {
......
......@@ -138,6 +138,23 @@ public class MetaModelResource {
return ResponseEntity.status(HttpStatus.OK).body(metamodelService.checkKey(metamodelMapping.toDomain(metamodeldto)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaModel-ExportFile-all')")
@ApiOperation(value = "导出文件", tags = {"模型" }, notes = "导出文件")
@RequestMapping(method = RequestMethod.POST, value = "/metamodels/{metamodel_id}/exportfile")
public ResponseEntity<MetaModelDTO> exportFile(@PathVariable("metamodel_id") String metamodel_id, @RequestBody MetaModelDTO metamodeldto) {
MetaModel domain = metamodelMapping.toDomain(metamodeldto);
domain.setId(metamodel_id);
domain = metamodelService.exportFile(domain);
metamodeldto = metamodelMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(metamodeldto);
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaModel-ExportFile-all')")
@ApiOperation(value = "批量处理[导出文件]", tags = {"模型" }, notes = "批量处理[导出文件]")
@RequestMapping(method = RequestMethod.POST, value = "/metamodels/{metamodel_id}/exportfilebatch")
public ResponseEntity<Boolean> exportFileBatch(@RequestBody List<MetaModelDTO> metamodeldtos) {
return ResponseEntity.status(HttpStatus.OK).body(metamodelService.exportFileBatch(metamodelMapping.toDomain(metamodeldtos)));
}
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','ibzdst-MetaModel-Save-all')")
@ApiOperation(value = "保存模型", tags = {"模型" }, notes = "保存模型")
@RequestMapping(method = RequestMethod.POST, value = "/metamodels/save")
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册