123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- import { CONVERTER_ADD_DEFAULT, DataModel, transformArrayDataModel } from '@imengyu/js-request-transform';
- import { AppServerRequestModule } from '../RequestModules';
- import { transformSomeToArray } from '@/common/request/utils/Utils';
- export class VillageListItem extends DataModel<VillageListItem> {
- constructor() {
- super(VillageListItem, "活动列表");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
- }
- this._nameMapperServer = {
- name: 'villageName',
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('At'))
- return {
- clientSide: 'date',
- serverSide: 'string',
- };
- return undefined;
- };
- this._afterSolveServer = () => {
- this.address =
- (this.province || '未知省') +
- (this.city || '未知市') +
- (this.district || '未知区') +
- (this.township || '未知村');
- if (this.images && this.images && this.images.length > 0 ) {
- this.image = this.images[0]
- }
- }
- }
- id !: number;
- province = '' as string|null;
- city = '' as string|null;
- district = '' as string|null;
- township = '' as string|null;
- address = '';
- villageVolunteerId = null as number|null;
- villageId = null as number|null;
- claimReason = '';
- status = '';
- statusText = '';
- createdAt = null as Date|null;
- updatedAt = null as Date|null;
- deleteAt = null as Date|null;
- image = '';
- images = [] as string[];
- villageName = '';
- volunteerName = '';
- }
- export class VolunteerRanklistItem extends DataModel<VolunteerRanklistItem> {
- constructor() {
- super(VolunteerRanklistItem, "活动列表");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
- points: [{ clientSide: 'number', serverSide: 'number' }, { clientSide: CONVERTER_ADD_DEFAULT, clientSideParam: { defaultValue: 0 } }],
- level: [{ clientSide: 'number', serverSide: 'number' }, { clientSide: CONVERTER_ADD_DEFAULT, clientSideParam: { defaultValue: 0 } }],
- }
- }
- id !: number;
- name = '';
- mobile = '';
- points = 0;
- level = 0;
- typeText = '';
- sexText = '';
- statusText = '';
- image = '';
- }
- export class VolunteerInfo extends DataModel<VolunteerInfo> {
- constructor() {
- super(VolunteerInfo, "活动列表");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
- points: [{ clientSide: 'number', serverSide: 'number' }, { clientSide: CONVERTER_ADD_DEFAULT, clientSideParam: { defaultValue: 0 } }],
- level: [{ clientSide: 'number', serverSide: 'number' }, { clientSide: CONVERTER_ADD_DEFAULT, clientSideParam: { defaultValue: 0 } }],
- }
- }
- id !: number;
- mainBodyId !: number;
- type = '';
- name = '';
- sex = 0;
- mobile = '';
- regionId = null as number|null;
- address = '';
- image = '';
- birthday = new Date();
- intro = '';
- points = 0;
- level = 0;
- status = '';
- createdAt = '';
- updatedAt = '';
- typeText = '';
- sexText = '';
- statusText = '';
- }
- export class VillageMenuListItem extends DataModel<VillageMenuListItem> {
- constructor() {
- super(VillageMenuListItem, "村落菜单列表");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
- }
- this._nameMapperServer = {
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('At'))
- return {
- clientSide: 'date',
- serverSide: 'string',
- };
- return undefined;
- };
- }
- name = '';
- logo = '';
- }
- export class VillageApi extends AppServerRequestModule<DataModel> {
- constructor() {
- super();
- }
- async getClaimedVallageList(volunteerId?: string) {
- return (this.get('/village/village/getVillageList', '获取已认领村落', {
- village_volunteer_id: volunteerId,
- }))
- .then(res => transformArrayDataModel<VillageListItem>(VillageListItem, res.data2, `村落`, true))
- .catch(e => { throw e });
- }
- async getCanClaimVallageList() {
- return (this.get('/village/village/getClaimList', '可认领村落列表', {
- main_body_id: 2,
- }))
- .then(res => transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true))
- .catch(e => { throw e });
- }
- async claimVallage(data: any) {
- return (this.post('/village/village/addVillageClaim', {
- ...data
- }, '认领村落')) ;
- }
- async getVallageList() {
- return (this.get('/village/village/getList', '村落列表', {
- main_body_id: 2,
- }))
- .then(res => transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data2), `村落`, true))
- .catch(e => { throw e });
- }
- async getVolunteerInfo() {
- return (await this.post('/village/volunteer/getInfo', {
- }, '获取志愿者信息', undefined, VolunteerInfo)).data as VolunteerInfo
- }
- async getVolunteerRanklist(category?: number) {
- return (this.post('/village/volunteer/getRanklist', {
- category,
- }, '志愿者排行榜'))
- .then(res => transformArrayDataModel<VolunteerRanklistItem>(VolunteerRanklistItem, res.data2, ``, true))
- .catch(e => { throw e });
- }
-
- async getVillageMenuList(id: number) {
- return (this.get('/village/menu/getList', '村落菜单列表', {
- village_id: id,
- }))
- .then(res => transformArrayDataModel<VillageMenuListItem>(VillageMenuListItem, res.data2, `村落菜单`, true))
- .catch(e => { throw e });
- }
- }
- export default new VillageApi();
|