|
|
@@ -1,6 +1,7 @@
|
|
|
-import { DataModel, transformArrayDataModel } from '@imengyu/js-request-transform';
|
|
|
+import { DataModel, transformArrayDataModel, transformDataModel } from '@imengyu/js-request-transform';
|
|
|
import { AppServerRequestModule } from '../RequestModules';
|
|
|
import dayjs from 'dayjs';
|
|
|
+import { transformSomeToArray } from '../Utils';
|
|
|
|
|
|
export class CommonInfo<T extends DataModel> extends DataModel<T> {
|
|
|
|
|
|
@@ -75,6 +76,8 @@ export class IchInfo extends CommonInfo<IchInfo> {
|
|
|
data.latitude = this.lonlat[1];
|
|
|
};
|
|
|
this._beforeSolveClient = (data) => {
|
|
|
+ if (!this.expandInfo)
|
|
|
+ this.expandInfo = new IchExpandInfo();
|
|
|
this.expandInfo.batch = this.batch;
|
|
|
this.expandInfo.region = this.region;
|
|
|
this.expandInfo.image = this.image;
|
|
|
@@ -86,7 +89,7 @@ export class IchInfo extends CommonInfo<IchInfo> {
|
|
|
}
|
|
|
|
|
|
lonlat = [] as (number|string)[];
|
|
|
- expandInfo = new IchExpandInfo();
|
|
|
+ expandInfo : IchExpandInfo|null = new IchExpandInfo();
|
|
|
|
|
|
id = 0 as number;
|
|
|
modelId = 2;
|
|
|
@@ -228,7 +231,7 @@ export class InheritorInfo extends CommonInfo<InheritorInfo> {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- expandInfo = new InheritorExpandInfo();
|
|
|
+ expandInfo : InheritorExpandInfo|null = new InheritorExpandInfo();
|
|
|
|
|
|
id = 0 as number;
|
|
|
modelId = 7;
|
|
|
@@ -369,7 +372,7 @@ export class SeminarInfo extends CommonInfo<SeminarInfo> {
|
|
|
}
|
|
|
|
|
|
lonlat = [] as (number|string)[];
|
|
|
- expandInfo = new SeminarExpandInfo();
|
|
|
+ expandInfo : SeminarExpandInfo|null = new SeminarExpandInfo();
|
|
|
|
|
|
id = 0 as number;
|
|
|
modelId = 17;
|
|
|
@@ -459,6 +462,21 @@ export class PlanInfo extends DataModel<PlanInfo> {
|
|
|
ichName = '' as string;
|
|
|
progressText = '' as string;
|
|
|
}
|
|
|
+export class InheritorAccountInfo extends DataModel<InheritorAccountInfo> {
|
|
|
+ constructor() {
|
|
|
+ super(InheritorAccountInfo, "传承人账号信息");
|
|
|
+ this.setNameMapperCase('Camel', 'Snake');
|
|
|
+ this._convertTable = {
|
|
|
+ username: { clientSide: 'string', clientSideRequired: true },
|
|
|
+ password: { clientSide: 'string', clientSideRequired: true },
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ id = 0 as number;
|
|
|
+ username = '' as string;
|
|
|
+ password = '' as string;
|
|
|
+ nickname = '' as string;
|
|
|
+}
|
|
|
|
|
|
export class InheritorContentApi extends AppServerRequestModule<DataModel> {
|
|
|
|
|
|
@@ -466,9 +484,10 @@ export class InheritorContentApi extends AppServerRequestModule<DataModel> {
|
|
|
super();
|
|
|
}
|
|
|
|
|
|
- async getBaseInfo<T extends DataModel>(newDataModel: new () => T) {
|
|
|
+ async getBaseInfo<T extends DataModel>(id: number|undefined, newDataModel: new () => T) {
|
|
|
return (await this.post('/ich/inheritor/baseInfo', {
|
|
|
model_id: new newDataModel().modelId,
|
|
|
+ id,
|
|
|
}, '基础表信息', undefined, newDataModel)).data as T;
|
|
|
}
|
|
|
/**
|
|
|
@@ -490,10 +509,15 @@ export class InheritorContentApi extends AppServerRequestModule<DataModel> {
|
|
|
async saveBaseInfo<T extends DataModel>(dataModel: T) {
|
|
|
return (await this.post('/ich/inheritor/saveBase', dataModel.toServerSide(), '基础内容表采集(非遗,传承人,传习所)'));
|
|
|
}
|
|
|
- async getExpandInfo<T extends DataModel>(newDataModel: new () => T) {
|
|
|
- return (await this.post('/ich/inheritor/expandInfo', {
|
|
|
+ async getExpandInfo<T extends DataModel>(id: number|undefined, newDataModel: new () => T) : Promise<T | null> {
|
|
|
+ return this.post('/ich/inheritor/expandInfo', {
|
|
|
model_id: new newDataModel().modelId,
|
|
|
- }, '扩展表信息', undefined, newDataModel)).data as T;
|
|
|
+ id,
|
|
|
+ }, '扩展表信息', undefined).then((res) => {
|
|
|
+ if (!res.data2)
|
|
|
+ return null;
|
|
|
+ return transformDataModel(newDataModel, res.data2) as T;
|
|
|
+ })
|
|
|
}
|
|
|
async saveExpandInfo<T extends DataModel>(dataModel: T) {
|
|
|
return (await this.post('/ich/inheritor/saveExpand', dataModel.toServerSide(), '扩展内容表采集(非遗,传承人,传习所)'));
|
|
|
@@ -502,23 +526,34 @@ export class InheritorContentApi extends AppServerRequestModule<DataModel> {
|
|
|
return (await this.post('/ich/inheritor/savePlans', dataModel.toServerSide(), '保存项目五年计划'));
|
|
|
}
|
|
|
|
|
|
- async getIchInfo() {
|
|
|
- return await this.getBaseInfo(IchInfo);
|
|
|
+ async getInheritorAccountInfo(contentId: number) {
|
|
|
+ return this.post('/ich/inheritor/getAccount', {
|
|
|
+ content_id: contentId,
|
|
|
+ }, '获取传承人账号信息', undefined).then((res) => {
|
|
|
+ const arr = transformSomeToArray(res.data2);
|
|
|
+ if (arr.length === 0)
|
|
|
+ return null;
|
|
|
+ return transformDataModel(InheritorAccountInfo, arr[0]);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ async getIchInfo(id: number|undefined) {
|
|
|
+ return await this.getBaseInfo(id, IchInfo);
|
|
|
}
|
|
|
- async getInheritorInfo() {
|
|
|
- return await this.getBaseInfo(InheritorInfo);
|
|
|
+ async getInheritorInfo(id: number|undefined) {
|
|
|
+ return await this.getBaseInfo(id, InheritorInfo);
|
|
|
}
|
|
|
- async getSeminarInfo() {
|
|
|
- return await this.getBaseInfo(SeminarInfo);
|
|
|
+ async getSeminarInfo(id: number|undefined) {
|
|
|
+ return await this.getBaseInfo(id, SeminarInfo);
|
|
|
}
|
|
|
- async getIchExpandInfo() {
|
|
|
- return await this.getExpandInfo(IchExpandInfo);
|
|
|
+ async getIchExpandInfo(id: number|undefined) {
|
|
|
+ return await this.getExpandInfo(id, IchExpandInfo);
|
|
|
}
|
|
|
- async getInheritorExpandInfo() {
|
|
|
- return await this.getExpandInfo(InheritorExpandInfo);
|
|
|
+ async getInheritorExpandInfo(id: number|undefined) {
|
|
|
+ return await this.getExpandInfo(id, InheritorExpandInfo);
|
|
|
}
|
|
|
- async getSeminarExpandInfo() {
|
|
|
- return await this.getExpandInfo(SeminarExpandInfo);
|
|
|
+ async getSeminarExpandInfo(id: number|undefined) {
|
|
|
+ return await this.getExpandInfo(id, SeminarExpandInfo);
|
|
|
}
|
|
|
}
|
|
|
|