| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507 |
- import { DataModel, transformArrayDataModel, transformDataModel, type KeyValue } from '@imengyu/js-request-transform';
- import { AppServerRequestModule } from '../RequestModules';
- import { transformSomeToArray } from '../Utils';
- import type { MiniRender } from '@/components/canvas/MiniRender';
- export class VillageListItem extends DataModel<VillageListItem> {
- constructor() {
- super(VillageListItem, "村社详情");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- id: { clientSide: 'number', clientSideRequired: true },
- isLight: { clientSide: 'boolean' },
- region: { clientSide: 'number' },
- rank: { clientSide: 'number' },
- volunteerCount: { clientSide: 'number' },
- followCount: { clientSide: 'number' },
- collectCount: { clientSide: 'number' },
- villageType: { clientSide: 'number' },
- altitude: { clientSide: 'number' },
- longitude: { clientSide: 'number' },
- latitude: { clientSide: 'number' },
- age: { clientSide: 'number' },
- area: { clientSide: 'number' },
- villageArea: { clientSide: 'number' },
- traditionalBuildings: { clientSide: 'number' },
- ichLevel: { clientSide: 'number' },
- historyLevel: { clientSide: 'number' },
- touristLevel: { clientSide: 'number' },
- isFeaturedVillage: { clientSide: 'number' },
- registeredPopulationYear: { clientSide: 'number' },
- registeredPopulation: { clientSide: 'number' },
- permanentPopulationYear: { clientSide: 'number' },
- permanentPopulation: { clientSide: 'number' },
- personalAnnualIncomeYear: { clientSide: 'number' },
- villageAnnualIncomeYear: { clientSide: 'number' },
- points: { clientSide: 'number' },
- light: { clientSide: 'number' },
- lightTotal: { clientSide: 'number' },
- fruitOutput: { clientSide: 'number' },
- fruitRemain: { clientSide: 'number' },
- fruitToday: { clientSide: 'number' },
- level: { clientSide: 'number' },
- weight: { clientSide: 'number' },
- vipLevel: { clientSide: 'number' },
- overviewId: { clientSide: 'number' },
- myOverviewId: { clientSide: 'number' },
- treeLight: { clientSide: 'number' },
- nextTreeLight: { clientSide: 'number' },
- nextTreeLevel: { clientSide: 'number' },
- imageLimit: { clientSide: 'number' },
- storageLimit: { clientSide: 'number' },
- managerLimit: { clientSide: 'number' },
- treeImageAnimProps: { clientSide: 'json' },
- }
- 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]
- }
- this.thumbnail = this.image;
- if (!this.name && this.villageName)
- this.name = this.villageName as string;
- if (this.villageId)
- this.id = this.villageId;
- }
- }
- id !: number;
- /** 地区 */
- region = 0;
- /** 省份/省级行政区 */
- province = '' as string|null;
- /** 城市/地级行政区 */
- city = '' as string|null;
- /** 区县/县级行政区 */
- district = '' as string|null;
- /** 乡镇/乡级行政区 */
- township = '' as string|null;
- /** 拼接地址(客户端计算) */
- address = '';
- /** 村落编码 */
- code = '' as string|null;
- /** 是否点亮 */
- isLight = false;
- isLightText = '';
- lightValue = Math.random();
- villageVolunteerId = null as number|null;
- villageId !:number;
- claimReason = '';
- /** 状态: 0=完善中, 1=已归档 */
- status = '';
- statusText = '';
- createdAt = null as Date|null;
- updatedAt = null as Date|null;
- deleteAt = null as Date|null;
- /** 录入时间 */
- enterAt = null as Date|null;
- /** 封面图 */
- image = '';
- thumbnail = '';
- /** 村落形象照片 */
- images = [] as string[];
- /** 村落名称 */
- name = '';
- desc = '';
- title = '';
- /** 排名 */
- rank = 0;
- /** 乡源人数 */
- volunteerCount = 0;
- /** 关注人数 */
- followCount = 0;
- /** 采集投稿数 */
- collectCount = 0;
- /** 积分 */
- points = 0;
- /** 可用乡源光 */
- light = 0;
- /** 累计乡源光 */
- lightTotal = 0;
- /** 可产果数 */
- fruitOutput = 0;
- /** 可拾取果数 */
- fruitRemain = 0;
- /** 今日产果数 */
- fruitToday = 0;
- /** 等级 */
- level = 0;
- /** 权重 */
- weight = 0;
- volunteerName = '';
- /** 经度 */
- longitude = 0;
- /** 纬度 */
- latitude = 0;
- /** 村落类型 */
- villageType = 0;
- /** 海拔(米) */
- altitude = null as number|null;
- /** 地形地貌特征(多选) */
- landforms = '' as string|null;
- /** 村落形成年代 */
- age = null as number|null;
- /** 村域面积(平方公里) */
- area = null as number|null;
- /** 村庄占地面积(亩) */
- villageArea = null as number|null;
- /** 传统建筑数量 */
- traditionalBuildings = null as number|null;
- /** 非遗最高级别 */
- ichLevel = null as number|null;
- /** 列入历史文化名村级别 */
- historyLevel = null as number|null;
- /** 列入特色景观旅游名村级别 */
- touristLevel = null as number|null;
- /** 列入少数民族特色村寨试点示范: 0=否, 1=是 */
- isFeaturedVillage = 0;
- /** 其他认定级别 */
- other = '' as string|null;
- /** 主要民族 */
- nationlity = '' as string|null;
- /** 户籍人口年份 */
- registeredPopulationYear = null as number|null;
- /** 户籍人口 */
- registeredPopulation = null as number|null;
- /** 常住人口年份 */
- permanentPopulationYear = null as number|null;
- /** 常住人口 */
- permanentPopulation = null as number|null;
- /** 人均年收入年份 */
- personalAnnualIncomeYear = null as number|null;
- /** 人均年收入(万元) */
- personalAnnualIncome = '' as string|null;
- /** 集体年收入年份 */
- villageAnnualIncomeYear = null as number|null;
- /** 集体年收入(万元) */
- villageAnnualIncome = '' as string|null;
- /** 突出价值 */
- prominent = '' as string|null;
- /** 主要产业_农业 */
- agriculture = '' as string|null;
- /** 主要产业_其他农业 */
- otherAgriculture = '' as string|null;
- /** 主要产业_林业 */
- forestry = '' as string|null;
- /** 主要产业_畜牧业 */
- animal = '' as string|null;
- /** 主要产业_渔业 */
- fishing = '' as string|null;
- /** 主要产业_制造业(含手工) */
- manufacturing = '' as string|null;
- /** 主要产业_建筑业 */
- construction = '' as string|null;
- /** 主要产业_批发和零售业 */
- retail = '' as string|null;
- /** 主要产业_服务业 */
- service = '' as string|null;
- /** 主要产业_其他服务业 */
- otherService = '' as string|null;
- /** 主要产业_其他 */
- otherIndustries = '' as string|null;
- /** 来源 */
- source = '' as string|null;
- /** 图片说明 */
- imageDesc = '' as string|null;
- /** 组图描述 */
- imagesDesc = [] as string[];
- /** 音频 */
- audio = '' as string|null;
- /** 视频 */
- video = '' as string|null;
- /** 数字档案 */
- archives = '' as string|null;
- /** 其他附件 */
- annex = '' as string|null;
- /** 标志 */
- flag = '';
- /** 关键字 */
- keywords = '';
- /** 联系人 */
- contact = '' as string|null;
- /** 联系电话 */
- mobile = '' as string|null;
- /** 跳转链接 */
- url = '' as string|null;
- /** VIP等级 */
- vipLevel = 0;
- /** 概况最新ID */
- overviewId = null as number|null;
- /** 当前志愿者概况ID */
- myOverviewId = null as number|null;
- /** 当前等级树名称 */
- treeName = '';
- /** 当前等级树图片 */
- treeImage = '';
- /** 当前等级所需乡源光 */
- treeLight = 0;
- /** 树动画属性 */
- treeImageAnimProps ?: VillageTreeAnimProps;
- /** 下一级等级树名称 */
- nextTreeName = '';
- /** 下一级所需乡源光 */
- nextTreeLight = 0;
- /** 下一级 */
- nextTreeLevel = 0;
- /** 图片上传最大数量限制 */
- imageLimit = 0;
- /** 存储内存限制(MB) */
- storageLimit = 0;
- /** 存储内存已使用(MB) */
- storageUsed = 0;
- /** 可设置管理人员数量 */
- managerLimit = 0;
- /** 志愿者在村落昵称 */
- villageNickname = '';
- }
- export interface VillageTreeAnimProps {
- width: number,
- height: number,
- offsetX?: number,
- offsetY?: number,
- frames: MiniRender.AnimateSpriteFrame[],
- framerate: number,
- animations: Record<string, {
- frames: number[],
- }>,
- }
- export class VillageMapItem extends DataModel<VillageMapItem> {
- constructor() {
- super(VillageMapItem, "村社地图");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- villageId: { clientSide: 'number' },
- isLight: { clientSide: 'boolean' },
- latitude: { clientSide: 'number' },
- longitude: { clientSide: 'number' },
- };
- }
- villageId!: number|null;
- villageName = '';
- isLight = false;
- areaId = 0;
- areaCode = 0;
- mergerName = '';
- longitude = 0;
- latitude = 0;
- lightValue = 0;
- name = '';
- }
- export class LightVillageApi extends AppServerRequestModule<DataModel> {
- constructor() {
- super();
- }
- /**
- * 志愿者排行榜
- * POST /village/volunteer/getRanklist
- */
- async getVolunteerRankList(params?: {
- /** 地区(区域内所有村社) */
- region_id?: number;
- /** 数量:显示前几名(默认10) */
- num?: number;
- /** 村社ID */
- village_id?: number;
- }) {
- const res = await this.post<{
- id: number;
- name: string;
- mobile: string;
- points: number;
- level: number;
- type: string;
- type_text?: string;
- sex_text?: string;
- status_text?: string;
- avatar?: string;
- }[]>('/village/volunteer/getRanklist', '志愿者排行榜', params, undefined, undefined, {
- cacheEnable: true,
- cacheTime: 1000 * 60 * 10, //10min
- });
- return res.requireData();
- }
- /**
- * 村社排行榜
- * POST /village/village/getRanklist
- */
- async getVillageRankList(params?: {
- /** 地区(区域内所有村社) */
- region_id?: number;
- /** 数量:显示前几名(默认10) */
- num?: number;
- /** 点亮状态:0=未点亮,1=已点亮 */
- is_light?: number;
- }) {
- const res = await this.post<{
- id: number;
- name: string;
- points: number;
- region: number;
- status?: string;
- is_light: number | string;
- status_text?: string;
- region_text?: string;
- is_light_text?: string;
- image?: string;
- }[]>('/village/village/getRanklist', '村社排行榜', params, undefined, undefined, {
- cacheEnable: true,
- cacheTime: 1000 * 60 * 10, //10min
- });
- return res.requireData();
- }
- async getVillageList(data?: {
- level?: number,
- areaCode?: number,
- region?: number,
- status?: number,
- page?: number,
- pageSize?: number,
- keyword?: string,
- }|undefined) {
- const res = await this.get<{
- data: any[],
- total: number,
- }>('/village/village/list', '乡源村落列表', {
- history_level: data?.level,
- status: data?.status,
- region: data?.region,
- page: data?.page,
- pageSize: data?.pageSize,
- keyword: data?.keyword,
- area_code: data?.areaCode,
- });
- return {
- total: res.requireData().total,
- list: transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.requireData().data), `村落`, true)
- }
- }
-
- async getVillageDetails(id: number) {
- const res = await this.get<VillageListItem>('/village/village/getInfo', '村社详情', {
- id: id,
- }, VillageListItem);
- return res.requireData();
- }
- async getIpAddress() {
- const res = await this.get<{
- address: string,
- address_detail:{
- adcode: string,
- city: string,
- city_code: number,
- district: string,
- province: string,
- street: string,
- street_number: string,
- },
- point: {
- x: string,
- y: string,
- },
- }>('/village/volunteer/getIpArea', '获取IP地址');
- return res.requireData();
- }
- async updateVillageGallery(id: number, images: string[]) {
- return await this.post<KeyValue>('/village/village/save', '更新村社相册', {
- id: id,
- images: images,
- });
- }
- async updateVillageInfo(id: number, desc: string, image: string) {
- return await this.post<KeyValue>('/village/village/save', '更新村社基本信息', {
- id: id,
- image: image,
- desc: desc,
- });
- }
- async createVillage(data: {
- name: string,
- longitude: string,
- latitude: string,
- desc: string,
- area_code: number,
- /**
- * 村落类型:
- 95=自然村
- 96=行政村,
- 334=社区
- */
- village_type: number,
- }) {
- return await this.post<KeyValue>('/village/village/addVillage', '创建村社', data);
- }
- /**
- * 村社地图
- * POST /village/village/mapVillage
- */
- async getMapVillage(params: {
- /** 地区code */
- areaCode: number;
- }) {
- const res = await this.post<KeyValue[]>('/village/village/mapVillage', '村社地图', {
- area_code: params.areaCode,
- });
- return transformArrayDataModel<VillageMapItem>(VillageMapItem, res.requireData(), '村社地图条目', true);
- }
- async updateStorage(params: {
- /** 村社ID */
- villageId: number;
- /** 文件大小(字节) */
- memorySize: number;
- }) {
- return await this.post<KeyValue>('/village/village/updateStorage', '更新存储', {
- village_id: params.villageId,
- memory_size: params.memorySize,
- });
- }
- /**
- * 修改本志愿者在本村的昵称
- * POST /village/volunteer/nicknameSave
- */
- async nicknameSave(params: {
- /** 村社ID */
- villageId: number;
- /** 村社昵称 */
- villageNickname: string;
- }) {
- return await this.post<KeyValue>('/village/volunteer/nicknameSave', '修改志愿者昵称', {
- village_id: params.villageId,
- village_nickname: params.villageNickname,
- });
- }
- }
- export default new LightVillageApi();
|