kobe6258 пре 7 месеци
родитељ
комит
e2af81bde0

+ 5 - 1
common/component/config/ht_biz_config.go

@@ -8,6 +8,7 @@ type HTOpts struct {
 	MediaIndex  string
 	Encode      string
 	DesCode     string
+	ConfigPath  string
 }
 type HTBizConfig struct {
 	BaseConfig
@@ -28,7 +29,9 @@ func (e *HTBizConfig) NeedEncode() bool {
 	}
 	return false
 }
-
+func (e *HTBizConfig) ConfigPath() string {
+	return e.opts.ConfigPath
+}
 func (e *HTBizConfig) GetDesCode() string {
 	return e.opts.DesCode
 }
@@ -38,6 +41,7 @@ func (e *HTBizConfig) InitConfig() {
 		MediaIndex:  e.GetString("es_media_index"),
 		Encode:      e.GetString("response.encode"),
 		DesCode:     e.GetString("response.des_code"),
+		ConfigPath:  e.GetString("config_path"),
 	}
 	e.opts = opts
 }

+ 60 - 0
eta_mini_ht_api/conf/app.conf

@@ -0,0 +1,60 @@
+appname = wechat
+httpport = 80
+runmode = dev
+autorender = false
+copyrequestbody = true
+EnableDocs = true
+sqlconn =
+file.path="./conf"
+file.notice="海通小程序注册用户须知.txt"
+file.disclaimer="海通免责声明.txt"
+file.publicKey ="MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIwpWwsvZB2bZSSuFzjv5GE+spQdnd5sW2bDjnGM9hw8Zf1kXuOO2ThuokXgr0iHjQU5WHbrkcefUcvJmQ9NLJ0CAwEAAQ=="
+[dev]
+#系统配置
+
+#验证码长度
+auth.code.length=6
+#redis配置
+#redis.host = 192.168.77.130:6379,127.0.0.1:6379
+redis.host = 192.168.77.130:6379
+redis.password = ""
+redis.db = 0
+redis.maxidle = 50
+redis.maxactive = 100
+redis.timeout = 300
+
+#HT
+ht.es_report_index = "ht_test_report_v1"
+ht.es_media_index="ht_test_media_v1"
+#ht.es_report_index = "report_index"
+#ht.es_media_index="media_index"
+ht.response.encode="false"
+ht.response.des_code="5filp4vSvLVQK8SLioNlKm3q"
+#wechat配置
+#wechat.appid = wx49f965502877530a
+#wechat.secret= eef0b899951d5d5074915e1f56c5e87a
+wechat.appid = wxcc4ac5526a578908
+wechat.secret= a289a3a3289e4ede54932216931ed16f
+#短信
+sms.sms_type = "juhe"
+sms.juhe.tlp_id="254663"
+sms.juhe.expire_minute=3
+sms.juhe.key="4c8504c49dd335e99cfd7b6a3a9e2415"
+sms.emas.url="root:199118@(localhost:3306)/emas?timeout=5000ms&readTimeout=5000ms&writeTimeout=5000ms&charset=utf8mb4&parseTime=true&loc=Local"
+sms.emas.expire_minute=3
+sms.emas.template="【期海通行】您的期海通行小程序验证码为:{{.Code}},请在{{.ExpireMinute}}分钟内完成验证。"
+#database配置
+database.driver = "mysql"
+database.url="hz_technology:hongze@2021@tcp(rm-uf67kg347rhjfep5c1o.mysql.rds.aliyuncs.com:3306)/test_eta_mini_master_ht?charset=utf8mb4&loc=Asia%2FShanghai&parseTime=true"
+#database.url="root:199118@tcp(localhost:3306)/wechat?charset=utf8mb4&loc=Asia%2FShanghai&parseTime=true"
+#eta数据库配置
+eta.database.url= "hz_technology:hongze@2021@tcp(rm-uf67kg347rhjfep5c1o.mysql.rds.aliyuncs.com:3306)/test_v2_hongze_rddp?charset=utf8mb4&loc=Asia%2FShanghai&parseTime=true"
+#钢联数据库配置
+gl.database.url= "hz_technology:hongze@2021@tcp(rm-uf67kg347rhjfep5c1o.mysql.rds.aliyuncs.com:3306)/test_eta_mini_master_ht?charset=utf8mb4&loc=Asia%2FShanghai&parseTime=true"
+#ES配置
+#es.url="http://192.168.77.130:9200"
+es.url="http://es-cn-nif227b580019rgw6.public.elasticsearch.aliyuncs.com:9200"
+es.username="elastic"
+es.password="hongze@2021"
+#es.password="DV=NPV7pTEbRJ4JnMNnt"
+[test]

