Просмотр исходного кода

Merge branch 'Thailand' of https://gitee.com/chengdu-weichu-network/congkong into Thailand

gitxsm 1 год назад
Родитель
Сommit
c1acfbddd7
2 измененных файлов с 44 добавлено и 5 удалено
  1. 33 5
      webServer/src/controller/ApiController.ts
  2. 11 0
      webServer/src/model/SystemModel.ts

+ 33 - 5
webServer/src/controller/ApiController.ts

@@ -22,6 +22,7 @@ import {
 const CryptoJS = require("crypto-js");
 const Order = require('../model/OrderModel')
 const Server = require('../model/ServerModel')
+const System = require('../model/SystemModel')
 const User = require('../model/UserModel')
 const Version = require('../model/VersionModel')
 const CDK = require("../model/CDK")
@@ -1146,19 +1147,46 @@ class ApiController {
             platform = ctx.query.platform
         }
 
-        switch (platform) {
+        let content = ''
+        let content_wh = ''
+        const system = await System.getSystemConfig()
+
+        if(system){
+            system.forEach(element => {
+                
+                if(element.key == 'content'){
+                    content = element.value
+                }
+
+                if(element.key == 'content_wh'){
+                    content_wh = element.value
+                }
+
+            });
+        }
+        
+        let notice_data = {
+            status : 1,
+            content: content,
+            content_wh:content_wh
+        }
+
+        if(notice_data.content == ''){
+                switch (platform) {
             case 'th':
-                ctx.body = th_notice
+                notice_data = th_notice
                 break;
             case '360':
-                ctx.body = notice
+                notice_data = notice
                 break;
             case 'xky':
-                ctx.body = xky_notice
+                notice_data = xky_notice
                 break;
             default:
-                ctx.body = notice
+                notice_data = notice
+        }
         }
+        ctx.body = notice_data
     }
 
 

+ 11 - 0
webServer/src/model/SystemModel.ts

@@ -0,0 +1,11 @@
+import { query } from '../sql/query'; // 确保路径是正确的
+
+class SystemModel {
+    //获取订单
+    async getSystemConfig() {
+        return await query('SELECT * FROM system_config',[])
+    }
+
+}
+
+module.exports = new SystemModel()