|
|
@@ -200,124 +200,113 @@ export class VillageApi extends AppServerRequestModule<DataModel> {
|
|
|
}
|
|
|
|
|
|
async getClaimedVallageList(volunteerId?: string) {
|
|
|
-
|
|
|
- return (this.get('/village/village/getVillageList', '获取已认领村落', {
|
|
|
+ const res = await this.get('/village/village/getVillageList', '获取已认领村落', {
|
|
|
village_volunteer_id: volunteerId,
|
|
|
- }))
|
|
|
- .then(res => transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true))
|
|
|
- .catch(e => { throw e });
|
|
|
+ });
|
|
|
+ return transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true);
|
|
|
}
|
|
|
async getCanClaimVallageList() {
|
|
|
-
|
|
|
- return (this.get('/village/village/getClaimList', '可认领村落列表', {
|
|
|
+ const res = await this.get('/village/village/getClaimList', '可认领村落列表', {
|
|
|
main_body_id: 2,
|
|
|
- }))
|
|
|
- .then(res => transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true))
|
|
|
- .catch(e => { throw e });
|
|
|
+ });
|
|
|
+ return transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true);
|
|
|
}
|
|
|
async claimVallage(data: any) {
|
|
|
- return (this.post('/village/village/addVillageClaim', {
|
|
|
- ...data
|
|
|
- }, '认领村落')) ;
|
|
|
+ return this.post('/village/village/addVillageClaim', '认领村落', data);
|
|
|
}
|
|
|
async getVallageList(level?: number, status?: number) {
|
|
|
-
|
|
|
- return (this.get('/village/village/getList', '村落列表', {
|
|
|
+ const res = await this.get('/village/village/getList', '村落列表', {
|
|
|
history_level: level,
|
|
|
status,
|
|
|
- }))
|
|
|
- .then(res => transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true))
|
|
|
- .catch(e => { throw e });
|
|
|
+ });
|
|
|
+ return transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true);
|
|
|
}
|
|
|
async getVolunteerInfo() {
|
|
|
-
|
|
|
- return (await this.post('/village/volunteer/getInfo', {
|
|
|
- }, '获取志愿者信息', undefined, VolunteerInfo)).data as VolunteerInfo
|
|
|
+ const res = await this.post('/village/volunteer/getInfo', '获取志愿者信息', {}, undefined, VolunteerInfo);
|
|
|
+ return res.data as VolunteerInfo;
|
|
|
}
|
|
|
async getVolunteerRanklist(category?: number) {
|
|
|
- return (this.post('/village/volunteer/getRanklist', {
|
|
|
+ const res = await this.post('/village/volunteer/getRanklist', '志愿者排行榜', {
|
|
|
category,
|
|
|
- }, '志愿者排行榜'))
|
|
|
- .then(res => transformArrayDataModel<VolunteerRanklistItem>(VolunteerRanklistItem, res.data2, ``, true))
|
|
|
- .catch(e => { throw e });
|
|
|
+ });
|
|
|
+ return transformArrayDataModel<VolunteerRanklistItem>(VolunteerRanklistItem, res.data2, ``, true);
|
|
|
}
|
|
|
|
|
|
async addVolunteer(data: VolunteerInfo) {
|
|
|
- return (this.post('/village/volunteer/add', data.toServerSide(), '添加志愿者')) ;
|
|
|
+ return this.post('/village/volunteer/add', '添加志愿者', data.toServerSide());
|
|
|
}
|
|
|
async updateVolunteer(data: VolunteerInfo) {
|
|
|
console.log('updateVolunteer', data.toServerSide());
|
|
|
- return (this.post('/village/volunteer/save', data.toServerSide(), '更新志愿者')) ;
|
|
|
+ return this.post('/village/volunteer/save', '更新志愿者', data.toServerSide());
|
|
|
}
|
|
|
async deleteVolunteer(id: number, villageId: number) {
|
|
|
- return (this.post('/village/volunteer/del', {
|
|
|
+ return this.post('/village/volunteer/del', '删除志愿者', {
|
|
|
id,
|
|
|
village_id: villageId,
|
|
|
- }, '删除志愿者')) ;
|
|
|
+ });
|
|
|
}
|
|
|
async shareAddVolunteer(data: VolunteerInfo) {
|
|
|
- return (await (this.post('/village/volunteer/shareAdd', data.toServerSide(), '分享添加志愿者', undefined, LoginResult))).data as LoginResult;
|
|
|
+ const res = await this.post('/village/volunteer/shareAdd', '分享添加志愿者', data.toServerSide(), undefined, LoginResult);
|
|
|
+ return res.data as LoginResult;
|
|
|
}
|
|
|
async bindVolunteer(data: {
|
|
|
account: string,
|
|
|
password: string
|
|
|
}) {
|
|
|
- return (await (this.post('/village/volunteer/bindVolunteer', data, '绑定志愿者', undefined, LoginResult))).data as LoginResult;
|
|
|
+ const res = await this.post('/village/volunteer/bindVolunteer', '绑定志愿者', data, undefined, LoginResult);
|
|
|
+ return res.data as LoginResult;
|
|
|
}
|
|
|
async bindWechat(data: { code: string }) {
|
|
|
- return (this.post('/village/volunteer/bindWechat', {
|
|
|
+ return this.post('/village/volunteer/bindWechat', '绑定微信', {
|
|
|
code: data.code,
|
|
|
appid: AppCofig.appId
|
|
|
- }, '绑定微信')) ;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
async getVolunteerInfoByIdAdmin(id: number) {
|
|
|
- return (await this.post('/village/volunteer/info', {
|
|
|
+ const res = await this.post('/village/volunteer/info', '管理员获取志愿者信息', {
|
|
|
id,
|
|
|
- }, '管理员获取志愿者信息', undefined, VolunteerInfo)).data as VolunteerInfo
|
|
|
+ }, undefined, VolunteerInfo);
|
|
|
+ return res.data as VolunteerInfo;
|
|
|
}
|
|
|
async getVolunteerInfoById(id: number) {
|
|
|
- return (await this.post('/village/volunteer/getInfo', {
|
|
|
+ const res = await this.post('/village/volunteer/getInfo', '获取志愿者信息', {
|
|
|
id,
|
|
|
- }, '获取志愿者信息', undefined, VolunteerInfo)).data as VolunteerInfo
|
|
|
+ }, undefined, VolunteerInfo);
|
|
|
+ return res.data as VolunteerInfo;
|
|
|
}
|
|
|
async getVillageVolunteerList(villageId?: number, status?: number) {
|
|
|
- return (this.post('/village/volunteer/getList', {
|
|
|
+ const res = await this.post('/village/volunteer/getList', '获取志愿者列表', {
|
|
|
village_id: villageId,
|
|
|
status,
|
|
|
- }, '获取志愿者列表'))
|
|
|
- .then(res => transformArrayDataModel<VolunteerInfo>(VolunteerInfo, res.data2 || [], ``, true))
|
|
|
- .catch(e => { throw e });
|
|
|
+ });
|
|
|
+ return transformArrayDataModel<VolunteerInfo>(VolunteerInfo, res.data2 || [], ``, true);
|
|
|
}
|
|
|
async reviewVillageVolunteer(villageId: number, volunteerId: number, status: number) {
|
|
|
- return (this.post('/village/village/claimReview', {
|
|
|
+ return this.post('/village/village/claimReview', '审核志愿者', {
|
|
|
village_id: villageId,
|
|
|
village_volunteer_id: volunteerId,
|
|
|
status,
|
|
|
- }, '审核志愿者')) ;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
async getCollectModuleList() {
|
|
|
- return (this.get('/village/volunteer/getCollectModuleList', '获取采集版块列表', {
|
|
|
- }))
|
|
|
- .then(res => {
|
|
|
- const result = [] as {
|
|
|
- value: string,
|
|
|
- label: string,
|
|
|
- }[];
|
|
|
- for (const key in res.data2) {
|
|
|
- result.push({
|
|
|
- value: key,
|
|
|
- label: res.data2[key],
|
|
|
- })
|
|
|
- }
|
|
|
- return result;
|
|
|
- })
|
|
|
- .catch(e => { throw e });
|
|
|
+ const res = await this.get('/village/volunteer/getCollectModuleList', '获取采集版块列表', {});
|
|
|
+ const result = [] as {
|
|
|
+ value: string,
|
|
|
+ label: string,
|
|
|
+ }[];
|
|
|
+ for (const key in res.data2) {
|
|
|
+ result.push({
|
|
|
+ value: key,
|
|
|
+ label: res.data2[key],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
async getCollectModuleMap() {
|
|
|
- const res = (await this.post('/village/volunteer/getCollectModuleList', {}, '采集板块列表'))
|
|
|
+ const res = await this.post('/village/volunteer/getCollectModuleList', '采集板块列表', {});
|
|
|
const map = new Map<string, number>();
|
|
|
if (!res.data2 || typeof res.data2 !== 'object')
|
|
|
return map;
|
|
|
@@ -332,20 +321,18 @@ export class VillageApi extends AppServerRequestModule<DataModel> {
|
|
|
}
|
|
|
|
|
|
async getCatalogList(villageId?: number, volunteerId?: number, pid?: number) {
|
|
|
- return (this.get('/village/village/getCatalogList', '村落目录列表', {
|
|
|
+ const res = await this.get('/village/village/getCatalogList', '村落目录列表', {
|
|
|
village_id: villageId,
|
|
|
village_volunteer_id: volunteerId,
|
|
|
pid: pid === 0 ? undefined : pid,
|
|
|
- }))
|
|
|
- .then(res => transformArrayDataModel<VillageCatalogListItem>(VillageCatalogListItem, res.data2, `村落目录列表`, true))
|
|
|
- .catch(e => { throw e });
|
|
|
+ });
|
|
|
+ return transformArrayDataModel<VillageCatalogListItem>(VillageCatalogListItem, res.data2, `村落目录列表`, true);
|
|
|
}
|
|
|
async getVillageMenuList(id: number) {
|
|
|
- return (this.get('/village/menu/getList', '村落菜单列表', {
|
|
|
+ const res = await this.get('/village/menu/getList', '村落菜单列表', {
|
|
|
village_id: id,
|
|
|
- }))
|
|
|
- .then(res => transformArrayDataModel<VillageMenuListItem>(VillageMenuListItem, res.data2, `村落菜单`, true))
|
|
|
- .catch(e => { throw e });
|
|
|
+ });
|
|
|
+ return transformArrayDataModel<VillageMenuListItem>(VillageMenuListItem, res.data2, `村落菜单`, true);
|
|
|
}
|
|
|
|
|
|
}
|