InheritorContent.ts 11 KB

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