|
|
@@ -1,6 +1,6 @@
|
|
|
-import { DataModel, transformArrayDataModel, type NewDataModel } from '@imengyu/js-request-transform';
|
|
|
-import CommonContent from '../CommonContent';
|
|
|
+import { DataModel, transformArrayDataModel } from '@imengyu/js-request-transform';
|
|
|
import { AppServerRequestModule } from '../RequestModules';
|
|
|
+import CommonContent from '../CommonContent';
|
|
|
|
|
|
export class CategoryListItem extends DataModel<CategoryListItem> {
|
|
|
constructor() {
|
|
|
@@ -30,6 +30,9 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
|
|
|
id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
|
|
|
|
|
|
},
|
|
|
+ this._blackList.toServer.push(
|
|
|
+ 'updatedAt', 'createdAt', 'deletedAt',
|
|
|
+ );
|
|
|
this._afterSolveServer = () => {
|
|
|
if (this.province && this.city && this.district) {
|
|
|
this.cityAddress = [this.province as string, this.city as string, this.district as string];
|
|
|
@@ -45,7 +48,6 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
|
|
|
}
|
|
|
id !: number;
|
|
|
cityAddress?: string[];
|
|
|
-
|
|
|
}
|
|
|
|
|
|
export class VillageEnvInfo extends DataModel<VillageEnvInfo> {
|
|
|
@@ -58,7 +60,11 @@ export class VillageEnvInfo extends DataModel<VillageEnvInfo> {
|
|
|
{ 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];
|
|
|
@@ -82,6 +88,9 @@ export class VillageListItem extends DataModel<VillageListItem> {
|
|
|
this._convertTable = {
|
|
|
id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
|
|
|
},
|
|
|
+ this._blackList.toServer.push(
|
|
|
+ 'updatedAt', 'createdAt', 'deletedAt',
|
|
|
+ );
|
|
|
this._convertKeyType = (key, direction) => {
|
|
|
if (key.endsWith('At'))
|
|
|
return {
|
|
|
@@ -93,10 +102,10 @@ export class VillageListItem extends DataModel<VillageListItem> {
|
|
|
this._afterSolveServer = () => {
|
|
|
if (!this.title) {
|
|
|
if (this.name) this.title = this.name as string;
|
|
|
- else if (typeof this.content === 'object' && (this.content as any)?.title) this.title = (this.content as any).title as string;
|
|
|
- else if (this.content) this.title = this.content as string;
|
|
|
- else if (this.structure) this.title = this.structure as string;
|
|
|
- else if (this.wisdom) this.title = this.wisdom as string;
|
|
|
+ if (typeof this.content === 'object' && (this.content as any)?.title) this.title = (this.content as any).title as string;
|
|
|
+ if (this.content) this.title = this.content as string;
|
|
|
+ if (this.structure) this.title = this.structure as string;
|
|
|
+ if (this.wisdom) this.title = this.wisdom as string;
|
|
|
}
|
|
|
if (!this.image) {
|
|
|
if (this.distribution) this.image = this.distribution as string;
|
|
|
@@ -116,6 +125,9 @@ export class VillageBulidingInfo extends DataModel<VillageBulidingInfo> {
|
|
|
this._convertTable = {
|
|
|
id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
|
|
|
}
|
|
|
+ this._blackList.toServer.push(
|
|
|
+ 'updatedAt', 'createdAt', 'deletedAt',
|
|
|
+ );
|
|
|
const commaArrayKeys = [
|
|
|
'purpose','floorType','wallType','roofForm','bearingType',
|
|
|
]
|
|
|
@@ -159,29 +171,40 @@ export class VillageInfoApi extends AppServerRequestModule<DataModel> {
|
|
|
}
|
|
|
|
|
|
async getInfo<T extends DataModel>(
|
|
|
- sub: string,
|
|
|
- subId: number,
|
|
|
+ collectModuleId: number|undefined,
|
|
|
+ subType: string,
|
|
|
+ subId: number|undefined,
|
|
|
+ subKey: string|undefined,
|
|
|
villageId: number,
|
|
|
villageVolunteerId: number,
|
|
|
- id?: number,
|
|
|
+ id?: number,
|
|
|
modelClassCreator: (new () => T) = CommonInfoModel as any
|
|
|
) {
|
|
|
- return (await this.post(`/village/${sub}/getInfo`, {
|
|
|
- type: subId,
|
|
|
- village_id: villageId,
|
|
|
- village_volunteer_id: villageVolunteerId,
|
|
|
- id,
|
|
|
- }, '获取信息详情', undefined, modelClassCreator)).data as T
|
|
|
+ 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
|
|
|
+ }
|
|
|
}
|
|
|
async getList<T extends DataModel = VillageListItem>(
|
|
|
- sub: string,
|
|
|
+ collectModuleId: number|undefined,
|
|
|
+ subType: string,
|
|
|
subId: number|undefined,
|
|
|
subKey: string|undefined,
|
|
|
villageId: number,
|
|
|
villageVolunteerId: number,
|
|
|
modelClassCreator: (new () => T) = VillageListItem as any
|
|
|
) {
|
|
|
- return (this.post(`/village/${sub}/getList`, {
|
|
|
+ return (this.post(`/village/collect/list`, {
|
|
|
+ collect_module_id: collectModuleId,
|
|
|
[subKey ? subKey : 'type']: subId,
|
|
|
village_id: villageId,
|
|
|
village_volunteer_id: villageVolunteerId,
|
|
|
@@ -190,17 +213,30 @@ export class VillageInfoApi extends AppServerRequestModule<DataModel> {
|
|
|
.catch(e => { throw e });
|
|
|
}
|
|
|
async updateInfo<T extends DataModel>(
|
|
|
- sub: string,
|
|
|
+ collectModuleId: number|undefined,
|
|
|
+ subType: string,
|
|
|
+ subKey: string,
|
|
|
+ subId: number,
|
|
|
villageId: number,
|
|
|
villageVolunteerId: number,
|
|
|
data: T,
|
|
|
) {
|
|
|
- return (await this.post(`/village/${sub}/save`, {
|
|
|
- sub,
|
|
|
- village_id: villageId,
|
|
|
- village_volunteer_id: villageVolunteerId,
|
|
|
- ...data.toServerSide(),
|
|
|
- }, '更新信息详情'));
|
|
|
+ if (subType === 'overview') {
|
|
|
+ return (await this.post(`/village/${subType}/save`, {
|
|
|
+ subType,
|
|
|
+ village_id: villageId,
|
|
|
+ village_volunteer_id: villageVolunteerId,
|
|
|
+ ...data.toServerSide(),
|
|
|
+ }, '更新信息详情'));
|
|
|
+ } else {
|
|
|
+ return (await this.post(`/village/collect/save`, {
|
|
|
+ collect_module_id: collectModuleId,
|
|
|
+ [subKey||'type']: subId,
|
|
|
+ village_id: villageId,
|
|
|
+ village_volunteer_id: villageVolunteerId,
|
|
|
+ ...data.toServerSide(),
|
|
|
+ }, '通用更新信息详情'));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|