+ 57 - 0
eta_mini_ht_api/conf/log/log_config.json

@@ -0,0 +1,57 @@
+{
+  "filepath": "./etalogs",
+  "appenders": [
+    {
+      "type": "console",
+      "rotate": true,
+      "level": "info",
+      "color": true
+    },
+    {
+      "type": "file",
+      "filename": "file/error.log",
+      "maxlines": 1000000,
+      "maxsize": 268435456,
+      "daily": true,
+      "maxdays": 7,
+      "rotate": true,
+      "level": "error",
+      "color": true
+    },
+    {
+      "type": "file",
+      "filename": "file/info.log",
+      "maxlines": 1000000,
+      "maxsize": 268435456,
+      "daily": true,
+      "maxdays": 30,
+      "rotate": true,
+      "level": "info",
+      "color": true
+    },
+    {
+      "filter": "apiRequest",
+      "type": "file",
+      "filename": "api/api.log",
+      "maxlines": 1000000,
+      "maxsize": 268435456,
+      "daily": true,
+      "maxdays": 30,
+      "rotate": true,
+      "level": "info",
+      "color": true
+    },
+    {
+      "filter": "coin,orm....*",
+      "type": "file",
+      "filename": "db/db.log",
+      "maxlines": 1000000,
+      "maxsize": 268435456,
+      "daily": false,
+      "maxdays": 30,
+      "rotate": true,
+      "level": "info",
+      "color": true
+    }
+  ]
+}

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/conf/海通免责声明.txt


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/conf/海通小程序注册用户须知.txt


BIN
eta_mini_ht_api/eta_mini_ht_api


BIN
eta_mini_ht_api/eta_mini_ht_api.exe


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


+ 60 - 0
eta_mini_ht_api/swagger/index.html

@@ -0,0 +1,60 @@
+<!-- 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>

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

@@ -0,0 +1,79 @@
+<!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>

Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
eta_mini_ht_api/swagger/swagger-ui-bundle.js


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui-bundle.js.map


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui-es-bundle-core.js


Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
eta_mini_ht_api/swagger/swagger-ui-es-bundle.js


Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
eta_mini_ht_api/swagger/swagger-ui-standalone-preset.js


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui-standalone-preset.js.map


Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
eta_mini_ht_api/swagger/swagger-ui.css


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui.css.map


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui.js


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
eta_mini_ht_api/swagger/swagger-ui.js.map


+ 151 - 0
eta_mini_ht_api/swagger/swagger.json

@@ -0,0 +1,151 @@
+{
+    "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"
+        }
+    ]
+}

+ 107 - 0
eta_mini_ht_api/swagger/swagger.yml

@@ -0,0 +1,107 @@
+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

+ 11 - 1
main.go

@@ -2,6 +2,7 @@ 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"
@@ -11,6 +12,7 @@ import (
 	_ "eta/eta_mini_ht_api/routers"
 	_ "eta/eta_mini_ht_api/task"
 	"github.com/beego/beego/v2/server/web"
+	"log"
 	"sync"
 	"time"
 )
@@ -20,7 +22,15 @@ 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)
+		}
+	}
 	//web.ErrorHandler("*", exception.ControllerAdvice())
 	web.BConfig.RecoverFunc = exception.PanicAdvice
 	go func() {

Неке датотеке нису приказане због велике количине промена