123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471 |
- import { DataModel } from '@imengyu/js-request-transform';
- import { AppServerRequestModule } from '../RequestModules';
- import dayjs from 'dayjs';
- export class CommonInfo<T extends DataModel> extends DataModel<T> {
- constructor(classCreator?: (new () => T) | undefined, name: string = '基础信息') {
- super(classCreator, name);
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
- flag: { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
- type: { clientSide: 'number', serverSide: 'number' },
- keywords: { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
- images: { clientSide: 'array', serverSide: 'string' },
- expandInfo: { serverSide: 'undefined' },
- region: { clientSide: 'number', serverSide: 'number' },
- };
- }
- contentId = null as number|null;
- collectId = null as number|null;
-
- title = '' as string;
- region = null as number|null;
- image = '' as string|null;
- imageDesc = '' as string|null;
- images = [] as string[];
- audio = '' as string|null;
- video = '' as string|null;
- flag = [] as string[];
- keywords = [] as string[];
- tags = '' as string;
- associationId = 0 as number;
- pid = 0 as number;
- content = '' as string|null;
- }
- export class IchInfo extends CommonInfo<IchInfo> {
- constructor() {
- super(IchInfo, "非遗项目信息");
- this._convertTable = {
- ...this._convertTable,
- lonlat: { serverSide: 'undefined' },
- batch: { clientSide: 'number', serverSide: 'string' },
- typicalImages: [
- {
- clientSide: 'object',
- clientSideChildDataModel: {
- convertTable: {},
- },
- serverSide: 'string'
- },
- {
- clientSide: 'addDefaultValue',
- clientSideParam: {
- defaultValue: [],
- }
- },
- ],
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('Text') || key.endsWith('_text')) {
- return {
- clientSide: 'string',
- serverSide: 'undefined',
- };
- }
- };
- this._afterSolveServer = (self) => {
- self.lonlat = [ self.longitude, self.latitude ];
- };
- this._afterSolveClient = (data) => {
- data.longitude = this.lonlat[0];
- data.latitude = this.lonlat[1];
- };
- this._beforeSolveClient = (data) => {
- this.expandInfo.batch = this.batch;
- this.expandInfo.region = this.region;
- this.expandInfo.image = this.image;
- this.expandInfo.level = this.level!;
- this.expandInfo.ichType = this.ichType!;
- this.expandInfo.contentId = this.contentId!;
- this.expandInfo.collectId = this.collectId!;
- };
- }
- lonlat = [] as (number|string)[];
- expandInfo = new IchExpandInfo();
- id = 0 as number;
- modelId = 2;
- mainBodyColumnId = 0 as number;
- ztImage = '' as string|null;
- intro = '' as string;
- description = '' as string;
- heritage = null as number|null;
- level = null as number|null;
- ichType = null as number|null;
- batch = '' as string;
- longitude = '' as string;
- latitude = '' as string;
- mapX = '' as string|null;
- mapY = '' as string|null;
- unit = '' as string;
- address = '' as string|null;
- declarationRegion = '' as string;
- popularRegion = '' as string;
- approveTime = '' as string;
- typicalImages = [] as {
- form: string,
- mobile: string,
- desc: string,
- url: string,
- }[];
- thumbnail = '' as string;
- flagText = '' as string;
- typeText = '' as string;
- openStatusText = '' as string;
- statusText = '' as string;
- regionText = '' as string;
- levelText = '' as string;
- crTypeText = '' as string;
- ichTypeText = '' as string;
- claimStatusText = '' as string;
- isMultipleClaimsText = '' as string;
- batchText = '' as string;
- ichSiteTypeText = '' as string;
- }
- export class IchExpandInfo extends DataModel<IchExpandInfo> {
- constructor() {
- super(IchExpandInfo, "非遗项目信息");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- protectLevel: { clientSide: 'number', serverSide: 'string' },
- id: { clientSide: 'number', serverSide: 'undefined' },
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('Text') || key.endsWith('_text')) {
- return {
- clientSide: 'string',
- serverSide: 'undefined',
- };
- }
- if (key.endsWith('At')) {
- return {
- clientSide: 'date',
- serverSide: 'undefined',
- };
- }
- };
- this._afterSolveServer = (self) => {
- };
- this._afterSolveClient = (data) => {
- };
- }
- id = 0 as number;
- modelId = 2;
- userId = 0 as number;
- reviewId = 0 as number;
- originId = '' as string|null;
- contentId = 0 as number;
- name = '' as string;
- level = 0 as number;
- ichType = 0 as number;
- protectLevel = null as number|null;
- image = '' as string|null;
- images = [] as string[];
- otherNames = '' as string|null;
- history = false;
- existence = false;
- folkCulture = '' as string|null;
- culturalRelic = '' as string|null;
- description = '' as string|null;
- desc = '' as string;
- mapX = '' as string|null;
- mapY = '' as string|null;
- declarationRegion = '' as string|null;
- popularRegion = '' as string|null;
- createdAt = '' as string;
- updatedAt = '' as string;
- deletedAt = '' as string|null;
- progress = 0 as number;
- comment = '' as string;
- levelText = '' as string;
- ichTypeText = '' as string;
- protectLevelText = '' as string;
- progressText = '' as string;
- }
- export class InheritorInfo extends CommonInfo<InheritorInfo> {
- constructor() {
- super(InheritorInfo, "传承人信息");
- this._convertTable = {
- ...this._convertTable,
- gender: { clientSide: 'number', serverSide: 'string' },
- level: { clientSide: 'number', serverSide: 'string' },
- batch: { clientSide: 'number', serverSide: 'string' },
- typicalImages: [
- {
- clientSide: 'object',
- clientSideChildDataModel: {
- convertTable: {},
- },
- serverSide: 'string'
- },
- {
- clientSide: 'addDefaultValue',
- clientSideParam: {
- defaultValue: [],
- }
- },
- ],
- works: {
- clientSide: 'array',
- clientSideChildDataModel: InheritorWorkInfo,
- serverSide: 'array'
- },
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('Text') || key.endsWith('_text')) {
- return {
- clientSide: 'string',
- serverSide: 'undefined',
- };
- }
- };
- }
- expandInfo = new InheritorExpandInfo();
- id = 0 as number;
- modelId = 7;
- mainBodyColumnId = 0 as number;
- alsoName = '' as string|null;
- nation = '' as string;
- dateBirth = '' as string;
- deathBirth = '' as string|null;
- unit = '' as string;
- content = '' as string|null;
- intro = '' as string;
- prize = '' as string;
- level = null as number|null;
- gender = 0 as number;
- batch = '' as string|null;
- typicalImages = [] as string[];
- progress = 0 as number;
- contentId = 0 as number;
- thumbnail = '' as string;
- flagText = '' as string;
- typeText = '' as string;
- openStatusText = '' as string;
- statusText = '' as string;
- regionText = '' as string;
- levelText = '' as string;
- crTypeText = '' as string;
- ichTypeText = '' as string;
- claimStatusText = '' as string;
- isMultipleClaimsText = '' as string;
- batchText = '' as string;
- ichSiteTypeText = '' as string;
- progressText = '' as string;
- works = [] as InheritorWorkInfo[];
- }
- export class InheritorExpandInfo extends DataModel<InheritorExpandInfo> {
- constructor() {
- super(InheritorExpandInfo, "非遗项目信息");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- gender: { clientSide: 'number', serverSide: 'string' },
- level: { clientSide: 'number', serverSide: 'string' },
- batch: { clientSide: 'number', serverSide: 'string' },
- photosJson: [
- {
- clientSide: 'object',
- clientSideChildDataModel: {
- convertTable: {},
- },
- serverSide: 'string'
- },
- {
- clientSide: 'addDefaultValue',
- clientSideParam: {
- defaultValue: [],
- }
- },
- ],
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('Text') || key.endsWith('_text')) {
- return {
- clientSide: 'string',
- serverSide: 'undefined',
- };
- }
- };
- this._afterSolveServer = (self) => {
- };
- this._afterSolveClient = (data) => {
- };
- }
- modelId = 7;
- }
- export class InheritorWorkInfo extends DataModel<InheritorWorkInfo> {
- constructor() {
- super(InheritorWorkInfo, "传承人作品");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- collectionTime: { clientSide: 'dayjs', serverSide: 'string' },
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('Text') || key.endsWith('_text')) {
- return {
- clientSide: 'string',
- serverSide: 'undefined',
- };
- }
- };
- this._afterSolveServer = (self) => {
- };
- this._afterSolveClient = (data) => {
- };
- }
- id = 0;
- category = '';
- feature = '';
- otherName = '';
- creator = '';
- language = '';
- overview = '';
- ethnicGroup = '';
- creationEra = '';
- mainPerformer = '';
- otherPerformers = '';
- fullString = '';
- tune = '';
- development = '';
- spread = '';
- influence = '';
- collector = '';
- collectionTime = dayjs();
- collectionLocation = '';
- }
- export class SeminarInfo extends CommonInfo<SeminarInfo> {
- constructor() {
- super(SeminarInfo, "传习所信息");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- ...this._convertTable,
- lonlat: { serverSide: 'undefined' },
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('Text') || key.endsWith('_text')) {
- return {
- clientSide: 'string',
- serverSide: 'undefined',
- };
- }
- };
- this._afterSolveServer = (self) => {
- self.lonlat = [ self.longitude, self.latitude ];
- };
- this._afterSolveClient = (data) => {
- data.longitude = this.lonlat[0];
- data.latitude = this.lonlat[1];
- };
- }
- lonlat = [] as (number|string)[];
- expandInfo = new SeminarExpandInfo();
- id = 0 as number;
- modelId = 17;
- mainBodyColumnId = 0 as number;
- content = '' as string|null;
- mapX = '' as string|null;
- mapY = '' as string|null;
- longitude = '' as string|null;
- latitude = '' as string|null;
- address = '' as string;
- featuresType = null as number|null;
- contact = '' as string;
- ichSiteType = '' as string;
- flagText = '' as string;
- typeText = '' as string;
- openStatusText = '' as string;
- statusText = '' as string;
- regionText = '' as string;
- levelText = '' as string;
- crTypeText = '' as string;
- ichTypeText = '' as string;
- claimStatusText = '' as string;
- isMultipleClaimsText = '' as string;
- batchText = '' as string;
- ichSiteTypeText = '' as string;
- }
- export class SeminarExpandInfo extends DataModel<SeminarExpandInfo> {
- constructor() {
- super(SeminarExpandInfo, "非遗项目信息");
- this.setNameMapperCase('Camel', 'Snake');
- this._convertTable = {
- lonlat: { serverSide: 'undefined' },
- };
- this._convertKeyType = (key, direction) => {
- if (key.endsWith('Text') || key.endsWith('_text')) {
- return {
- clientSide: 'string',
- serverSide: 'undefined',
- };
- }
- };
- this._afterSolveServer = (self) => {
- self.lonlat = [ self.longitude, self.latitude ];
- };
- this._afterSolveClient = (data) => {
- data.longitude = this.lonlat[0];
- data.latitude = this.lonlat[1];
- };
- }
- modelId = 17;
- lonlat = [] as (number|string)[];
- }
- export class InheritorContentApi extends AppServerRequestModule<DataModel> {
- constructor() {
- super();
- }
- async getBaseInfo<T extends DataModel>(newDataModel: new () => T) {
- return (await this.post('/ich/inheritor/baseInfo', {
- model_id: new newDataModel().modelId,
- }, '基础表信息', undefined, newDataModel)).data as T;
- }
- async saveBaseInfo<T extends DataModel>(dataModel: T) {
- return (await this.post('/ich/inheritor/saveBase', dataModel.toServerSide(), '基础内容表采集(非遗,传承人,传习所)'));
- }
- async getExpandInfo<T extends DataModel>(newDataModel: new () => T) {
- return (await this.post('/ich/inheritor/expandInfo', {
- model_id: new newDataModel().modelId,
- }, '扩展表信息', undefined, newDataModel)).data as T;
- }
- async saveExpandInfo<T extends DataModel>(dataModel: T) {
- return (await this.post('/ich/inheritor/saveExpand', dataModel.toServerSide(), '扩展内容表采集(非遗,传承人,传习所)'));
- }
- async getIchInfo() {
- return await this.getBaseInfo(IchInfo);
- }
- async getInheritorInfo() {
- return await this.getBaseInfo(InheritorInfo);
- }
- async getSeminarInfo() {
- return await this.getBaseInfo(SeminarInfo);
- }
- async getIchExpandInfo() {
- return await this.getExpandInfo(IchExpandInfo);
- }
- async getInheritorExpandInfo() {
- return await this.getExpandInfo(InheritorExpandInfo);
- }
- async getSeminarExpandInfo() {
- return await this.getExpandInfo(SeminarExpandInfo);
- }
- }
- export default new InheritorContentApi();
|