diff --git a/Document/东师理想数智创新中心软件研发管理办法v1.docx b/Document/东师理想数智创新中心软件研发管理办法v1.docx new file mode 100644 index 00000000..26a9b722 Binary files /dev/null and b/Document/东师理想数智创新中心软件研发管理办法v1.docx differ diff --git a/dsBaseWeb/docs/docs.go b/dsBaseWeb/docs/docs.go index 31fe5865..c7f2d055 100644 --- a/dsBaseWeb/docs/docs.go +++ b/dsBaseWeb/docs/docs.go @@ -1,18 +1,18 @@ -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT -// This file was generated by swaggo/swag at -// 2020-05-20 14:45:12.3054401 +0800 CST m=+0.096772501 - -package docs - -import ( - "bytes" - "encoding/json" - "strings" - - "github.com/alecthomas/template" - "github.com/swaggo/swag" -) - +// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT +// This file was generated by swaggo/swag at +// 2020-05-20 14:45:12.3054401 +0800 CST m=+0.096772501 + +package docs + +import ( + "bytes" + "encoding/json" + "strings" + + "github.com/alecthomas/template" + "github.com/swaggo/swag" +) + var doc = `{ "definitions": { "Model.Res": { @@ -2059,17 +2059,26 @@ var doc = `{ "version": "1.0" }, "paths": { +<<<<<<< HEAD "/base/business/UpdateBaseBusiness": { +======= + "/base/business/DeleteBaseBusiness": { +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "post": { "consumes": [ "application/x-www-form-urlencoded" ], +<<<<<<< HEAD "description": "修改业务系统信息", +======= + "description": "删除业务系统信息", +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "parameters": [ { "description": "业务系统编码", "in": "formData", "name": "businessCode", +<<<<<<< HEAD "required": true, "type": "string" }, @@ -2077,6 +2086,8 @@ var doc = `{ "description": "业务系统名称", "in": "formData", "name": "businessName", +======= +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "required": true, "type": "string" } @@ -2092,20 +2103,31 @@ var doc = `{ } } }, +<<<<<<< HEAD "summary": "修改业务系统信息", +======= + "summary": "删除业务系统信息", +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "tags": [ "业务系统维护" ], "x-emptylimit": [ +<<<<<<< HEAD "businessCode", "businessName" +======= + "businessCode" +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d ], "x-lengthlimit": [ { "businessCode": "6,6" +<<<<<<< HEAD }, { "businessName": "1:50" +======= +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d } ], "x-rolelimit": [ @@ -2210,11 +2232,16 @@ var doc = `{ ] } }, +<<<<<<< HEAD "/base/business/PageBaseBusiness": { +======= + "/base/business/GetBaseBusiness": { +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "get": { "consumes": [ "application/x-www-form-urlencoded" ], +<<<<<<< HEAD "description": "获取业务系统信息(列表)", "parameters": [ { @@ -2230,6 +2257,16 @@ var doc = `{ "name": "limit", "required": true, "type": "integer" +======= + "description": "获取业务系统信息(单条)", + "parameters": [ + { + "description": "业务系统编码", + "in": "query", + "name": "businessCode", + "required": true, + "type": "string" +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d } ], "produces": [ @@ -2243,36 +2280,56 @@ var doc = `{ } } }, +<<<<<<< HEAD "summary": "获取业务系统信息(列表)", +======= + "summary": "获取业务系统信息(单条)", +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "tags": [ "业务系统维护" ], "x-emptylimit": [ +<<<<<<< HEAD "page", "limit" ], "x-intlimit": [ "page", "limit" +======= + "businessCode" + ], + "x-lengthlimit": [ + { + "businessCode": "6,6" + } +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d ], "x-rolelimit": [ "1" ] } }, - "/base/business/GetBaseBusiness": { + "/base/business/PageBaseBusiness": { "get": { "consumes": [ "application/x-www-form-urlencoded" ], - "description": "获取业务系统信息(单条)", + "description": "获取业务系统信息(列表)", "parameters": [ { - "description": "业务系统编码", + "description": "第几页", "in": "query", - "name": "businessCode", + "name": "page", "required": true, - "type": "string" + "type": "integer" + }, + { + "description": "一页显示多少条", + "in": "query", + "name": "limit", + "required": true, + "type": "integer" } ], "produces": [ @@ -2286,17 +2343,17 @@ var doc = `{ } } }, - "summary": "获取业务系统信息(单条)", + "summary": "获取业务系统信息(列表)", "tags": [ "业务系统维护" ], "x-emptylimit": [ - "businessCode" + "page", + "limit" ], - "x-lengthlimit": [ - { - "businessCode": "6,6" - } + "x-intlimit": [ + "page", + "limit" ], "x-rolelimit": [ "1" @@ -7652,12 +7709,12 @@ var doc = `{ ] } }, - "/base/organization/PageMainSchoolInfo": { + "/base/organization/PageSchoolInfo": { "get": { "consumes": [ "application/x-www-form-urlencoded" ], - "description": "获取主校列表", + "description": "获取学校列表", "parameters": [ { "description": "第几页", @@ -7681,9 +7738,16 @@ var doc = `{ "type": "string" }, { - "description": "学校ID,增加学校时无需传,修改学校时需要传被修改学校的ID", + "description": "学校办学类型 -1:全部", "in": "query", - "name": "orgId", + "name": "xxbxlxm", + "required": true, + "type": "string" + }, + { + "description": "学校名称", + "in": "query", + "name": "orgName", "type": "string" } ], @@ -7694,11 +7758,11 @@ var doc = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/base.organization.PageMainSchoolInfo" + "$ref": "#/definitions/base.organization.PageSchoolInfo" } } }, - "summary": "获取主校列表", + "summary": "获取学校列表", "tags": [ "组织机构" ], @@ -7728,6 +7792,9 @@ var doc = `{ "x-lengthlimit": [ { "areaCode": "6,6" + }, + { + "orgName": "1,30" } ], "x-removeswaggerfield": [ @@ -7771,12 +7838,12 @@ var doc = `{ ] } }, - "/base/organization/PageSchoolInfo": { + "/base/organization/PageMainSchoolInfo": { "get": { "consumes": [ "application/x-www-form-urlencoded" ], - "description": "获取学校列表", + "description": "获取主校列表", "parameters": [ { "description": "第几页", @@ -7800,16 +7867,9 @@ var doc = `{ "type": "string" }, { - "description": "学校办学类型 -1:全部", - "in": "query", - "name": "xxbxlxm", - "required": true, - "type": "string" - }, - { - "description": "学校名称", + "description": "学校ID,增加学校时无需传,修改学校时需要传被修改学校的ID", "in": "query", - "name": "orgName", + "name": "orgId", "type": "string" } ], @@ -7820,11 +7880,11 @@ var doc = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/base.organization.PageSchoolInfo" + "$ref": "#/definitions/base.organization.PageMainSchoolInfo" } } }, - "summary": "获取学校列表", + "summary": "获取主校列表", "tags": [ "组织机构" ], @@ -7854,9 +7914,6 @@ var doc = `{ "x-lengthlimit": [ { "areaCode": "6,6" - }, - { - "orgName": "1,30" } ], "x-removeswaggerfield": [ @@ -9001,6 +9058,7 @@ var doc = `{ ] } }, +<<<<<<< HEAD "/base/area/DeleteGovArea": { "post": { "consumes": [ @@ -9052,6 +9110,10 @@ var doc = `{ }, "/base/area/AddGovArea": { "post": { +======= + "/base/area/PageGovArea": { + "get": { +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "consumes": [ "application/x-www-form-urlencoded" ], @@ -9257,6 +9319,58 @@ var doc = `{ ] } }, + "/base/area/GetGovArea": { + "get": { + "consumes": [ + "application/x-www-form-urlencoded" + ], + "description": "获取行政区划信息(单条)", + "parameters": [ + { + "description": "行政区划码", + "in": "query", + "name": "areaCode", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Model.Res" + } + } + }, + "summary": "获取行政区划信息(单条)", + "tags": [ + "行政区划" + ], + "x-emptylimit": [ + "areaCode" + ], + "x-intlimit": [ + "areaCode" + ], + "x-lengthlimit": [ + { + "areaCode": "6,6" + } + ], + "x-rolelimit": [ + "1", + "2", + "3", + "4", + "5", + "6", + "7" + ] + } + }, "/base/role/GetManageAreaInfo": { "get": { "consumes": [ @@ -9352,51 +9466,51 @@ var doc = `{ } }, "swagger": "2.0" -}` - -type swaggerInfo struct { - Version string - Host string - BasePath string - Schemes []string - Title string - Description string -} - -// SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = swaggerInfo{ - Version: "1.0", - Host: "127.0.0.1:8002", - BasePath: "", - Schemes: []string{}, - Title: "基础数据API", - Description: "分布式,大并发,高可用", -} - -type s struct{} - -func (s *s) ReadDoc() string { - sInfo := SwaggerInfo - sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) - - t, err := template.New("swagger_info").Funcs(template.FuncMap{ - "marshal": func(v interface{}) string { - a, _ := json.Marshal(v) - return string(a) - }, - }).Parse(doc) - if err != nil { - return doc - } - - var tpl bytes.Buffer - if err := t.Execute(&tpl, sInfo); err != nil { - return doc - } - - return tpl.String() -} - -func init() { - swag.Register(swag.Name, &s{}) -} +}` + +type swaggerInfo struct { + Version string + Host string + BasePath string + Schemes []string + Title string + Description string +} + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = swaggerInfo{ + Version: "1.0", + Host: "127.0.0.1:8002", + BasePath: "", + Schemes: []string{}, + Title: "基础数据API", + Description: "分布式,大并发,高可用", +} + +type s struct{} + +func (s *s) ReadDoc() string { + sInfo := SwaggerInfo + sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1) + + t, err := template.New("swagger_info").Funcs(template.FuncMap{ + "marshal": func(v interface{}) string { + a, _ := json.Marshal(v) + return string(a) + }, + }).Parse(doc) + if err != nil { + return doc + } + + var tpl bytes.Buffer + if err := t.Execute(&tpl, sInfo); err != nil { + return doc + } + + return tpl.String() +} + +func init() { + swag.Register(swag.Name, &s{}) +} diff --git a/dsBaseWeb/docs/swagger.json b/dsBaseWeb/docs/swagger.json index d2e99898..15e05632 100644 --- a/dsBaseWeb/docs/swagger.json +++ b/dsBaseWeb/docs/swagger.json @@ -2044,17 +2044,26 @@ "version": "1.0" }, "paths": { +<<<<<<< HEAD "/base/business/UpdateBaseBusiness": { +======= + "/base/business/DeleteBaseBusiness": { +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "post": { "consumes": [ "application/x-www-form-urlencoded" ], +<<<<<<< HEAD "description": "修改业务系统信息", +======= + "description": "删除业务系统信息", +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "parameters": [ { "description": "业务系统编码", "in": "formData", "name": "businessCode", +<<<<<<< HEAD "required": true, "type": "string" }, @@ -2062,6 +2071,8 @@ "description": "业务系统名称", "in": "formData", "name": "businessName", +======= +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "required": true, "type": "string" } @@ -2077,20 +2088,31 @@ } } }, +<<<<<<< HEAD "summary": "修改业务系统信息", +======= + "summary": "删除业务系统信息", +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "tags": [ "业务系统维护" ], "x-emptylimit": [ +<<<<<<< HEAD "businessCode", "businessName" +======= + "businessCode" +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d ], "x-lengthlimit": [ { "businessCode": "6,6" +<<<<<<< HEAD }, { "businessName": "1:50" +======= +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d } ], "x-rolelimit": [ @@ -2195,11 +2217,16 @@ ] } }, +<<<<<<< HEAD "/base/business/PageBaseBusiness": { +======= + "/base/business/GetBaseBusiness": { +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "get": { "consumes": [ "application/x-www-form-urlencoded" ], +<<<<<<< HEAD "description": "获取业务系统信息(列表)", "parameters": [ { @@ -2215,6 +2242,16 @@ "name": "limit", "required": true, "type": "integer" +======= + "description": "获取业务系统信息(单条)", + "parameters": [ + { + "description": "业务系统编码", + "in": "query", + "name": "businessCode", + "required": true, + "type": "string" +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d } ], "produces": [ @@ -2228,36 +2265,56 @@ } } }, +<<<<<<< HEAD "summary": "获取业务系统信息(列表)", +======= + "summary": "获取业务系统信息(单条)", +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "tags": [ "业务系统维护" ], "x-emptylimit": [ +<<<<<<< HEAD "page", "limit" ], "x-intlimit": [ "page", "limit" +======= + "businessCode" + ], + "x-lengthlimit": [ + { + "businessCode": "6,6" + } +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d ], "x-rolelimit": [ "1" ] } }, - "/base/business/GetBaseBusiness": { + "/base/business/PageBaseBusiness": { "get": { "consumes": [ "application/x-www-form-urlencoded" ], - "description": "获取业务系统信息(单条)", + "description": "获取业务系统信息(列表)", "parameters": [ { - "description": "业务系统编码", + "description": "第几页", "in": "query", - "name": "businessCode", + "name": "page", "required": true, - "type": "string" + "type": "integer" + }, + { + "description": "一页显示多少条", + "in": "query", + "name": "limit", + "required": true, + "type": "integer" } ], "produces": [ @@ -2271,17 +2328,17 @@ } } }, - "summary": "获取业务系统信息(单条)", + "summary": "获取业务系统信息(列表)", "tags": [ "业务系统维护" ], "x-emptylimit": [ - "businessCode" + "page", + "limit" ], - "x-lengthlimit": [ - { - "businessCode": "6,6" - } + "x-intlimit": [ + "page", + "limit" ], "x-rolelimit": [ "1" @@ -7637,12 +7694,12 @@ ] } }, - "/base/organization/PageMainSchoolInfo": { + "/base/organization/PageSchoolInfo": { "get": { "consumes": [ "application/x-www-form-urlencoded" ], - "description": "获取主校列表", + "description": "获取学校列表", "parameters": [ { "description": "第几页", @@ -7666,9 +7723,16 @@ "type": "string" }, { - "description": "学校ID,增加学校时无需传,修改学校时需要传被修改学校的ID", + "description": "学校办学类型 -1:全部", "in": "query", - "name": "orgId", + "name": "xxbxlxm", + "required": true, + "type": "string" + }, + { + "description": "学校名称", + "in": "query", + "name": "orgName", "type": "string" } ], @@ -7679,11 +7743,11 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/base.organization.PageMainSchoolInfo" + "$ref": "#/definitions/base.organization.PageSchoolInfo" } } }, - "summary": "获取主校列表", + "summary": "获取学校列表", "tags": [ "组织机构" ], @@ -7713,6 +7777,9 @@ "x-lengthlimit": [ { "areaCode": "6,6" + }, + { + "orgName": "1,30" } ], "x-removeswaggerfield": [ @@ -7756,12 +7823,12 @@ ] } }, - "/base/organization/PageSchoolInfo": { + "/base/organization/PageMainSchoolInfo": { "get": { "consumes": [ "application/x-www-form-urlencoded" ], - "description": "获取学校列表", + "description": "获取主校列表", "parameters": [ { "description": "第几页", @@ -7785,16 +7852,9 @@ "type": "string" }, { - "description": "学校办学类型 -1:全部", - "in": "query", - "name": "xxbxlxm", - "required": true, - "type": "string" - }, - { - "description": "学校名称", + "description": "学校ID,增加学校时无需传,修改学校时需要传被修改学校的ID", "in": "query", - "name": "orgName", + "name": "orgId", "type": "string" } ], @@ -7805,11 +7865,11 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/base.organization.PageSchoolInfo" + "$ref": "#/definitions/base.organization.PageMainSchoolInfo" } } }, - "summary": "获取学校列表", + "summary": "获取主校列表", "tags": [ "组织机构" ], @@ -7839,9 +7899,6 @@ "x-lengthlimit": [ { "areaCode": "6,6" - }, - { - "orgName": "1,30" } ], "x-removeswaggerfield": [ @@ -8986,6 +9043,7 @@ ] } }, +<<<<<<< HEAD "/base/area/DeleteGovArea": { "post": { "consumes": [ @@ -9037,6 +9095,10 @@ }, "/base/area/AddGovArea": { "post": { +======= + "/base/area/PageGovArea": { + "get": { +>>>>>>> ea05e18bf61c824e573165ebe8d10662bcbbc82d "consumes": [ "application/x-www-form-urlencoded" ], @@ -9242,6 +9304,58 @@ ] } }, + "/base/area/GetGovArea": { + "get": { + "consumes": [ + "application/x-www-form-urlencoded" + ], + "description": "获取行政区划信息(单条)", + "parameters": [ + { + "description": "行政区划码", + "in": "query", + "name": "areaCode", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/Model.Res" + } + } + }, + "summary": "获取行政区划信息(单条)", + "tags": [ + "行政区划" + ], + "x-emptylimit": [ + "areaCode" + ], + "x-intlimit": [ + "areaCode" + ], + "x-lengthlimit": [ + { + "areaCode": "6,6" + } + ], + "x-rolelimit": [ + "1", + "2", + "3", + "4", + "5", + "6", + "7" + ] + } + }, "/base/role/GetManageAreaInfo": { "get": { "consumes": [ diff --git a/dsBigData/Business/Student/StudentDao/StudentDao.go b/dsBigData/Business/Student/StudentDao/StudentDao.go index 94961dc5..e7e18513 100644 --- a/dsBigData/Business/Student/StudentDao/StudentDao.go +++ b/dsBigData/Business/Student/StudentDao/StudentDao.go @@ -192,7 +192,7 @@ func GetStudentCountAggsOrgId(schoolIds []string) ([]StudentModel.StudentCountAg } func GetStudentCountAggsRxnf(schoolId string, stageId string) ([]StudentModel.StudentCountRxnf, error) { - + /* endYear := time.Now().Year() startYear := 0 month := CommonUtil.ConvertStringToInt32(time.Now().Format("1")) @@ -205,16 +205,17 @@ func GetStudentCountAggsRxnf(schoolId string, stageId string) ([]StudentModel.St } else { startYear = endYear - 2 } + */ orgIdTerm := elastic.NewTermQuery("org_id", schoolId) stageIdTerm := elastic.NewTermQuery("data_content.stage_id", stageId) - rxnfRang := elastic.NewRangeQuery("data_content.rxnf").Gte(startYear).Lte(endYear) + //rxnfRang := elastic.NewRangeQuery("data_content.rxnf").Gte(startYear).Lte(endYear) bUseTerm := elastic.NewTermQuery("data_content.b_use", 1) enableFlagTerm := elastic.NewTermQuery("enable_flag", 1) delFlagTerm := elastic.NewTermQuery("del_flag", 0) - boolQuery := elastic.NewBoolQuery().Must(orgIdTerm, stageIdTerm, bUseTerm, rxnfRang, enableFlagTerm, delFlagTerm) - + boolQuery := elastic.NewBoolQuery().Must(orgIdTerm, stageIdTerm, bUseTerm, enableFlagTerm, delFlagTerm) + //boolQuery := elastic.NewBoolQuery().Must(orgIdTerm, stageIdTerm, bUseTerm, rxnfRang, enableFlagTerm, delFlagTerm) //rxnfHistogramAggregation := elastic.NewHistogramAggregation().Field("data_content.rxnf").MinDocCount(0).ExtendedBounds(float64(startYear), float64(endYear)).Interval(1) rxnfAggs := elastic. diff --git a/dsBigData/build/dsBigData b/dsBigData/build/dsBigData index 82e37c66..382d8755 100644 Binary files a/dsBigData/build/dsBigData and b/dsBigData/build/dsBigData differ diff --git a/dsDataex/Config/Config.ini b/dsDataex/Config/Config.ini index 87e4206a..66999bff 100644 --- a/dsDataex/Config/Config.ini +++ b/dsDataex/Config/Config.ini @@ -25,6 +25,7 @@ expireTime = 86400 [kafka] brokers = 10.10.14.238:9092, ;brokers = 192.168.0.200:9092,192.168.0.200:9091 +KafkaAccessLogTopic = log_dataex partition = 20 replication = 1 process_no = 1 diff --git a/dsDataex/MiddleWare/Middleware.go b/dsDataex/MiddleWare/Middleware.go new file mode 100644 index 00000000..aa2ef3f5 --- /dev/null +++ b/dsDataex/MiddleWare/Middleware.go @@ -0,0 +1,161 @@ +package Middleware + +import ( + "dsDataex/Utils/CommonUtil" + "dsDataex/Utils/ConfigUtil" + "dsDataex/Utils/KafkaUtil" + "github.com/gin-gonic/gin" + "github.com/sirupsen/logrus" + "github.com/tracer0tong/kafkalogrus" + "os" + "strings" + "time" +) + +//转为东八区时间 +type CSTFormatter struct { + logrus.Formatter +} + +func (u CSTFormatter) Format(e *logrus.Entry) ([]byte, error) { + e.Time = e.Time.Local() + return u.Formatter.Format(e) +} + +//add by zhangjun 2020-08-03 +func stringEndWith(input string) bool { + + if strings.Contains(input,".png"){ return true } + if strings.Contains(input,".jpg"){ return true } + if strings.Contains(input,".js"){ return true } + if strings.Contains(input,".css"){ return true } + if strings.Contains(input,".ico"){ return true } + if strings.Contains(input,".svg"){ return true} + if strings.Contains(input,".gif"){ return true } + return false +} + +func init() { + var err error + var hook *kafkalogrus.KafkaLogrusHook + + //add by zhangjun 2020-08-03 + //初始化 topic,多个 partition,提高数据批处理性能。 + KafkaUtil.InitTopic(ConfigUtil.KafkaAccessLogTopic) + + if hook, err = kafkalogrus.NewKafkaLogrusHook( + "kh", + logrus.AllLevels, + &logrus.JSONFormatter{}, + //change by zhangjun 2020-08-03 + //[]string{ConfigUtil.KafkaAddress}, + ConfigUtil.KafkaBrokers, + ConfigUtil.KafkaAccessLogTopic, + true, + nil); err != nil { + panic(err) + } + + //设置日志格式 + logrus.SetFormatter(CSTFormatter{&logrus.JSONFormatter{}}) + + //add by zhangjun 2020-08-03 + src, _:= os.OpenFile("./gin_server.log", os.O_APPEND|os.O_WRONLY, os.ModeAppend) + logrus.SetOutput(src) + + logrus.AddHook(hook) +} + +// 日志记录到 Kafka +func LoggerToKafka() gin.HandlerFunc { + return func(c *gin.Context) { + // 开始时间 + startTime := time.Now().Local() + // 处理请求 + c.Next() + // 结束时间 + endTime := time.Now().Local() + // 执行时间 + latencyTime := endTime.Sub(startTime).Seconds() + // 请求方式 + reqMethod := c.Request.Method + // 请求路由 + reqUri := c.Request.RequestURI + // 状态码 + statusCode := c.Writer.Status() + // 请求IP + clientIP := c.ClientIP() + + //统一认证的会话id + //var identityId = -1 + //var personId = -1 + var deviceId = -1 + /* + cookie, e := c.Request.Cookie(ConfigUtil.SessionId) + if e == nil { + deviceId, identityId, personId = SsoUtil.AnalyzeSessionId(cookie.Value) + } + */ + + personId, err := c.Cookie("person_id") + if err != nil { + personId = "-1" + } + identityId, err := c.Cookie("identity_id") + if err != nil { + identityId = "-1" + } + + //add by zhangjun 2020-08-03 + broswerId, err := c.Cookie("browser_id") + if err != nil { + broswerId = "-1" + } + var properties=make(map[string]interface{}) + + properties["req_method"]=reqMethod + properties["latency_time"]=latencyTime + properties["status_code"]=statusCode + + strs:=strings.Split(reqUri,"/") + properties["req_action"]=strs[len(strs)-1] + + //一般静态文件 + if stringEndWith( strs[len(strs)-1]){ + return + } + + //change by zhangjun 2020-08-03 + // 日志格式 + //logrus.WithFields(logrus.Fields{ + // "status_code": statusCode, + // "access_time": startTime, + // "latency_time": latencyTime, + // "client_ip": clientIP, + // "req_method": reqMethod, + // "req_uri": reqUri, + // "device_id": deviceId, + // "identity_id": identityId, + // "person_id": personId, + //}).Info() + logrus.WithFields(logrus.Fields{ + "system_id":ConfigUtil.ProjectName, + "datasource_id":ConfigUtil.KafkaAccessLogTopic, + "data_id":CommonUtil.GetUUID(), + + "user_id":personId, + "identity":identityId, + "access_id":broswerId, + "access_ip":clientIP, + "access_way":deviceId, + + "event_type":"101", + "event_name":"gin_webrequest", + "event_time":startTime.Format("2006/01/02 15:04:05"), + "event_uri":reqUri, + "event_seqno":0, + "collect_time":endTime.Format("2006/01/02 15:04:05"), + "event_property":properties, + }).Info() + } +} diff --git a/dsDataex/Utils/ConfigUtil/ConfigUtil.go b/dsDataex/Utils/ConfigUtil/ConfigUtil.go index f8467c42..17dde70f 100644 --- a/dsDataex/Utils/ConfigUtil/ConfigUtil.go +++ b/dsDataex/Utils/ConfigUtil/ConfigUtil.go @@ -48,6 +48,8 @@ var ( //Kafka broker地址 KafkaBrokers []string + KafkaAccessLogTopic string + KafkaParts int64 KafkaReply int64 @@ -130,6 +132,9 @@ func init() { KafkaProcNo=iniParser.GetInt64("kafka", "process_no") KafkaParts=iniParser.GetInt64("kafka", "partition") + //add by zhangjun 2020-08-03 + KafkaAccessLogTopic= iniParser.GetString("kafka", "KafkaAccessLogTopic") + ESNodes = iniParser.GetString("elasticsearch", "nodes") ESUser = iniParser.GetString("elasticsearch", "user") diff --git a/dsDataex/Utils/KafkaUtil/KafkaUtil.go b/dsDataex/Utils/KafkaUtil/KafkaUtil.go index 9dabc497..91b89702 100644 --- a/dsDataex/Utils/KafkaUtil/KafkaUtil.go +++ b/dsDataex/Utils/KafkaUtil/KafkaUtil.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "github.com/segmentio/kafka-go" + "github.com/segmentio/kafka-go/snappy" "math/rand" "strconv" "time" @@ -186,6 +187,10 @@ func Consume(topic string, group string, index int) { } }() + //add by zhangjun 2020-08-03 + //Kafka-Sarama 解析压缩消息 + snappy.NewCompressionCodec() + r := kafka.NewReader(kafka.ReaderConfig{ Brokers: ConfigUtil.KafkaBrokers, Topic: topic, @@ -300,6 +305,29 @@ func Provide(topic string, datas []DataEX.KafkaData) (bool, string) { } } +/** + * @Author zhangjun + * @Description + * @Date 2020-08-03 08:47 + * @Param + * @return + **/ +func InitTopic(topic string) { + client, _ := kafka.DialLeader(context.Background(), "tcp", ConfigUtil.KafkaBrokers[0], topic, 0) + + parts, _ := client.ReadPartitions() + offset, _ := client.ReadLastOffset() + + if len(parts) == 1 && offset == 0 { + + DeleteTopic(topic) + + time.Sleep(100 * time.Millisecond) + + CreateTopic(topic) + } +} + /** * @Author zhangjun * @Description 创建 Kafka Topic diff --git a/dsDataex/gin_server.log b/dsDataex/gin_server.log new file mode 100644 index 00000000..e69de29b diff --git a/dsDataex/go.mod b/dsDataex/go.mod index 6e9ea645..3fe4ecb4 100644 --- a/dsDataex/go.mod +++ b/dsDataex/go.mod @@ -6,6 +6,7 @@ require ( github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6 // indirect github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect github.com/CloudyKit/jet v2.1.2+incompatible // indirect + github.com/Shopify/sarama v1.26.4 // indirect github.com/UNO-SOFT/soap-proxy v0.9.0 // indirect github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee // indirect github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 // indirect @@ -35,6 +36,7 @@ require ( github.com/swaggo/gin-swagger v1.2.0 github.com/swaggo/swag v1.5.1 github.com/tealeg/xlsx v1.0.5 // indirect + github.com/tracer0tong/kafkalogrus v0.0.0-20180816014403-290bb4d4d549 github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be // indirect github.com/xormplus/core v0.0.0-20200308074340-f3bce19d5f31 github.com/xormplus/xorm v0.0.0-20200529061552-7d0d26c6f81c diff --git a/dsDataex/go.sum b/dsDataex/go.sum index c7b9f882..89714d69 100644 --- a/dsDataex/go.sum +++ b/dsDataex/go.sum @@ -50,6 +50,9 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/Shopify/sarama v1.26.4 h1:+17TxUq/PJEAfZAll0T7XJjSgQWCpaQSoki/x5yN8o8= +github.com/Shopify/sarama v1.26.4/go.mod h1:NbSGBSSndYaIhRcBtY9V0U7AyH+x71bG668AuWys/yU= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/UNO-SOFT/grpcer v0.4.5 h1:fof8hqD7RjN9L8KiYbz+h9inHkPyvXOooegS9VPMxsU= github.com/UNO-SOFT/grpcer v0.4.5/go.mod h1:dT+UlfZ9JAxmpUj70d/IS78bc3AoGF6cQrJiqCh4bWo= github.com/UNO-SOFT/soap-proxy v0.9.0 h1:HD1p7xFSWflJnMP5rH0PJ0C8qulbxNIthPlpxmnYZlI= @@ -106,6 +109,7 @@ github.com/cznic/sortutil v0.0.0-20181122101858-f5f958428db8/go.mod h1:q2w6Bg5je github.com/cznic/zappy v0.0.0-20160723133515-2533cb5b45cc/go.mod h1:Y1SNZ4dRUOKXshKUbwUapqNncRrho4mkjQebgEHZLj8= github.com/cznic/zappy v0.0.0-20181122101859-ca47d358d4b1/go.mod h1:Y1SNZ4dRUOKXshKUbwUapqNncRrho4mkjQebgEHZLj8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20180707235734-242fa5aa1b45 h1:UW8VerkZA1zCt3uWhQ2wbMae76OLn7s7Utz8wyKtJUk= github.com/denisenkom/go-mssqldb v0.0.0-20180707235734-242fa5aa1b45/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= @@ -117,7 +121,12 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-linebreak v0.0.0-20180812204043-d8f37254e7d3/go.mod h1:FDHdQKtI1NtvxIYsG/y+ymRaIQIsp+LRSTGl7eBKQEU= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.2.0 h1:v7g92e/KSN71Rq7vSThKaWIq68fL4YHvWyiUKorFR1Q= +github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/elastic/go-elasticsearch v0.0.0 h1:Pd5fqOuBxKxv83b0+xOAJDAkziWYwFinWnBO0y+TZaA= @@ -142,6 +151,7 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/frankban/quicktest v1.2.2/go.mod h1:Qh/WofXFeiAFII1aEBu529AtJo6Zg2VHscnEsbBnJ20= +github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -332,6 +342,8 @@ github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6 github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM= github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -348,6 +360,8 @@ github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= github.com/jackc/pgx v3.2.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= +github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8= +github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= @@ -376,6 +390,7 @@ github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0 github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.8/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.10.4 h1:jFzIFaf586tquEB5EhzQG0HwGNSlgAJpG53G6Ss11wc= github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= @@ -389,6 +404,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= @@ -478,6 +494,8 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9 github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= github.com/phpdave11/gofpdi v1.0.7/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4 v2.4.1+incompatible h1:mFe7ttWaflA46Mhqh+jUfjp2qTbPYxLB2/OyBppH9dg= +github.com/pierrec/lz4 v2.4.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -492,6 +510,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/rakyll/statik v0.1.6/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs= +github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 h1:dY6ETXrvDG7Sa4vE8ZQG4yqWg6UnOcbqTAahkV813vQ= +github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -588,6 +608,8 @@ github.com/tgulacsi/picago v0.0.0-20171229130838-9e1ac2306c70/go.mod h1:YOW4MCz1 github.com/tgulacsi/statik v0.1.3/go.mod h1:pVOIVRTX4bNYzBJsbhza+p+Wzhm+wk4WgL//X4Gntac= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE= +github.com/tracer0tong/kafkalogrus v0.0.0-20180816014403-290bb4d4d549 h1:hqEVIPHSz/NB7wobGhaNjx7qelBUMM9Xw/20mjDxvp4= +github.com/tracer0tong/kafkalogrus v0.0.0-20180816014403-290bb4d4d549/go.mod h1:llNPwZUpuR/gPA17kqlHPTWK9ohsBjijSwR0Kprsbbc= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= @@ -657,6 +679,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200210222208-86ce3cb69678 h1:wCWoJcFExDgyYx2m2hpHgwz8W3+FPdfldvIgzqDIhyg= golang.org/x/crypto v0.0.0-20200210222208-86ce3cb69678/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -915,6 +939,15 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.57.0 h1:9unxIsFcTt4I55uWluz+UmL95q4kdJ0buvQ1ZIqVQww= gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw= +gopkg.in/jcmturner/aescts.v1 v1.0.1/go.mod h1:nsR8qBOg+OucoIW+WMhB3GspUQXq9XorLnQb9XtvcOo= +gopkg.in/jcmturner/dnsutils.v1 v1.0.1 h1:cIuC1OLRGZrld+16ZJvvZxVJeKPsvd5eUIvxfoN5hSM= +gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eRhxkJMWSIz9Q= +gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= +gopkg.in/jcmturner/gokrb5.v7 v7.5.0 h1:a9tsXlIDD9SKxotJMK3niV7rPZAJeX2aD/0yg3qlIrg= +gopkg.in/jcmturner/gokrb5.v7 v7.5.0/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= +gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU= +gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= gopkg.in/mgo.v2 v2.0.0-20160818020120-3f83fa500528/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= diff --git a/dsDataex/main.go b/dsDataex/main.go index b082d618..070f054c 100644 --- a/dsDataex/main.go +++ b/dsDataex/main.go @@ -1,6 +1,7 @@ package main import ( + Middleware "dsDataex/MiddleWare" "dsDataex/MyModel/DataAccess/DataaccessController" "dsDataex/MyModel/DataSource/DatasourceController" "dsDataex/MyModel/JYT2012/Jyt2012Controller" @@ -50,12 +51,15 @@ func GinServerInit() { r = gin.Default() + //启用日志中间件 + r.Use(Middleware.LoggerToKafka()) + + r.Use(Utils.Cors()) + r.GET("/", func(c *gin.Context) { c.JSON(200, "dsDataEX GO !!!") }) - r.Use(Utils.Cors()) - //add by wangshuai 2020-07-14 r.Static("/docs", "./docs") //r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))