|
|
@@ -29,6 +29,16 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
|
|
|
this._convertTable = {
|
|
|
id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
|
|
|
keywords: { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
|
|
|
+ culturalType: { clientSide: 'number', serverSide: 'number' },
|
|
|
+ productType: { clientSide: 'number', serverSide: 'number' },
|
|
|
+ type: { clientSide: 'number', serverSide: 'number' },
|
|
|
+ nature: { clientSide: 'number', serverSide: 'number' },
|
|
|
+ folkCultureType: { clientSide: 'number', serverSide: 'number' },
|
|
|
+ landforms: [
|
|
|
+ { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
|
|
|
+ { clientSide: 'arrayInt', serverSide: 'original' },
|
|
|
+ ],
|
|
|
+ villageType: { clientSide: 'number', serverSide: 'number' },
|
|
|
},
|
|
|
this._blackList.toServer.push(
|
|
|
'updatedAt', 'createdAt', 'deletedAt',
|
|
|
@@ -47,6 +57,9 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
|
|
|
}
|
|
|
if (!this.title && this.name)
|
|
|
this.title = this.name;
|
|
|
+ if (this.longitude && this.latitude) {
|
|
|
+ this.lonlat = [this.longitude as number, this.latitude as number];
|
|
|
+ }
|
|
|
};
|
|
|
this._afterSolveClient = (data) => {
|
|
|
if (this.cityAddress) {
|
|
|
@@ -54,6 +67,10 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
|
|
|
data.city = this.cityAddress[1];
|
|
|
data.district = this.cityAddress[2];
|
|
|
}
|
|
|
+ if (this.lonlat) {
|
|
|
+ data.longitude = this.lonlat[0];
|
|
|
+ data.latitude = this.lonlat[1];
|
|
|
+ }
|
|
|
};
|
|
|
}
|
|
|
id !: number;
|
|
|
@@ -78,39 +95,10 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
|
|
|
createdAt = new Date();
|
|
|
updatedAt = new Date();
|
|
|
publishAt = new Date();
|
|
|
-}
|
|
|
-
|
|
|
-export class VillageEnvInfo extends DataModel<VillageEnvInfo> {
|
|
|
- constructor() {
|
|
|
- super(VillageEnvInfo, "地理信息");
|
|
|
- this.setNameMapperCase('Camel', 'Snake');
|
|
|
- this._convertTable = {
|
|
|
- id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
|
|
|
- landforms: [
|
|
|
- { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
|
|
|
- { clientSide: 'arrayInt', serverSide: 'original' },
|
|
|
- ],
|
|
|
- villageType: { clientSide: 'number', serverSide: 'number' },
|
|
|
- },
|
|
|
- this._blackList.toServer.push(
|
|
|
- 'updatedAt', 'createdAt', 'deletedAt',
|
|
|
- );
|
|
|
- this._afterSolveServer = () => {
|
|
|
- if (this.longitude && this.latitude) {
|
|
|
- this.lonlat = [this.longitude as number, this.latitude as number];
|
|
|
- }
|
|
|
- };
|
|
|
- this._afterSolveClient = (data) => {
|
|
|
- if (this.lonlat) {
|
|
|
- data.longitude = this.lonlat[0];
|
|
|
- data.latitude = this.lonlat[1];
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
- id !: number;
|
|
|
lonlat?: number[];
|
|
|
landforms = [] as string[];
|
|
|
}
|
|
|
+
|
|
|
export class VillageListItem extends DataModel<VillageListItem> {
|
|
|
constructor() {
|
|
|
super(VillageListItem, "村社信息");
|
|
|
@@ -211,19 +199,10 @@ export class VillageInfoApi extends AppServerRequestModule<DataModel> {
|
|
|
id?: number,
|
|
|
modelClassCreator: (new () => T) = CommonInfoModel as any
|
|
|
) {
|
|
|
- if (subType === 'overview') {
|
|
|
- return (await this.post(`/village/${subType}/getInfo`, {
|
|
|
- type: subId,
|
|
|
- village_id: villageId,
|
|
|
- village_volunteer_id: villageVolunteerId,
|
|
|
- id,
|
|
|
- }, '获取村落概况', undefined, modelClassCreator)).data as T
|
|
|
- } else {
|
|
|
- return (await this.post(`/village/collect/info`, {
|
|
|
- collect_module_id: collectModuleId,
|
|
|
- id,
|
|
|
- }, '通用获取信息详情', undefined, modelClassCreator)).data as T
|
|
|
- }
|
|
|
+ return (await this.post(`/village/collect/info`, {
|
|
|
+ collect_module_id: collectModuleId,
|
|
|
+ id,
|
|
|
+ }, '通用获取信息详情', undefined, modelClassCreator)).data as T
|
|
|
}
|
|
|
async getList<T extends DataModel = VillageListItem>(
|
|
|
collectModuleId: number|undefined,
|
|
|
@@ -273,24 +252,15 @@ export class VillageInfoApi extends AppServerRequestModule<DataModel> {
|
|
|
villageVolunteerId: number,
|
|
|
data: T,
|
|
|
) {
|
|
|
- if (subType === 'overview') {
|
|
|
- return (await this.post(`/village/${subType}/save`, {
|
|
|
- ...data.toServerSide(),
|
|
|
- subType,
|
|
|
- village_id: villageId,
|
|
|
- village_volunteer_id: villageVolunteerId,
|
|
|
- }, '更新信息详情'));
|
|
|
- } else {
|
|
|
- const res : Record<string, any> = {
|
|
|
- ...data.toServerSide(),
|
|
|
- collect_module_id: collectModuleId,
|
|
|
- village_id: villageId,
|
|
|
- village_volunteer_id: villageVolunteerId,
|
|
|
- };
|
|
|
- if (subKey)
|
|
|
- res[subKey] = subId;
|
|
|
- return (await this.post(`/village/collect/save`, res, '通用更新信息详情'));
|
|
|
- }
|
|
|
+ const res : Record<string, any> = {
|
|
|
+ ...data.toServerSide(),
|
|
|
+ collect_module_id: collectModuleId,
|
|
|
+ village_id: villageId,
|
|
|
+ village_volunteer_id: villageVolunteerId,
|
|
|
+ };
|
|
|
+ if (subKey)
|
|
|
+ res[subKey] = subId;
|
|
|
+ return (await this.post(`/village/collect/save`, res, '通用更新信息详情'));
|
|
|
}
|
|
|
}
|
|
|
|