lrf 1 month ago
parent
commit
d734c907d2

+ 3 - 1
src/config/config.local.ts

@@ -10,7 +10,8 @@ const v2DbName = 'water_service_v2'
 const dbUsername = 'root';
 /**数据库密码 */
 const dbPwd = 'root';
-
+/**旧文件域名 */
+const urlDomain = 'https://36.135.104.33'
 export default {
   keys: '1697684406848_4978',
   koa: {
@@ -18,6 +19,7 @@ export default {
     globalPrefix: '/warter/front/v2/api',
     queryParseMode: 'extended',
   },
+  urlDomain,
   typeorm: {
     dataSource: {
       default: {

+ 3 - 1
src/config/config.prod.ts

@@ -13,7 +13,8 @@ const dbPwd = 'ccshuitou';
 
 const dbv2 = 'water_v2'
 const dbv2Pwd = 'ccshuitou'
-
+/**旧文件域名 */
+const urlDomain = 'http://10.2.2.18:9004'
 export default {
   keys: '1697684406848_4978',
   koa: {
@@ -26,6 +27,7 @@ export default {
       level: 'info'
     }
   },
+  urlDomain,
   typeorm: {
     dataSource: {
       default: {

+ 2 - 1
src/controller/jtxw.controller.ts

@@ -33,7 +33,8 @@ export class JtxwController {
         content_id: get(i, 'content_id'),
         id: get(i, 'content_id'),
         title: get(i, 'ext.title'),
-        brief: get(i, 'ext.description'),
+        brief: get(i, 'txt.txt'),
+        desc: get(i, 'ext.description'),
         date: get(i, 'ext.release_date'),
         url: get(i, 'ext.title_img')
       }

+ 25 - 0
src/controller/oldFile.controller.ts

@@ -0,0 +1,25 @@
+import { Config, Controller, Get, Inject } from "@midwayjs/core";
+import { Context } from '@midwayjs/koa';
+import { makeHttpRequest } from '@midwayjs/core';
+import { get } from "lodash";
+import * as mime from 'mime-types';
+@Controller('/u/cms', { ignoreGlobalPrefix: true })
+export class OldFileController {
+  @Inject()
+  ctx: Context;
+  @Config('urlDomain')
+  urlDomain: string
+
+
+  @Get('/**')
+  async getFile() {
+    const req = this.ctx.request
+    const uri = req.url;
+    const newUrl = `${this.urlDomain}${uri}`
+    const result = await makeHttpRequest(newUrl, { rejectUnauthorized: false })
+    const type = mime.lookup(uri);
+    this.ctx.response.set('content-type', type);
+    this.ctx.body = get(result, 'data');
+  }
+
+}