Przeglądaj źródła

增加配置文件

kobe6258 6 miesięcy temu
rodzic
commit
a3b0fe5cde

+ 14 - 0
common/component/component.go

@@ -7,9 +7,23 @@ import (
 	_ "eta/eta_mini_ht_api/common/component/sms"
 	"eta/eta_mini_ht_api/common/contants"
 	"eta/eta_mini_ht_api/common/utils/sms"
+	"fmt"
+	"github.com/beego/beego/v2/server/web"
+	"log"
 )
 
 func init() {
+	tmpRunMode, err := web.AppConfig.String("run_mode")
+	if err != nil {
+		panic(any("配置文件读取run_mode错误 " + err.Error()))
+	}
+	fmt.Println("RunMode:", tmpRunMode)
+	configPath := "/home/code/config/eta_mini_ht_api/conf/app.conf"
+	logger.Info("加载配置文件:%v", configPath)
+	err = web.LoadAppConfig("ini", configPath)
+	if err != nil {
+		log.Fatalf("web.LoadAppConfig Err:%v", err)
+	}
 	//配置SMS平台,没有配置直接报错
 	if smsConf, ok := config.GetConfig(contants.SMS).(*config.SMSConfig); ok && smsConf != nil {
 		logger.Info("开始加载短信平台客户端")

BIN
eta_mini_ht_api/eta_mini_ht_api.exe → eta_mini_ht_api.tar.gz


+ 1 - 1
eta_mini_ht_api/conf/app.conf

@@ -26,6 +26,7 @@ redis.timeout = 300
 #HT
 ht.es_report_index = "ht_test_report_v1"
 ht.es_media_index="ht_test_media_v1"
+#ht.config_path="/home/code/config/eta_mini_ht_api/conf/app.conf"
 #ht.es_report_index = "report_index"
 #ht.es_media_index="media_index"
 ht.response.encode="false"
@@ -57,4 +58,3 @@ es.url="http://es-cn-nif227b580019rgw6.public.elasticsearch.aliyuncs.com:9200"
 es.username="elastic"
 es.password="hongze@2021"
 #es.password="DV=NPV7pTEbRJ4JnMNnt"
-[test]

BIN
eta_mini_ht_api/eta_mini_ht_api


BIN
eta_mini_ht_api/swagger.zip


BIN
eta_mini_ht_api/swagger/favicon-16x16.png


BIN
eta_mini_ht_api/swagger/favicon-32x32.png


+ 0 - 60
eta_mini_ht_api/swagger/index.html

@@ -1,60 +0,0 @@
-<!-- HTML for static distribution bundle build -->
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="UTF-8">
-    <title>Swagger UI</title>
-    <link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
-    <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
-    <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
-    <style>
-      html
-      {
-        box-sizing: border-box;
-        overflow: -moz-scrollbars-vertical;
-        overflow-y: scroll;
-      }
-
-      *,
-      *:before,
-      *:after
-      {
-        box-sizing: inherit;
-      }
-
-      body
-      {
-        margin:0;
-        background: #fafafa;
-      }
-    </style>
-  </head>
-
-  <body>
-    <div id="swagger-ui"></div>
-
-    <script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
-    <script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
-    <script>
-    window.onload = function() {
-      // Begin Swagger UI call region
-      const ui = SwaggerUIBundle({
-        url: "https://petstore.swagger.io/v2/swagger.json",
-        dom_id: '#swagger-ui',
-        deepLinking: true,
-        presets: [
-          SwaggerUIBundle.presets.apis,
-          SwaggerUIStandalonePreset
-        ],
-        plugins: [
-          SwaggerUIBundle.plugins.DownloadUrl
-        ],
-        layout: "StandaloneLayout"
-      });
-      // End Swagger UI call region
-
-      window.ui = ui;
-    };
-  </script>
-  </body>
-</html>

+ 0 - 79
eta_mini_ht_api/swagger/oauth2-redirect.html

@@ -1,79 +0,0 @@
-<!doctype html>
-<html lang="en-US">
-<head>
-    <title>Swagger UI: OAuth2 Redirect</title>
-</head>
-<body>
-<script>
-    'use strict';
-    function run () {
-        var oauth2 = window.opener.swaggerUIRedirectOauth2;
-        var sentState = oauth2.state;
-        var redirectUrl = oauth2.redirectUrl;
-        var isValid, qp, arr;
-
-        if (/code|token|error/.test(window.location.hash)) {
-            qp = window.location.hash.substring(1);
-        } else {
-            qp = location.search.substring(1);
-        }
-
-        arr = qp.split("&");
-        arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
-        qp = qp ? JSON.parse('{' + arr.join() + '}',
-                function (key, value) {
-                    return key === "" ? value : decodeURIComponent(value);
-                }
-        ) : {};
-
-        isValid = qp.state === sentState;
-
-        if ((
-          oauth2.auth.schema.get("flow") === "accessCode" ||
-          oauth2.auth.schema.get("flow") === "authorizationCode" ||
-          oauth2.auth.schema.get("flow") === "authorization_code"
-        ) && !oauth2.auth.code) {
-            if (!isValid) {
-                oauth2.errCb({
-                    authId: oauth2.auth.name,
-                    source: "auth",
-                    level: "warning",
-                    message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
-                });
-            }
-
-            if (qp.code) {
-                delete oauth2.state;
-                oauth2.auth.code = qp.code;
-                oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
-            } else {
-                let oauthErrorMsg;
-                if (qp.error) {
-                    oauthErrorMsg = "["+qp.error+"]: " +
-                        (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
-                        (qp.error_uri ? "More info: "+qp.error_uri : "");
-                }
-
-                oauth2.errCb({
-                    authId: oauth2.auth.name,
-                    source: "auth",
-                    level: "error",
-                    message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
-                });
-            }
-        } else {
-            oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
-        }
-        window.close();
-    }
-
-    if (document.readyState !== 'loading') {
-        run();
-    } else {
-        document.addEventListener('DOMContentLoaded', function () {
-            run();
-        });
-    }
-</script>
-</body>
-</html>

Plik diff jest za duży
+ 0 - 1
eta_mini_ht_api/swagger/swagger-ui-bundle.js


Plik diff jest za duży
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui-bundle.js.map


Plik diff jest za duży
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui-es-bundle-core.js


Plik diff jest za duży
+ 0 - 1
eta_mini_ht_api/swagger/swagger-ui-es-bundle.js


Plik diff jest za duży
+ 0 - 1
eta_mini_ht_api/swagger/swagger-ui-standalone-preset.js


Plik diff jest za duży
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui-standalone-preset.js.map


Plik diff jest za duży
+ 0 - 1
eta_mini_ht_api/swagger/swagger-ui.css


Plik diff jest za duży
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui.css.map


Plik diff jest za duży
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui.js


Plik diff jest za duży
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui.js.map


+ 0 - 151
eta_mini_ht_api/swagger/swagger.json

@@ -1,151 +0,0 @@
-{
-    "swagger": "2.0",
-    "info": {
-        "contact": {}
-    },
-    "basePath": "/htapi",
-    "paths": {
-        "/auth/login": {
-            "post": {
-                "tags": [
-                    "auth"
-                ],
-                "summary": "小程序用户登录",
-                "description": "用户通过微信小程序登录\n\u003cbr\u003e",
-                "parameters": [
-                    {
-                        "in": "body",
-                        "name": "mobile",
-                        "description": "登录请求体",
-                        "required": true,
-                        "schema": {
-                            "$ref": "#/definitions/LoginReq"
-                        }
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "",
-                        "schema": {
-                            "$ref": "#/definitions/controllers.BaseResponse"
-                        }
-                    }
-                }
-            }
-        },
-        "/auth/sendCode": {
-            "post": {
-                "tags": [
-                    "auth"
-                ],
-                "summary": "获取手机验证码",
-                "description": "用户发送手机验证码\n\u003cbr\u003e",
-                "parameters": [
-                    {
-                        "in": "body",
-                        "name": "mobile",
-                        "description": "小程序手机验证码接口",
-                        "required": true,
-                        "schema": {
-                            "$ref": "#/definitions/SmsCodeReq"
-                        }
-                    }
-                ],
-                "responses": {
-                    "200": {
-                        "description": "",
-                        "schema": {
-                            "$ref": "#/definitions/controllers.BaseResponse"
-                        }
-                    }
-                }
-            }
-        },
-        "/report/list": {
-            "get": {
-                "tags": [
-                    "report"
-                ],
-                "description": "get all Users\n\u003cbr\u003e",
-                "operationId": "ReportController.GetAll",
-                "responses": {
-                    "200": {
-                        "description": "",
-                        "schema": {
-                            "$ref": "#/definitions/models.User"
-                        }
-                    }
-                }
-            }
-        },
-        "/user/": {
-            "get": {
-                "tags": [
-                    "user"
-                ],
-                "description": "get all Users\n\u003cbr\u003e",
-                "operationId": "UserController.GetAll",
-                "responses": {
-                    "200": {
-                        "description": "",
-                        "schema": {
-                            "$ref": "#/definitions/models.User"
-                        }
-                    }
-                }
-            }
-        }
-    },
-    "definitions": {
-        "LoginReq": {
-            "title": "LoginReq",
-            "type": "object"
-        },
-        "SmsCodeReq": {
-            "title": "SmsCodeReq",
-            "type": "object"
-        },
-        "controllers.BaseResponse": {
-            "title": "BaseResponse",
-            "type": "object",
-            "properties": {
-                "Data": {
-                    "$ref": "#/definitions/controllers.interface"
-                },
-                "ErrCode": {
-                    "type": "integer",
-                    "format": "int64"
-                },
-                "ErrMsg": {
-                    "type": "string"
-                },
-                "Msg": {
-                    "type": "string"
-                },
-                "Ret": {
-                    "description": "返回状态码",
-                    "type": "integer",
-                    "format": "int64"
-                },
-                "Success": {
-                    "description": "true 执行成功,false 执行失败",
-                    "type": "boolean"
-                }
-            }
-        },
-        "controllers.interface": {
-            "title": "interface",
-            "type": "object"
-        },
-        "models.User": {
-            "title": "User",
-            "type": "object"
-        }
-    },
-    "tags": [
-        {
-            "name": "user",
-            "description": "Operations about Users\n"
-        }
-    ]
-}

+ 0 - 107
eta_mini_ht_api/swagger/swagger.yml

@@ -1,107 +0,0 @@
-swagger: "2.0"
-info: {}
-basePath: /htapi
-paths:
-  /auth/login:
-    post:
-      tags:
-      - auth
-      summary: 小程序用户登录
-      description: |-
-        用户通过微信小程序登录
-        <br>
-      parameters:
-      - in: body
-        name: mobile
-        description: 登录请求体
-        required: true
-        schema:
-          $ref: '#/definitions/LoginReq'
-      responses:
-        "200":
-          description: ""
-          schema:
-            $ref: '#/definitions/controllers.BaseResponse'
-  /auth/sendCode:
-    post:
-      tags:
-      - auth
-      summary: 获取手机验证码
-      description: |-
-        用户发送手机验证码
-        <br>
-      parameters:
-      - in: body
-        name: mobile
-        description: 小程序手机验证码接口
-        required: true
-        schema:
-          $ref: '#/definitions/SmsCodeReq'
-      responses:
-        "200":
-          description: ""
-          schema:
-            $ref: '#/definitions/controllers.BaseResponse'
-  /report/list:
-    get:
-      tags:
-      - report
-      description: |-
-        get all Users
-        <br>
-      operationId: ReportController.GetAll
-      responses:
-        "200":
-          description: ""
-          schema:
-            $ref: '#/definitions/models.User'
-  /user/:
-    get:
-      tags:
-      - user
-      description: |-
-        get all Users
-        <br>
-      operationId: UserController.GetAll
-      responses:
-        "200":
-          description: ""
-          schema:
-            $ref: '#/definitions/models.User'
-definitions:
-  LoginReq:
-    title: LoginReq
-    type: object
-  SmsCodeReq:
-    title: SmsCodeReq
-    type: object
-  controllers.BaseResponse:
-    title: BaseResponse
-    type: object
-    properties:
-      Data:
-        $ref: '#/definitions/controllers.interface'
-      ErrCode:
-        type: integer
-        format: int64
-      ErrMsg:
-        type: string
-      Msg:
-        type: string
-      Ret:
-        description: 返回状态码
-        type: integer
-        format: int64
-      Success:
-        description: true 执行成功,false 执行失败
-        type: boolean
-  controllers.interface:
-    title: interface
-    type: object
-  models.User:
-    title: User
-    type: object
-tags:
-- name: user
-  description: |
-    Operations about Users

+ 1 - 11
main.go

@@ -2,7 +2,6 @@ package main
 
 import (
 	_ "eta/eta_mini_ht_api/common/component"
-	"eta/eta_mini_ht_api/common/component/config"
 	logger "eta/eta_mini_ht_api/common/component/log"
 	"eta/eta_mini_ht_api/common/contants"
 	"eta/eta_mini_ht_api/common/exception"
@@ -12,7 +11,6 @@ import (
 	_ "eta/eta_mini_ht_api/routers"
 	_ "eta/eta_mini_ht_api/task"
 	"github.com/beego/beego/v2/server/web"
-	"log"
 	"sync"
 	"time"
 )
@@ -22,15 +20,7 @@ func main() {
 		web.BConfig.WebConfig.DirectoryIndex = true
 		web.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
 	}
-	sysConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
-	configPath := sysConfig.ConfigPath()
-	if configPath != "" {
-		logger.Info("加载配置文件:%v", configPath)
-		err := web.LoadAppConfig("ini", configPath)
-		if err != nil {
-			log.Fatalf("web.LoadAppConfig Err:%v", err)
-		}
-	}
+	//sysConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
 	//web.ErrorHandler("*", exception.ControllerAdvice())
 	web.BConfig.RecoverFunc = exception.PanicAdvice
 	go func() {

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików