InheritorContent.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. import { DataModel } from '@imengyu/js-request-transform';
  2. import { AppServerRequestModule } from '../RequestModules';
  3. import dayjs from 'dayjs';
  4. export class CommonInfo<T extends DataModel> extends DataModel<T> {
  5. constructor(classCreator?: (new () => T) | undefined, name: string = '基础信息') {
  6. super(classCreator, name);
  7. this.setNameMapperCase('Camel', 'Snake');
  8. this._convertTable = {
  9. id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
  10. flag: { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
  11. type: { clientSide: 'number', serverSide: 'number' },
  12. keywords: { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
  13. images: { clientSide: 'array', serverSide: 'string' },
  14. expandInfo: { serverSide: 'undefined' },
  15. region: { clientSide: 'number', serverSide: 'number' },
  16. };
  17. }
  18. contentId = null as number|null;
  19. collectId = null as number|null;
  20. title = '' as string;
  21. region = null as number|null;
  22. image = '' as string|null;
  23. imageDesc = '' as string|null;
  24. images = [] as string[];
  25. audio = '' as string|null;
  26. video = '' as string|null;
  27. flag = [] as string[];
  28. keywords = [] as string[];
  29. tags = '' as string;
  30. associationId = 0 as number;
  31. pid = 0 as number;
  32. content = '' as string|null;
  33. }
  34. export class IchInfo extends CommonInfo<IchInfo> {
  35. constructor() {
  36. super(IchInfo, "非遗项目信息");
  37. this._convertTable = {
  38. ...this._convertTable,
  39. lonlat: { serverSide: 'undefined' },
  40. batch: { clientSide: 'number', serverSide: 'string' },
  41. typicalImages: [
  42. {
  43. clientSide: 'object',
  44. clientSideChildDataModel: {
  45. convertTable: {},
  46. },
  47. serverSide: 'string'
  48. },
  49. {
  50. clientSide: 'addDefaultValue',
  51. clientSideParam: {
  52. defaultValue: [],
  53. }
  54. },
  55. ],
  56. };
  57. this._convertKeyType = (key, direction) => {
  58. if (key.endsWith('Text') || key.endsWith('_text')) {
  59. return {
  60. clientSide: 'string',
  61. serverSide: 'undefined',
  62. };
  63. }
  64. };
  65. this._afterSolveServer = (self) => {
  66. self.lonlat = [ self.longitude, self.latitude ];
  67. };
  68. this._afterSolveClient = (data) => {
  69. data.longitude = this.lonlat[0];
  70. data.latitude = this.lonlat[1];
  71. };
  72. this._beforeSolveClient = (data) => {
  73. this.expandInfo.batch = this.batch;
  74. this.expandInfo.region = this.region;
  75. this.expandInfo.image = this.image;
  76. this.expandInfo.level = this.level!;
  77. this.expandInfo.ichType = this.ichType!;
  78. this.expandInfo.contentId = this.contentId!;
  79. this.expandInfo.collectId = this.collectId!;
  80. };
  81. }
  82. lonlat = [] as (number|string)[];
  83. expandInfo = new IchExpandInfo();
  84. id = 0 as number;
  85. modelId = 2;
  86. mainBodyColumnId = 0 as number;
  87. ztImage = '' as string|null;
  88. intro = '' as string;
  89. description = '' as string;
  90. heritage = null as number|null;
  91. level = null as number|null;
  92. ichType = null as number|null;
  93. batch = '' as string;
  94. longitude = '' as string;
  95. latitude = '' as string;
  96. mapX = '' as string|null;
  97. mapY = '' as string|null;
  98. unit = '' as string;
  99. address = '' as string|null;
  100. declarationRegion = '' as string;
  101. popularRegion = '' as string;
  102. approveTime = '' as string;
  103. typicalImages = [] as {
  104. form: string,
  105. mobile: string,
  106. desc: string,
  107. url: string,
  108. }[];
  109. thumbnail = '' as string;
  110. flagText = '' as string;
  111. typeText = '' as string;
  112. openStatusText = '' as string;
  113. statusText = '' as string;
  114. regionText = '' as string;
  115. levelText = '' as string;
  116. crTypeText = '' as string;
  117. ichTypeText = '' as string;
  118. claimStatusText = '' as string;
  119. isMultipleClaimsText = '' as string;
  120. batchText = '' as string;
  121. ichSiteTypeText = '' as string;
  122. }
  123. export class IchExpandInfo extends DataModel<IchExpandInfo> {
  124. constructor() {
  125. super(IchExpandInfo, "非遗项目信息");
  126. this.setNameMapperCase('Camel', 'Snake');
  127. this._convertTable = {
  128. protectLevel: { clientSide: 'number', serverSide: 'string' },
  129. id: { clientSide: 'number', serverSide: 'undefined' },
  130. };
  131. this._convertKeyType = (key, direction) => {
  132. if (key.endsWith('Text') || key.endsWith('_text')) {
  133. return {
  134. clientSide: 'string',
  135. serverSide: 'undefined',
  136. };
  137. }
  138. if (key.endsWith('At')) {
  139. return {
  140. clientSide: 'date',
  141. serverSide: 'undefined',
  142. };
  143. }
  144. };
  145. this._afterSolveServer = (self) => {
  146. };
  147. this._afterSolveClient = (data) => {
  148. };
  149. }
  150. id = 0 as number;
  151. modelId = 2;
  152. userId = 0 as number;
  153. reviewId = 0 as number;
  154. originId = '' as string|null;
  155. contentId = 0 as number;
  156. name = '' as string;
  157. level = 0 as number;
  158. ichType = 0 as number;
  159. protectLevel = null as number|null;
  160. image = '' as string|null;
  161. images = [] as string[];
  162. otherNames = '' as string|null;
  163. history = false;
  164. existence = false;
  165. folkCulture = '' as string|null;
  166. culturalRelic = '' as string|null;
  167. description = '' as string|null;
  168. desc = '' as string;
  169. mapX = '' as string|null;
  170. mapY = '' as string|null;
  171. declarationRegion = '' as string|null;
  172. popularRegion = '' as string|null;
  173. createdAt = '' as string;
  174. updatedAt = '' as string;
  175. deletedAt = '' as string|null;
  176. progress = 0 as number;
  177. comment = '' as string;
  178. levelText = '' as string;
  179. ichTypeText = '' as string;
  180. protectLevelText = '' as string;
  181. progressText = '' as string;
  182. }
  183. export class InheritorInfo extends CommonInfo<InheritorInfo> {
  184. constructor() {
  185. super(InheritorInfo, "传承人信息");
  186. this._convertTable = {
  187. ...this._convertTable,
  188. gender: { clientSide: 'number', serverSide: 'string' },
  189. level: { clientSide: 'number', serverSide: 'string' },
  190. batch: { clientSide: 'number', serverSide: 'string' },
  191. typicalImages: [
  192. {
  193. clientSide: 'object',
  194. clientSideChildDataModel: {
  195. convertTable: {},
  196. },
  197. serverSide: 'string'
  198. },
  199. {
  200. clientSide: 'addDefaultValue',
  201. clientSideParam: {
  202. defaultValue: [],
  203. }
  204. },
  205. ],
  206. works: {
  207. clientSide: 'array',
  208. clientSideChildDataModel: InheritorWorkInfo,
  209. serverSide: 'array'
  210. },
  211. };
  212. this._convertKeyType = (key, direction) => {
  213. if (key.endsWith('Text') || key.endsWith('_text')) {
  214. return {
  215. clientSide: 'string',
  216. serverSide: 'undefined',
  217. };
  218. }
  219. };
  220. }
  221. expandInfo = new InheritorExpandInfo();
  222. id = 0 as number;
  223. modelId = 7;
  224. mainBodyColumnId = 0 as number;
  225. alsoName = '' as string|null;
  226. nation = '' as string;
  227. dateBirth = '' as string;
  228. deathBirth = '' as string|null;
  229. unit = '' as string;
  230. content = '' as string|null;
  231. intro = '' as string;
  232. prize = '' as string;
  233. level = null as number|null;
  234. gender = 0 as number;
  235. batch = '' as string|null;
  236. typicalImages = [] as string[];
  237. progress = 0 as number;
  238. contentId = 0 as number;
  239. thumbnail = '' as string;
  240. flagText = '' as string;
  241. typeText = '' as string;
  242. openStatusText = '' as string;
  243. statusText = '' as string;
  244. regionText = '' as string;
  245. levelText = '' as string;
  246. crTypeText = '' as string;
  247. ichTypeText = '' as string;
  248. claimStatusText = '' as string;
  249. isMultipleClaimsText = '' as string;
  250. batchText = '' as string;
  251. ichSiteTypeText = '' as string;
  252. progressText = '' as string;
  253. works = [] as InheritorWorkInfo[];
  254. }
  255. export class InheritorExpandInfo extends DataModel<InheritorExpandInfo> {
  256. constructor() {
  257. super(InheritorExpandInfo, "非遗项目信息");
  258. this.setNameMapperCase('Camel', 'Snake');
  259. this._convertTable = {
  260. gender: { clientSide: 'number', serverSide: 'string' },
  261. level: { clientSide: 'number', serverSide: 'string' },
  262. batch: { clientSide: 'number', serverSide: 'string' },
  263. photosJson: [
  264. {
  265. clientSide: 'object',
  266. clientSideChildDataModel: {
  267. convertTable: {},
  268. },
  269. serverSide: 'string'
  270. },
  271. {
  272. clientSide: 'addDefaultValue',
  273. clientSideParam: {
  274. defaultValue: [],
  275. }
  276. },
  277. ],
  278. };
  279. this._convertKeyType = (key, direction) => {
  280. if (key.endsWith('Text') || key.endsWith('_text')) {
  281. return {
  282. clientSide: 'string',
  283. serverSide: 'undefined',
  284. };
  285. }
  286. };
  287. this._afterSolveServer = (self) => {
  288. };
  289. this._afterSolveClient = (data) => {
  290. };
  291. }
  292. modelId = 7;
  293. }
  294. export class InheritorWorkInfo extends DataModel<InheritorWorkInfo> {
  295. constructor() {
  296. super(InheritorWorkInfo, "传承人作品");
  297. this.setNameMapperCase('Camel', 'Snake');
  298. this._convertTable = {
  299. collectionTime: { clientSide: 'dayjs', serverSide: 'string' },
  300. };
  301. this._convertKeyType = (key, direction) => {
  302. if (key.endsWith('Text') || key.endsWith('_text')) {
  303. return {
  304. clientSide: 'string',
  305. serverSide: 'undefined',
  306. };
  307. }
  308. };
  309. this._afterSolveServer = (self) => {
  310. };
  311. this._afterSolveClient = (data) => {
  312. };
  313. }
  314. id = 0;
  315. category = '';
  316. feature = '';
  317. otherName = '';
  318. creator = '';
  319. language = '';
  320. overview = '';
  321. ethnicGroup = '';
  322. creationEra = '';
  323. mainPerformer = '';
  324. otherPerformers = '';
  325. fullString = '';
  326. tune = '';
  327. development = '';
  328. spread = '';
  329. influence = '';
  330. collector = '';
  331. collectionTime = dayjs();
  332. collectionLocation = '';
  333. }
  334. export class SeminarInfo extends CommonInfo<SeminarInfo> {
  335. constructor() {
  336. super(SeminarInfo, "传习所信息");
  337. this.setNameMapperCase('Camel', 'Snake');
  338. this._convertTable = {
  339. ...this._convertTable,
  340. lonlat: { serverSide: 'undefined' },
  341. };
  342. this._convertKeyType = (key, direction) => {
  343. if (key.endsWith('Text') || key.endsWith('_text')) {
  344. return {
  345. clientSide: 'string',
  346. serverSide: 'undefined',
  347. };
  348. }
  349. };
  350. this._afterSolveServer = (self) => {
  351. self.lonlat = [ self.longitude, self.latitude ];
  352. };
  353. this._afterSolveClient = (data) => {
  354. data.longitude = this.lonlat[0];
  355. data.latitude = this.lonlat[1];
  356. };
  357. }
  358. lonlat = [] as (number|string)[];
  359. expandInfo = new SeminarExpandInfo();
  360. id = 0 as number;
  361. modelId = 17;
  362. mainBodyColumnId = 0 as number;
  363. content = '' as string|null;
  364. mapX = '' as string|null;
  365. mapY = '' as string|null;
  366. longitude = '' as string|null;
  367. latitude = '' as string|null;
  368. address = '' as string;
  369. featuresType = null as number|null;
  370. contact = '' as string;
  371. ichSiteType = '' as string;
  372. flagText = '' as string;
  373. typeText = '' as string;
  374. openStatusText = '' as string;
  375. statusText = '' as string;
  376. regionText = '' as string;
  377. levelText = '' as string;
  378. crTypeText = '' as string;
  379. ichTypeText = '' as string;
  380. claimStatusText = '' as string;
  381. isMultipleClaimsText = '' as string;
  382. batchText = '' as string;
  383. ichSiteTypeText = '' as string;
  384. }
  385. export class SeminarExpandInfo extends DataModel<SeminarExpandInfo> {
  386. constructor() {
  387. super(SeminarExpandInfo, "非遗项目信息");
  388. this.setNameMapperCase('Camel', 'Snake');
  389. this._convertTable = {
  390. lonlat: { serverSide: 'undefined' },
  391. };
  392. this._convertKeyType = (key, direction) => {
  393. if (key.endsWith('Text') || key.endsWith('_text')) {
  394. return {
  395. clientSide: 'string',
  396. serverSide: 'undefined',
  397. };
  398. }
  399. };
  400. this._afterSolveServer = (self) => {
  401. self.lonlat = [ self.longitude, self.latitude ];
  402. };
  403. this._afterSolveClient = (data) => {
  404. data.longitude = this.lonlat[0];
  405. data.latitude = this.lonlat[1];
  406. };
  407. }
  408. modelId = 17;
  409. lonlat = [] as (number|string)[];
  410. }
  411. export class InheritorContentApi extends AppServerRequestModule<DataModel> {
  412. constructor() {
  413. super();
  414. }
  415. async getBaseInfo<T extends DataModel>(newDataModel: new () => T) {
  416. return (await this.post('/ich/inheritor/baseInfo', {
  417. model_id: new newDataModel().modelId,
  418. }, '基础表信息', undefined, newDataModel)).data as T;
  419. }
  420. async saveBaseInfo<T extends DataModel>(dataModel: T) {
  421. return (await this.post('/ich/inheritor/saveBase', dataModel.toServerSide(), '基础内容表采集(非遗,传承人,传习所)'));
  422. }
  423. async getExpandInfo<T extends DataModel>(newDataModel: new () => T) {
  424. return (await this.post('/ich/inheritor/expandInfo', {
  425. model_id: new newDataModel().modelId,
  426. }, '扩展表信息', undefined, newDataModel)).data as T;
  427. }
  428. async saveExpandInfo<T extends DataModel>(dataModel: T) {
  429. return (await this.post('/ich/inheritor/saveExpand', dataModel.toServerSide(), '扩展内容表采集(非遗,传承人,传习所)'));
  430. }
  431. async getIchInfo() {
  432. return await this.getBaseInfo(IchInfo);
  433. }
  434. async getInheritorInfo() {
  435. return await this.getBaseInfo(InheritorInfo);
  436. }
  437. async getSeminarInfo() {
  438. return await this.getBaseInfo(SeminarInfo);
  439. }
  440. async getIchExpandInfo() {
  441. return await this.getExpandInfo(IchExpandInfo);
  442. }
  443. async getInheritorExpandInfo() {
  444. return await this.getExpandInfo(InheritorExpandInfo);
  445. }
  446. async getSeminarExpandInfo() {
  447. return await this.getExpandInfo(SeminarExpandInfo);
  448. }
  449. }
  450. export default new InheritorContentApi();