作者 唐旭辉

新增

@@ -12,7 +12,7 @@ func ResetCommonConfig() { @@ -12,7 +12,7 @@ func ResetCommonConfig() {
12 var setlog log.SetLoggerConfig 12 var setlog log.SetLoggerConfig
13 if mconfig.LogOutput == "console" { 13 if mconfig.LogOutput == "console" {
14 setlog = &log.LoggerConsole{ 14 setlog = &log.LoggerConsole{
15 - Level: log.LogLevelDebug, Color: true, 15 + Level: log.LogLevelDebug, Color: false,
16 } 16 }
17 } else if mconfig.LogOutput == "file" { 17 } else if mconfig.LogOutput == "file" {
18 setlog = &log.LoggerFile{ 18 setlog = &log.LoggerFile{
@@ -26,7 +26,7 @@ func RestMyConfig() *MyConfig { @@ -26,7 +26,7 @@ func RestMyConfig() *MyConfig {
26 RedisAddPort: beego.AppConfig.String("redis_add_port"), 26 RedisAddPort: beego.AppConfig.String("redis_add_port"),
27 RedisAuth: beego.AppConfig.DefaultString("redis_auth", ""), 27 RedisAuth: beego.AppConfig.DefaultString("redis_auth", ""),
28 RedisDB: beego.AppConfig.DefaultString("redis_db", "0"), 28 RedisDB: beego.AppConfig.DefaultString("redis_db", "0"),
29 - LogOutput: beego.AppConfig.DefaultString("log_outpur", "console"), 29 + LogOutput: beego.AppConfig.DefaultString("log_output", "console"),
30 LogFilename: beego.AppConfig.DefaultString("log_filename", "./log/ability.log"), 30 LogFilename: beego.AppConfig.DefaultString("log_filename", "./log/ability.log"),
31 LogLevel: beego.AppConfig.DefaultString("log_Level", "debug"), 31 LogLevel: beego.AppConfig.DefaultString("log_Level", "debug"),
32 } 32 }
@@ -68,12 +68,10 @@ var logger *logs.BeeLogger @@ -68,12 +68,10 @@ var logger *logs.BeeLogger
68 68
69 func ResetLog(config SetLoggerConfig, funcCall bool) { 69 func ResetLog(config SetLoggerConfig, funcCall bool) {
70 logger = logs.GetBeeLogger() 70 logger = logs.GetBeeLogger()
71 - logger.Async(1000)  
72 out := config.Name() 71 out := config.Name()
73 logconf := config.MarshalString() 72 logconf := config.MarshalString()
74 logger.EnableFuncCallDepth(funcCall) 73 logger.EnableFuncCallDepth(funcCall)
75 logger.SetLogFuncCallDepth(3) 74 logger.SetLogFuncCallDepth(3)
76 -  
77 logger.SetLogger(out, logconf) 75 logger.SetLogger(out, logconf)
78 return 76 return
79 } 77 }
@@ -4,24 +4,20 @@ config_name = "dev" @@ -4,24 +4,20 @@ config_name = "dev"
4 #端口号 4 #端口号
5 httpport = 8081 5 httpport = 8081
6 #开启应用内监控 6 #开启应用内监控
7 -EnableAdmin = true 7 +EnableAdmin = false
8 AdminPort = 8088 8 AdminPort = 8088
9 #---beego的默认配置 结束--- 9 #---beego的默认配置 结束---
10 10
11 #---自定义配置 开始---- 11 #---自定义配置 开始----
12 ##数据库连接 12 ##数据库连接
13 -sqlconn ="root:root@tcp(127.0.0.1:3306)/ability_display?charset=utf8" 13 +# sqlconn ="${MYSQL_CONN||root:root@tcp(127.0.0.1:3306)/opportunity_dev?charset=utf8}"
  14 +sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8}"
14 ##redis相关配置 15 ##redis相关配置
15 redis_add_port = "127.0.0.1:6379" 16 redis_add_port = "127.0.0.1:6379"
16 redis_auth = "" 17 redis_auth = ""
17 ##log相关配置 18 ##log相关配置
18 ##out_put:"console","file" 19 ##out_put:"console","file"
19 log_output = "file" 20 log_output = "file"
20 -log_filename = "./log/ability.log"  
21 -# maxlines =  
22 -# maxsize =  
23 -# daily =  
24 -# maxdays =  
25 -# rotate =  
26 -log_level = "debug" 21 +log_filename = "${LOG_FILENAME||./log/ability.log}"
  22 +log_level = "${LOG_LEVEL||debug}"
27 #---自定义配置 结束---- 23 #---自定义配置 结束----
@@ -17,6 +17,7 @@ redis_auth = "" @@ -17,6 +17,7 @@ redis_auth = ""
17 #log相关配置 17 #log相关配置
18 #out_put:"console","file" 18 #out_put:"console","file"
19 log_output = "file" 19 log_output = "file"
  20 +#
20 log_filename = "./log/ability.log" 21 log_filename = "./log/ability.log"
21 # maxlines = 22 # maxlines =
22 # maxsize = 23 # maxsize =
@@ -8,18 +8,13 @@ httpport = 8080 @@ -8,18 +8,13 @@ httpport = 8080
8 8
9 #---自定义配置 开始---- 9 #---自定义配置 开始----
10 #数据库连接 10 #数据库连接
11 -sqlconn = "root:root@tcp(127.0.0.1:3306)/ability_display?charset=utf8" 11 +sqlconn = "${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8}"
12 #redis相关配置 12 #redis相关配置
13 redis_add_port = "127.0.0.1:6379" 13 redis_add_port = "127.0.0.1:6379"
14 redis_auth = "" 14 redis_auth = ""
15 #log相关配置 15 #log相关配置
16 #out_put:"console","file" 16 #out_put:"console","file"
17 log_output = "file" 17 log_output = "file"
18 -log_filename = "./log/ability.log"  
19 -# maxlines =  
20 -# maxsize =  
21 -# daily =  
22 -# maxdays =  
23 -# rotate =  
24 -log_level = "debug" 18 +log_filename = "${LOG_FILENAME||./log/ability.log}"
  19 +log_level = "${LOG_LEVEL||debug}"
25 #---自定义配置 结束---- 20 #---自定义配置 结束----
@@ -6,21 +6,15 @@ import ( @@ -6,21 +6,15 @@ import (
6 "net/http" 6 "net/http"
7 "oppmg/common/log" 7 "oppmg/common/log"
8 "oppmg/protocol" 8 "oppmg/protocol"
  9 + "strconv"
9 10
10 "github.com/astaxie/beego" 11 "github.com/astaxie/beego"
11 ) 12 )
12 13
13 -//BaseHeader 请求的header数据  
14 -//减少在具体业务方法中使用 this.Ctx.Input.Header("xxxx")  
15 -type BaseHeader struct {  
16 - AccessToken string `json:"access_token"`  
17 - RefreshToken string `json:"refresh_token"`  
18 -}  
19 -  
20 //BaseController 基础 14 //BaseController 基础
21 type BaseController struct { 15 type BaseController struct {
22 beego.Controller 16 beego.Controller
23 - AppHead BaseHeader 17 + // AppHead protocol.BaseHeader
24 } 18 }
25 19
26 //Options 实现beego.ControllerInterface 的接口 20 //Options 实现beego.ControllerInterface 的接口
@@ -32,14 +26,18 @@ func (this *BaseController) Options() { @@ -32,14 +26,18 @@ func (this *BaseController) Options() {
32 26
33 //Prepare 实现beego.ControllerInterface 的接口 27 //Prepare 实现beego.ControllerInterface 的接口
34 func (this *BaseController) Prepare() { 28 func (this *BaseController) Prepare() {
35 - this.AppHead.AccessToken = this.Ctx.Input.Header("access_token")  
36 - this.AppHead.RefreshToken = this.Ctx.Input.Header("refresh_token")  
37 - //详细header待定 TODO  
38 - if this.Ctx.Input.RequestBody != nil {  
39 - log.Info(fmt.Sprintf("====>Recv data from client:\nHeadData: %s\n BodyData: %s", this.Ctx.Request.Header, string(this.Ctx.Input.RequestBody)))  
40 - } else {  
41 - log.Info(fmt.Sprintf("====>Recv data from client:\nHeadData: %s ", this.Ctx.Request.Header))  
42 - } 29 +
  30 +}
  31 +
  32 +func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) {
  33 + appHead.AccessToken = this.Ctx.Input.Header(protocol.HeaderAccessToken)
  34 + appHead.RefreshToken = this.Ctx.Input.Header(protocol.HeaderRefreshToken)
  35 + appHead.UID, _ = strconv.Atoi(this.Ctx.Input.Header(protocol.HeaderUID))
  36 + appHead.UUID = this.Ctx.Input.Header(protocol.HeaderUUID)
  37 + appHead.Timestamp, _ = strconv.Atoi(this.Ctx.Input.Header(protocol.HeaderTimestamp))
  38 + appHead.Devicetype = this.Ctx.Input.Header(protocol.HeaderDevicetype)
  39 + appHead.AppProject = this.Ctx.Input.Header(protocol.HeaderAppproject)
  40 + return
43 41
44 } 42 }
45 43
  1 +package controllers
  2 +
  3 +type RbacController struct {
  4 + BaseController
  5 +}
  6 +
  7 +//URLMapping 实现ControllerInterface中的URLMapping
  8 +func (c *RbacController) URLMapping() {
  9 + //c.Mapping("AccessToken", c.AccessToken)
  10 +}
@@ -11,6 +11,7 @@ require ( @@ -11,6 +11,7 @@ require (
11 github.com/onsi/ginkgo v1.10.3 // indirect 11 github.com/onsi/ginkgo v1.10.3 // indirect
12 github.com/onsi/gomega v1.7.1 // indirect 12 github.com/onsi/gomega v1.7.1 // indirect
13 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect 13 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
  14 + github.com/sony/sonyflake v1.0.0
14 golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba // indirect 15 golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba // indirect
15 google.golang.org/appengine v1.6.5 // indirect 16 google.golang.org/appengine v1.6.5 // indirect
16 gopkg.in/yaml.v2 v2.2.7 // indirect 17 gopkg.in/yaml.v2 v2.2.7 // indirect
@@ -13,6 +13,7 @@ github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:T @@ -13,6 +13,7 @@ github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:T
13 github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c= 13 github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
14 github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs= 14 github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
15 github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY= 15 github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
  16 +github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
16 github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= 17 github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
17 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 18 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
18 github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= 19 github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
@@ -49,6 +50,8 @@ github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/ @@ -49,6 +50,8 @@ github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/
49 github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= 50 github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
50 github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= 51 github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
51 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= 52 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
  53 +github.com/sony/sonyflake v1.0.0 h1:MpU6Ro7tfXwgn2l5eluf9xQvQJDROTBImNCfRXn/YeM=
  54 +github.com/sony/sonyflake v1.0.0/go.mod h1:Jv3cfhf/UFtolOTTRd3q4Nl6ENqM+KfyZ5PseKfZGF4=
52 github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= 55 github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
53 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= 56 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
54 github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc= 57 github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
1 -2019/09/25 09:30:17.551 [D] [main.go:23] 应用启动  
2 -2019/09/25 09:30:17.602 [I] [app.go:215] http server Running on http://:8080  
3 -2019/09/25 09:41:04.196 [D] [proc.go:203] 应用启动  
4 -2019/09/25 09:41:04.245 [I] [asm_amd64.s:1357] http server Running on http://:8080  
5 -2019/09/25 09:41:51.479 [D] [main.go:23] 应用启动  
6 -2019/09/25 09:41:51.522 [I] [app.go:215] http server Running on http://:8080  
7 -2019/09/25 09:43:54.102 [D] [main.go:23] 应用启动  
8 -2019/09/25 09:43:54.148 [I] [app.go:215] http server Running on http://:8080  
9 -2019/09/25 09:44:26.483 [D] 应用启动  
10 -2019/09/25 09:44:26.527 [I] http server Running on http://:8080  
11 -2019/09/25 09:45:14.831 [D] 应用启动  
12 -2019/09/25 09:45:14.883 [I] http server Running on http://:8080  
13 -2019/09/25 09:46:11.373 [D] [main.go:23] 应用启动  
14 -2019/09/25 09:46:11.421 [I] [app.go:215] http server Running on http://:8080  
15 -2019/09/25 09:46:20.279 [D] 应用启动  
16 -2019/09/25 09:46:20.321 [I] http server Running on http://:8080  
17 -2019/09/25 09:46:36.286 [D] [main.go:23] 应用启动  
18 -2019/09/25 09:46:36.327 [I] [app.go:215] http server Running on http://:8080  
19 -2019/09/25 09:48:04.055 [D] [logger.go:70] log 配置:{"filename":"./log/ability.log"}  
20 -2019/09/25 09:48:04.058 [D] [main.go:23] 应用启动  
21 -2019/09/25 09:48:04.101 [I] [app.go:215] http server Running on http://:8080  
22 -2019/09/25 09:48:57.467 [D] [logger.go:68] log 配置:{"filename":"./log/ability.log"}  
23 -2019/09/25 09:48:57.472 [D] [main.go:23] 应用启动  
24 -2019/09/25 09:48:57.513 [I] [app.go:215] http server Running on http://:8080  
25 -2019/09/25 09:51:29.788 [D] [logger.go:68] log 配置:{"filename":"./log/ability.log"}  
26 -2019/09/25 09:51:29.790 [D] [main.go:24] 应用启动  
27 -2019/09/25 09:51:29.831 [I] [app.go:215] http server Running on http://:8080  
28 -2019/09/25 09:52:37.088 [D] [logger.go:72] log 配置:{"filename":"./log/ability.log"}  
29 -2019/09/25 09:52:37.091 [D] [main.go:24] 应用启动  
30 -2019/09/25 09:52:37.134 [I] [app.go:215] http server Running on http://:8080  
31 -2019/09/25 09:53:53.727 [D] [logger.go:74] log 配置:{"filename":"./log/ability.log"}  
32 -2019/09/25 09:53:53.730 [D] [main.go:24] 应用启动  
33 -2019/09/25 09:53:53.774 [I] [app.go:215] http server Running on http://:8080  
34 -2019/09/25 09:57:45.468 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}  
35 -2019/09/25 09:57:45.471 [D] [main.go:24] 应用启动  
36 -2019/09/25 09:57:45.518 [I] [app.go:215] http server Running on http://:8080  
37 -2019/09/25 09:58:34.957 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}  
38 -2019/09/25 09:58:34.961 [D] [main.go:24] 应用启动  
39 -2019/09/25 09:58:35.001 [I] [app.go:215] http server Running on http://:8080  
40 -2019/09/25 09:59:00.222 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}  
41 -2019/09/25 09:59:00.224 [D] [main.go:24] 应用启动  
42 -2019/09/25 09:59:00.267 [I] [app.go:215] http server Running on http://:8080  
43 -2019/09/25 09:59:21.718 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}  
44 -2019/09/25 09:59:21.720 [D] [main.go:24] 应用启动  
45 -2019/09/25 09:59:21.763 [I] [app.go:215] http server Running on http://:8080  
46 -2019/09/25 09:59:51.099 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log"}  
47 -2019/09/25 09:59:51.102 [D] [main.go:24] 应用启动  
48 -2019/09/25 09:59:51.144 [I] [app.go:215] http server Running on http://:8080  
49 -2019/09/25 10:00:08.480 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log"}  
50 -2019/09/25 10:00:08.482 [D] [main.go:24] 应用启动  
51 -2019/09/25 10:00:08.529 [I] [app.go:215] http server Running on http://:8080  
52 -2019/09/25 10:00:24.442 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log"}  
53 -2019/09/25 10:00:24.444 [D] [main.go:24] 应用启动  
54 -2019/09/25 10:00:24.487 [I] [app.go:215] http server Running on http://:8080  
55 -2019/09/25 10:00:43.449 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}  
56 -2019/09/25 10:00:43.451 [D] [main.go:24] 应用启动  
57 -2019/09/25 10:00:43.491 [I] [app.go:215] http server Running on http://:8080  
58 -2019/09/25 10:01:06.019 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}  
59 -2019/09/25 10:01:06.021 [D] [main.go:23] 应用启动  
60 -2019/09/25 10:01:06.063 [I] [app.go:215] http server Running on http://:8080  
61 -2019/09/25 10:01:11.803 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}  
62 -2019/09/25 10:01:11.805 [D] [main.go:23] 应用启动  
63 -2019/09/25 10:01:11.849 [I] [app.go:215] http server Running on http://:8080  
64 -2019/09/25 10:01:12.837 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}  
65 -2019/09/25 10:01:12.838 [D] [main.go:23] 应用启动  
66 -2019/09/25 10:01:12.880 [I] [app.go:215] http server Running on http://:8080  
67 -2019/09/25 10:01:46.181 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}  
68 -2019/09/25 10:01:46.184 [D] [main.go:23] 应用启动  
69 -2019/09/25 10:01:46.231 [I] [app.go:215] http server Running on http://:8080 1 +2019/11/22 14:41:25.960 [D] [main.go:17] 加载配置dev
  2 +2019/11/22 14:41:26.134 [D] [main.go:23] 应用启动
  3 +2019/11/22 14:41:26.191 [I] [app.go:215] http server Running on http://:8081
  4 +2019/11/22 14:41:37.001 [D] [middle.go:11] 执行中间件AuthToken
  5 +2019/11/22 14:41:37.001 [I] [base.go:39] ====>Recv data from client:
  6 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[f81da1ed-6c04-4f71-93fd-0bc58e154b43] User-Agent:[PostmanRuntime/7.20.1]]
  7 + BodyData: {
  8 +
  9 +}
  10 +2019/11/22 14:41:37.001 [D] [auth.go:26] 运行cotrollers
  11 +2019/11/22 14:41:37.001 [I] [auth.go:12] log 打印
  12 +2019/11/22 14:41:37.001 [I] [auth.go:13] &{ConfigName:dev SqlConn:root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8 RedisAddPort:127.0.0.1:6379 RedisAuth: RedisDB:0 LogOutput:file LogFilename:./log/ability.log LogLevel:debug}
  13 +2019/11/22 14:41:37.002 [I] [base.go:53] <====Send to client: RspBodyData: {"code":"","msg":"","data":null}
  14 +2019/11/22 14:42:51.461 [D] [middle.go:11] 执行中间件AuthToken
  15 +2019/11/22 14:42:51.461 [I] [base.go:39] ====>Recv data from client:
  16 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[03f7d5a9-78cf-4a2a-8b31-f0186d912527] User-Agent:[PostmanRuntime/7.20.1]]
  17 + BodyData: {
  18 +
  19 +}
  20 +2019/11/22 14:42:51.461 [D] [auth.go:26] 运行cotrollers
  21 +2019/11/22 14:42:51.461 [I] [auth.go:12] log 打印
  22 +2019/11/22 14:42:51.461 [I] [auth.go:13] &{ConfigName:dev SqlConn:root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8 RedisAddPort:127.0.0.1:6379 RedisAuth: RedisDB:0 LogOutput:file LogFilename:./log/ability.log LogLevel:debug}
  23 +2019/11/22 14:42:51.462 [I] [base.go:53] <====Send to client: RspBodyData: {"code":"","msg":"","data":null}
  24 +2019/11/22 14:43:44.834 [D] [main.go:17] 加载配置dev
  25 +2019/11/22 14:43:44.985 [D] [main.go:23] 应用启动
  26 +2019/11/22 14:43:45.066 [I] [app.go:215] http server Running on http://:8081
  27 +2019/11/22 14:43:50.079 [D] [main.go:17] 加载配置dev
  28 +2019/11/22 14:43:50.293 [D] [main.go:23] 应用启动
  29 +2019/11/22 14:43:50.353 [I] [app.go:215] http server Running on http://:8081
  30 +2019/11/22 14:47:39.742 [D] [main.go:17] 加载配置dev
  31 +2019/11/22 14:47:39.895 [D] [main.go:23] 应用启动
  32 +2019/11/22 14:47:39.974 [I] [app.go:215] http server Running on http://:8081
  33 +2019/11/22 14:48:35.534 [D] [main.go:17] 加载配置dev
  34 +2019/11/22 14:48:35.694 [D] [main.go:23] 应用启动
  35 +2019/11/22 14:48:35.740 [I] [app.go:215] http server Running on http://:8081
  36 +2019/11/22 14:49:47.158 [D] [main.go:17] 加载配置dev
  37 +2019/11/22 14:49:47.334 [D] [main.go:23] 应用启动
  38 +2019/11/22 14:49:47.384 [I] [app.go:215] http server Running on http://:8081
  39 +2019/11/22 14:50:06.917 [D] [main.go:17] 加载配置dev
  40 +2019/11/22 14:50:07.074 [D] [main.go:23] 应用启动
  41 +2019/11/22 14:50:07.123 [I] [app.go:215] http server Running on http://:8081
  42 +2019/11/22 14:50:08.866 [D] [main.go:17] 加载配置dev
  43 +2019/11/22 14:50:09.012 [D] [main.go:23] 应用启动
  44 +2019/11/22 14:50:09.060 [I] [app.go:215] http server Running on http://:8081
  45 +2019/11/22 15:00:38.764 [D] [main.go:17] 加载配置dev
  46 +2019/11/22 15:00:38.912 [D] [main.go:23] 应用启动
  47 +2019/11/22 15:00:39.016 [I] [app.go:215] http server Running on http://:8081
  48 +2019/11/22 15:00:43.438 [D] [main.go:17] 加载配置dev
  49 +2019/11/22 15:00:43.630 [D] [main.go:23] 应用启动
  50 +2019/11/22 15:00:43.680 [I] [app.go:215] http server Running on http://:8081
  51 +2019/11/22 15:01:38.946 [D] [main.go:17] 加载配置dev
  52 +2019/11/22 15:01:39.096 [D] [main.go:23] 应用启动
  53 +2019/11/22 15:01:39.143 [I] [app.go:215] http server Running on http://:8081
  54 +2019/11/22 15:02:17.069 [D] [main.go:17] 加载配置dev
  55 +2019/11/22 15:02:17.457 [D] [main.go:23] 应用启动
  56 +2019/11/22 15:02:17.509 [I] [app.go:215] http server Running on http://:8081
  57 +2019/11/22 15:03:36.700 [D] [main.go:17] 加载配置dev
  58 +2019/11/22 15:03:36.865 [D] [main.go:23] 应用启动
  59 +2019/11/22 15:03:36.912 [I] [app.go:215] http server Running on http://:8081
  60 +2019/11/22 15:03:51.792 [D] [main.go:17] 加载配置dev
  61 +2019/11/22 15:03:51.980 [D] [main.go:23] 应用启动
  62 +2019/11/22 15:03:52.031 [I] [app.go:215] http server Running on http://:8081
  63 +2019/11/22 15:04:49.305 [D] [main.go:17] 加载配置dev
  64 +2019/11/22 15:04:49.476 [D] [main.go:23] 应用启动
  65 +2019/11/22 15:04:49.531 [I] [app.go:215] http server Running on http://:8081
  66 +2019/11/22 15:05:37.282 [D] [main.go:17] 加载配置dev
  67 +2019/11/22 15:05:37.431 [D] [main.go:23] 应用启动
  68 +2019/11/22 15:05:37.498 [I] [app.go:215] http server Running on http://:8081
  69 +2019/11/22 15:05:38.493 [D] [main.go:17] 加载配置dev
  70 +2019/11/22 15:05:38.699 [D] [main.go:23] 应用启动
  71 +2019/11/22 15:05:38.747 [I] [app.go:215] http server Running on http://:8081
  72 +2019/11/22 15:06:45.490 [D] [main.go:17] 加载配置dev
  73 +2019/11/22 15:06:45.697 [D] [main.go:23] 应用启动
  74 +2019/11/22 15:06:45.774 [I] [app.go:215] http server Running on http://:8081
  75 +2019/11/22 15:06:46.777 [D] [main.go:17] 加载配置dev
  76 +2019/11/22 15:06:46.920 [D] [main.go:23] 应用启动
  77 +2019/11/22 15:06:46.970 [I] [app.go:215] http server Running on http://:8081
  78 +2019/11/22 15:06:47.948 [D] [main.go:17] 加载配置dev
  79 +2019/11/22 15:06:48.085 [D] [main.go:23] 应用启动
  80 +2019/11/22 15:06:48.138 [I] [app.go:215] http server Running on http://:8081
  81 +2019/11/22 15:06:49.224 [D] [main.go:17] 加载配置dev
  82 +2019/11/22 15:06:49.367 [D] [main.go:23] 应用启动
  83 +2019/11/22 15:06:49.451 [I] [app.go:215] http server Running on http://:8081
  84 +2019/11/22 15:06:51.306 [D] [main.go:17] 加载配置dev
  85 +2019/11/22 15:06:51.472 [D] [main.go:23] 应用启动
  86 +2019/11/22 15:06:51.553 [I] [app.go:215] http server Running on http://:8081
  87 +2019/11/22 15:06:52.971 [D] [main.go:17] 加载配置dev
  88 +2019/11/22 15:06:53.119 [D] [main.go:23] 应用启动
  89 +2019/11/22 15:06:53.207 [I] [app.go:215] http server Running on http://:8081
  90 +2019/11/22 15:06:57.659 [D] [main.go:17] 加载配置dev
  91 +2019/11/22 15:06:57.825 [D] [main.go:23] 应用启动
  92 +2019/11/22 15:06:57.877 [I] [app.go:215] http server Running on http://:8081
  93 +2019/11/22 15:06:59.273 [D] [main.go:17] 加载配置dev
  94 +2019/11/22 15:06:59.445 [D] [main.go:23] 应用启动
  95 +2019/11/22 15:06:59.491 [I] [app.go:215] http server Running on http://:8081
  96 +2019/11/22 15:07:12.721 [D] [main.go:17] 加载配置dev
  97 +2019/11/22 15:07:12.933 [D] [main.go:23] 应用启动
  98 +2019/11/22 15:07:12.994 [I] [app.go:215] http server Running on http://:8081
  99 +2019/11/22 15:07:24.903 [D] [main.go:17] 加载配置dev
  100 +2019/11/22 15:07:25.054 [D] [main.go:23] 应用启动
  101 +2019/11/22 15:07:25.141 [I] [app.go:215] http server Running on http://:8081
  102 +2019/11/22 15:07:53.161 [D] [main.go:17] 加载配置dev
  103 +2019/11/22 15:07:53.318 [D] [main.go:23] 应用启动
  104 +2019/11/22 15:07:53.395 [I] [app.go:215] http server Running on http://:8081
  105 +2019/11/22 15:08:37.443 [D] [main.go:17] 加载配置dev
  106 +2019/11/22 15:08:37.639 [D] [main.go:23] 应用启动
  107 +2019/11/22 15:08:37.712 [I] [app.go:215] http server Running on http://:8081
  108 +2019/11/22 15:10:52.050 [D] [main.go:17] 加载配置dev
  109 +2019/11/22 15:10:52.302 [D] [main.go:23] 应用启动
  110 +2019/11/22 15:10:52.367 [I] [app.go:215] http server Running on http://:8081
  111 +2019/11/22 15:11:50.664 [D] [main.go:17] 加载配置dev
  112 +2019/11/22 15:11:50.815 [D] [main.go:23] 应用启动
  113 +2019/11/22 15:11:50.889 [I] [app.go:215] http server Running on http://:8081
  114 +2019/11/22 15:12:51.210 [D] [main.go:17] 加载配置dev
  115 +2019/11/22 15:12:51.837 [D] [main.go:23] 应用启动
  116 +2019/11/22 15:12:51.886 [I] [app.go:215] http server Running on http://:8081
  117 +2019/11/22 15:13:52.273 [D] [main.go:17] 加载配置dev
  118 +2019/11/22 15:13:52.560 [D] [main.go:23] 应用启动
  119 +2019/11/22 15:13:52.610 [I] [app.go:215] http server Running on http://:8081
  120 +2019/11/22 15:13:54.444 [D] [main.go:17] 加载配置dev
  121 +2019/11/22 15:13:54.595 [D] [main.go:23] 应用启动
  122 +2019/11/22 15:13:54.646 [I] [app.go:215] http server Running on http://:8081
  123 +2019/11/22 15:17:51.875 [D] [main.go:17] 加载配置dev
  124 +2019/11/22 15:17:52.122 [D] [main.go:23] 应用启动
  125 +2019/11/22 15:17:52.173 [I] [app.go:215] http server Running on http://:8081
  126 +2019/11/22 15:18:07.474 [D] [main.go:17] 加载配置dev
  127 +2019/11/22 15:18:07.744 [D] [main.go:23] 应用启动
  128 +2019/11/22 15:18:07.793 [I] [app.go:215] http server Running on http://:8081
  129 +2019/11/22 15:19:44.221 [D] [main.go:17] 加载配置dev
  130 +2019/11/22 15:19:44.669 [D] [main.go:23] 应用启动
  131 +2019/11/22 15:19:44.718 [I] [app.go:215] http server Running on http://:8081
  132 +2019/11/22 15:20:15.139 [D] [main.go:17] 加载配置dev
  133 +2019/11/22 15:20:15.330 [D] [main.go:23] 应用启动
  134 +2019/11/22 15:20:15.380 [I] [app.go:215] http server Running on http://:8081
  135 +2019/11/22 15:21:02.445 [D] [main.go:17] 加载配置dev
  136 +2019/11/22 15:21:02.827 [D] [main.go:23] 应用启动
  137 +2019/11/22 15:21:02.874 [I] [app.go:215] http server Running on http://:8081
  138 +2019/11/22 15:21:27.848 [D] [main.go:17] 加载配置dev
  139 +2019/11/22 15:21:28.250 [D] [main.go:23] 应用启动
  140 +2019/11/22 15:21:28.297 [I] [app.go:215] http server Running on http://:8081
  141 +2019/11/22 15:25:27.707 [D] [main.go:17] 加载配置dev
  142 +2019/11/22 15:25:28.041 [D] [main.go:23] 应用启动
  143 +2019/11/22 15:25:28.092 [I] [app.go:215] http server Running on http://:8081
  144 +2019/11/22 15:25:28.675 [D] [main.go:17] 加载配置dev
  145 +2019/11/22 15:25:28.835 [D] [main.go:23] 应用启动
  146 +2019/11/22 15:25:28.897 [I] [app.go:215] http server Running on http://:8081
  147 +2019/11/22 15:25:33.162 [D] [main.go:17] 加载配置dev
  148 +2019/11/22 15:25:33.356 [D] [main.go:23] 应用启动
  149 +2019/11/22 15:25:33.416 [I] [app.go:215] http server Running on http://:8081
  150 +2019/11/22 15:25:43.894 [D] [main.go:17] 加载配置dev
  151 +2019/11/22 15:25:44.034 [D] [main.go:23] 应用启动
  152 +2019/11/22 15:25:44.083 [I] [app.go:215] http server Running on http://:8081
  153 +2019/11/22 15:25:57.701 [D] [main.go:17] 加载配置dev
  154 +2019/11/22 15:25:59.257 [D] [main.go:23] 应用启动
  155 +2019/11/22 15:25:59.322 [I] [app.go:215] http server Running on http://:8081
  156 +2019/11/22 15:33:17.823 [D] [main.go:17] 加载配置dev
  157 +2019/11/22 15:33:19.387 [D] [main.go:23] 应用启动
  158 +2019/11/22 15:33:19.439 [I] [app.go:215] http server Running on http://:8081
  159 +2019/11/22 15:33:34.216 [D] [main.go:17] 加载配置dev
  160 +2019/11/22 15:33:35.405 [D] [main.go:23] 应用启动
  161 +2019/11/22 15:33:35.466 [I] [app.go:215] http server Running on http://:8081
  162 +2019/11/22 15:34:43.958 [D] [main.go:17] 加载配置dev
  163 +2019/11/22 15:34:45.033 [D] [main.go:23] 应用启动
  164 +2019/11/22 15:34:45.124 [I] [app.go:215] http server Running on http://:8081
  165 +2019/11/22 15:36:16.254 [D] [main.go:17] 加载配置dev
  166 +2019/11/22 15:36:17.502 [D] [main.go:23] 应用启动
  167 +2019/11/22 15:36:17.555 [I] [app.go:215] http server Running on http://:8081
  168 +2019/11/22 15:42:01.353 [D] [main.go:17] 加载配置dev
  169 +2019/11/22 15:42:01.585 [D] [main.go:23] 应用启动
  170 +2019/11/22 15:42:01.645 [I] [app.go:215] http server Running on http://:8081
  171 +2019/11/22 15:42:40.558 [D] [main.go:17] 加载配置dev
  172 +2019/11/22 15:42:40.761 [D] [main.go:23] 应用启动
  173 +2019/11/22 15:42:40.810 [I] [app.go:215] http server Running on http://:8081
  174 +2019/11/22 16:01:37.148 [D] [main.go:17] 加载配置dev
  175 +2019/11/22 16:01:37.299 [D] [main.go:23] 应用启动
  176 +2019/11/22 16:01:37.364 [I] [app.go:215] http server Running on http://:8081
  177 +2019/11/22 16:03:15.644 [D] [main.go:17] 加载配置dev
  178 +2019/11/22 16:03:16.120 [D] [main.go:23] 应用启动
  179 +2019/11/22 16:03:16.265 [I] [app.go:215] http server Running on http://:8081
  180 +2019/11/22 16:04:33.623 [D] [main.go:17] 加载配置dev
  181 +2019/11/22 16:04:33.892 [D] [main.go:23] 应用启动
  182 +2019/11/22 16:04:33.942 [I] [app.go:215] http server Running on http://:8081
  183 +2019/11/22 16:05:31.493 [D] [main.go:17] 加载配置dev
  184 +2019/11/22 16:05:31.636 [D] [main.go:23] 应用启动
  185 +2019/11/22 16:05:31.711 [I] [app.go:215] http server Running on http://:8081
  186 +2019/11/22 16:07:08.172 [D] [main.go:17] 加载配置dev
  187 +2019/11/22 16:07:08.446 [D] [main.go:23] 应用启动
  188 +2019/11/22 16:07:08.500 [I] [app.go:215] http server Running on http://:8081
  189 +2019/11/22 16:07:28.868 [D] [main.go:17] 加载配置dev
  190 +2019/11/22 16:07:29.281 [D] [main.go:23] 应用启动
  191 +2019/11/22 16:07:29.347 [I] [app.go:215] http server Running on http://:8081
  192 +2019/11/22 16:07:32.558 [D] [middle.go:41] 执行中间件AuthToken
  193 +2019/11/22 16:07:32.559 [I] [base.go:31] ====>Recv data from client:
  194 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[8dcc67e1-0292-4658-96df-a96ee77a1635] User-Agent:[PostmanRuntime/7.20.1]]
  195 + BodyData: {
  196 +
  197 +}
  198 +2019/11/22 16:07:32.559 [D] [auth.go:26] 运行cotrollers
  199 +2019/11/22 16:07:32.559 [I] [auth.go:12] log 打印
  200 +2019/11/22 16:07:32.559 [I] [auth.go:13] &{ConfigName:dev SqlConn:root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8 RedisAddPort:127.0.0.1:6379 RedisAuth: RedisDB:0 LogOutput:file LogFilename:./log/ability.log LogLevel:debug}
  201 +2019/11/22 16:07:32.559 [I] [base.go:56] <====Send to client: RspBodyData: {"code":"","msg":"","data":null}
  202 +2019/11/22 16:07:58.280 [D] [main.go:17] 加载配置dev
  203 +2019/11/22 16:07:58.749 [D] [main.go:23] 应用启动
  204 +2019/11/22 16:07:58.799 [I] [app.go:215] http server Running on http://:8081
  205 +2019/11/22 16:08:02.218 [D] [middle.go:41] 执行中间件AuthToken
  206 +2019/11/22 16:08:02.218 [E] [middle.go:32] ====>Recv data from client:
  207 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[3f39d7af-2850-41d9-a708-0d2054cbcd0f] User-Agent:[PostmanRuntime/7.20.1]]
  208 +
  209 +2019/11/22 16:08:36.273 [D] 加载配置prod
  210 +2019/11/22 16:08:37.610 [D] 应用启动
  211 +2019/11/22 16:08:37.700 [I] http server Running on http://:8080
  212 +2019/11/22 16:09:20.974 [D] 执行中间件AuthToken
  213 +2019/11/22 16:09:20.974 [E] ====>Recv data from client:
  214 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[9e148ff8-775f-40e3-b2a3-bf7de819d250] User-Agent:[PostmanRuntime/7.20.1]]
  215 +
  216 +2019/11/22 16:10:24.026 [D] 加载配置prod
  217 +2019/11/22 16:17:48.486 [D] [main.go:17] 加载配置dev
  218 +2019/11/22 16:17:48.827 [D] [main.go:23] 应用启动
  219 +2019/11/22 16:17:48.877 [I] [app.go:215] http server Running on http://:8081
  220 +2019/11/22 16:17:57.265 [I] [middle.go:15] ====>Recv Request:%!(EXTRA func() string=0x8da2e0)
  221 +2019/11/22 16:17:57.265 [I] [middle.go:17] ====>Recv data from client:
  222 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[6b9f73aa-bb5f-470d-aef8-9dc4007e856e] User-Agent:[PostmanRuntime/7.20.1]]
  223 + BodyData: {
  224 +
  225 +}
  226 +2019/11/22 16:17:57.265 [D] [middle.go:51] 执行中间件AuthToken
  227 +2019/11/22 16:17:57.265 [E] [middle.go:42] ===>Recv data from client:
  228 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[6b9f73aa-bb5f-470d-aef8-9dc4007e856e] User-Agent:[PostmanRuntime/7.20.1]]
  229 +
  230 +2019/11/22 16:18:22.449 [D] [main.go:17] 加载配置dev
  231 +2019/11/22 16:18:23.704 [D] [main.go:23] 应用启动
  232 +2019/11/22 16:18:23.785 [I] [app.go:215] http server Running on http://:8081
  233 +2019/11/22 16:18:30.882 [D] [main.go:17] 加载配置dev
  234 +2019/11/22 16:18:31.034 [D] [main.go:23] 应用启动
  235 +2019/11/22 16:18:31.083 [I] [app.go:215] http server Running on http://:8081
  236 +2019/11/22 16:18:34.022 [I] [middle.go:15] ====>Recv Request:%!s(func() string=0x8da230)
  237 +2019/11/22 16:18:34.022 [I] [middle.go:17] ====>Recv data from client:
  238 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[7a5a07e4-0613-40da-be0e-ce1e4292f596] User-Agent:[PostmanRuntime/7.20.1]]
  239 + BodyData: {
  240 +
  241 +}
  242 +2019/11/22 16:18:34.022 [D] [middle.go:49] 执行中间件AuthToken
  243 +2019/11/22 16:18:53.959 [D] [main.go:17] 加载配置dev
  244 +2019/11/22 16:18:55.133 [D] [main.go:23] 应用启动
  245 +2019/11/22 16:18:55.208 [I] [app.go:215] http server Running on http://:8081
  246 +2019/11/22 16:18:57.320 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  247 +2019/11/22 16:18:57.320 [I] [middle.go:17] ====>Recv data from client:
  248 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[a2dc6549-d2bf-473a-8e15-1bdaaee1f4ce] User-Agent:[PostmanRuntime/7.20.1]]
  249 + BodyData: {
  250 +
  251 +}
  252 +2019/11/22 16:18:57.320 [D] [middle.go:49] 执行中间件AuthToken
  253 +2019/11/22 16:20:04.808 [D] [main.go:17] 加载配置dev
  254 +2019/11/22 16:20:05.380 [D] [main.go:23] 应用启动
  255 +2019/11/22 16:20:05.430 [I] [app.go:215] http server Running on http://:8081
  256 +2019/11/22 16:20:07.999 [D] [main.go:17] 加载配置dev
  257 +2019/11/22 16:20:08.533 [D] [main.go:23] 应用启动
  258 +2019/11/22 16:20:08.639 [I] [app.go:215] http server Running on http://:8081
  259 +2019/11/22 16:20:12.534 [D] [main.go:17] 加载配置dev
  260 +2019/11/22 16:20:12.799 [D] [main.go:23] 应用启动
  261 +2019/11/22 16:20:12.860 [I] [app.go:215] http server Running on http://:8081
  262 +2019/11/22 16:20:15.158 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  263 +2019/11/22 16:20:15.158 [I] [middle.go:17] ====>Recv data from client:
  264 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[a2ee5689-f082-4a72-b954-ce5f0ac80580] User-Agent:[PostmanRuntime/7.20.1]]
  265 + BodyData: {
  266 +
  267 +}
  268 +2019/11/22 16:20:15.158 [D] [middle.go:49] 执行中间件AuthToken
  269 +2019/11/22 16:22:48.479 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  270 +2019/11/22 16:22:48.479 [I] [middle.go:17] ====>Recv data from client:
  271 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[f1868394-7b9b-41ce-8924-b7273a57590b] User-Agent:[PostmanRuntime/7.20.1]]
  272 + BodyData: {
  273 +
  274 +}
  275 +2019/11/22 16:22:48.479 [D] [middle.go:49] 执行中间件AuthToken
  276 +2019/11/22 16:24:15.594 [D] [main.go:17] 加载配置dev
  277 +2019/11/22 16:24:15.841 [D] [main.go:23] 应用启动
  278 +2019/11/22 16:24:15.891 [I] [app.go:215] http server Running on http://:8081
  279 +2019/11/22 16:24:18.455 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  280 +2019/11/22 16:24:18.455 [D] [middle.go:49] 执行中间件AuthToken
  281 +2019/11/22 16:25:52.592 [D] [main.go:17] 加载配置dev
  282 +2019/11/22 16:25:52.934 [D] [main.go:23] 应用启动
  283 +2019/11/22 16:25:52.982 [I] [app.go:215] http server Running on http://:8081
  284 +2019/11/22 16:26:02.004 [D] [main.go:17] 加载配置dev
  285 +2019/11/22 16:26:02.559 [D] [main.go:23] 应用启动
  286 +2019/11/22 16:26:02.646 [I] [app.go:215] http server Running on http://:8081
  287 +2019/11/22 16:26:05.922 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  288 +2019/11/22 16:26:05.922 [I] [middle.go:17] ====>Recv data from client:HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[ffaff420-0154-400a-8547-eaebdc5b490d] User-Agent:[PostmanRuntime/7.20.1]] BodyData: {
  289 +
  290 +}
  291 +2019/11/22 16:26:05.922 [D] [middle.go:49] 执行中间件AuthToken
  292 +2019/11/22 16:26:29.022 [D] [main.go:17] 加载配置dev
  293 +2019/11/22 16:26:30.724 [D] [main.go:23] 应用启动
  294 +2019/11/22 16:26:30.809 [I] [app.go:215] http server Running on http://:8081
  295 +2019/11/22 16:26:34.724 [D] [main.go:17] 加载配置dev
  296 +2019/11/22 16:26:34.879 [D] [main.go:23] 应用启动
  297 +2019/11/22 16:26:34.941 [I] [app.go:215] http server Running on http://:8081
  298 +2019/11/22 16:26:40.470 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  299 +2019/11/22 16:26:40.470 [I] [middle.go:17] ====>Recv data from client:BodyData: {
  300 +
  301 +}
  302 +2019/11/22 16:26:40.470 [D] [middle.go:49] 执行中间件AuthToken
  303 +2019/11/22 16:27:46.044 [D] [main.go:17] 加载配置dev
  304 +2019/11/22 16:27:46.215 [D] [main.go:23] 应用启动
  305 +2019/11/22 16:27:46.263 [I] [app.go:215] http server Running on http://:8081
  306 +2019/11/22 16:27:48.767 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  307 +2019/11/22 16:27:48.767 [I] [middle.go:16] ====>Recv data from client:HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[f6683252-2ec0-4070-97b3-ca5bffbea9c3] User-Agent:[PostmanRuntime/7.20.1]]
  308 +2019/11/22 16:27:48.767 [D] [middle.go:50] 执行中间件AuthToken
  309 +2019/11/22 16:28:07.472 [D] [main.go:17] 加载配置dev
  310 +2019/11/22 16:28:07.856 [D] [main.go:23] 应用启动
  311 +2019/11/22 16:28:07.909 [I] [app.go:215] http server Running on http://:8081
  312 +2019/11/22 16:28:12.794 [D] [main.go:17] 加载配置dev
  313 +2019/11/22 16:28:14.424 [D] [main.go:23] 应用启动
  314 +2019/11/22 16:28:14.484 [I] [app.go:215] http server Running on http://:8081
  315 +2019/11/22 16:28:15.761 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  316 +2019/11/22 16:28:15.761 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
  317 +2019/11/22 16:28:15.761 [D] [middle.go:50] 执行中间件AuthToken
  318 +2019/11/22 16:28:30.463 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  319 +2019/11/22 16:28:30.463 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
  320 +2019/11/22 16:28:30.463 [D] [middle.go:50] 执行中间件AuthToken
  321 +2019/11/22 16:29:11.856 [D] [main.go:17] 加载配置dev
  322 +2019/11/22 16:29:12.463 [D] [main.go:23] 应用启动
  323 +2019/11/22 16:29:12.517 [I] [app.go:215] http server Running on http://:8081
  324 +2019/11/22 16:29:15.066 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  325 +2019/11/22 16:29:15.066 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
  326 +2019/11/22 16:29:15.066 [D] [middle.go:50] 执行中间件AuthToken
  327 +2019/11/22 16:29:44.861 [D] [main.go:17] 加载配置dev
  328 +2019/11/22 16:29:45.137 [D] [main.go:23] 应用启动
  329 +2019/11/22 16:29:45.204 [I] [app.go:215] http server Running on http://:8081
  330 +2019/11/22 16:29:47.213 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  331 +2019/11/22 16:29:47.213 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
  332 +2019/11/22 16:29:47.213 [D] [middle.go:50] 执行中间件AuthToken
  333 +2019/11/22 16:33:05.350 [D] [main.go:17] 加载配置dev
  334 +2019/11/22 16:33:05.764 [D] [main.go:23] 应用启动
  335 +2019/11/22 16:33:05.825 [I] [app.go:215] http server Running on http://:8081
  336 +2019/11/22 16:33:06.599 [D] [main.go:17] 加载配置dev
  337 +2019/11/22 16:33:06.746 [D] [main.go:23] 应用启动
  338 +2019/11/22 16:33:06.818 [I] [app.go:215] http server Running on http://:8081
  339 +2019/11/22 16:33:07.875 [D] [main.go:17] 加载配置dev
  340 +2019/11/22 16:33:08.335 [D] [main.go:23] 应用启动
  341 +2019/11/22 16:33:08.384 [I] [app.go:215] http server Running on http://:8081
  342 +2019/11/22 16:33:09.094 [D] [main.go:17] 加载配置dev
  343 +2019/11/22 16:33:09.271 [D] [main.go:23] 应用启动
  344 +2019/11/22 16:33:09.317 [I] [app.go:215] http server Running on http://:8081
  345 +2019/11/22 16:33:12.363 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  346 +2019/11/22 16:33:12.363 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
  347 +2019/11/22 16:33:12.363 [D] [middle.go:50] 执行中间件AuthToken
  348 +2019/11/22 16:33:28.517 [D] [main.go:17] 加载配置dev
  349 +2019/11/22 16:33:28.799 [D] [main.go:23] 应用启动
  350 +2019/11/22 16:33:28.847 [I] [app.go:215] http server Running on http://:8081
  351 +2019/11/22 16:33:33.961 [D] [main.go:17] 加载配置dev
  352 +2019/11/22 16:33:34.183 [D] [main.go:23] 应用启动
  353 +2019/11/22 16:33:34.239 [I] [app.go:215] http server Running on http://:8081
  354 +2019/11/22 16:33:37.783 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  355 +2019/11/22 16:33:37.784 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
  356 +2019/11/22 16:33:37.785 [D] [middle.go:50] 执行中间件AuthToken
  357 +2019/11/22 16:33:54.888 [D] [main.go:17] 加载配置dev
  358 +2019/11/22 16:33:55.214 [D] [main.go:23] 应用启动
  359 +2019/11/22 16:33:55.264 [I] [app.go:215] http server Running on http://:8081
  360 +2019/11/22 16:34:14.502 [D] [main.go:17] 加载配置dev
  361 +2019/11/22 16:34:16.075 [D] [main.go:23] 应用启动
  362 +2019/11/22 16:34:16.136 [I] [app.go:215] http server Running on http://:8081
  363 +2019/11/22 16:34:16.399 [D] [main.go:17] 加载配置dev
  364 +2019/11/22 16:34:16.779 [D] [main.go:23] 应用启动
  365 +2019/11/22 16:34:16.847 [I] [app.go:215] http server Running on http://:8081
  366 +2019/11/22 16:34:20.114 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  367 +2019/11/22 16:34:20.115 [I] [middle.go:17] ====>Recv data from client: HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[078d2093-850a-40f8-8fdb-45dd7587a3a7] User-Agent:[PostmanRuntime/7.20.1]] BodyData: {
  368 +
  369 +}
  370 +2019/11/22 16:34:20.115 [D] [middle.go:49] 执行中间件AuthToken
  371 +2019/11/22 16:34:43.123 [D] [main.go:17] 加载配置dev
  372 +2019/11/22 16:34:44.647 [D] [main.go:23] 应用启动
  373 +2019/11/22 16:34:44.790 [I] [app.go:215] http server Running on http://:8081
  374 +2019/11/22 16:34:46.920 [D] [main.go:17] 加载配置dev
  375 +2019/11/22 16:34:47.313 [D] [main.go:23] 应用启动
  376 +2019/11/22 16:34:47.375 [I] [app.go:215] http server Running on http://:8081
  377 +2019/11/22 16:34:49.202 [D] [main.go:17] 加载配置dev
  378 +2019/11/22 16:34:49.866 [D] [main.go:23] 应用启动
  379 +2019/11/22 16:34:49.939 [I] [app.go:215] http server Running on http://:8081
  380 +2019/11/22 16:34:50.446 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
  381 +2019/11/22 16:34:50.446 [I] [middle.go:17] ====>Recv data from client:
  382 +HeadData: map[Accept:[*/*] Accept-Encoding:[gzip, deflate] Cache-Control:[no-cache] Connection:[keep-alive] Content-Length:[5] Content-Type:[application/json] Postman-Token:[3314f1ce-4ee8-493a-b815-d28c546ccc94] User-Agent:[PostmanRuntime/7.20.1]]
  383 +BodyData: {
  384 +
  385 +}
  386 +2019/11/22 16:34:50.450 [D] [middle.go:49] 执行中间件AuthToken
  387 +2019/11/22 16:35:38.163 [D] [main.go:17] 加载配置dev
  388 +2019/11/22 16:35:39.383 [D] [main.go:23] 应用启动
  389 +2019/11/22 16:35:39.459 [I] [app.go:215] http server Running on http://:8081
  390 +2019/11/22 16:36:21.655 [D] [main.go:17] 加载配置dev
  391 +2019/11/22 16:36:21.908 [D] [main.go:23] 应用启动
  392 +2019/11/22 16:36:21.966 [I] [app.go:215] http server Running on http://:8081
  393 +2019/11/22 16:36:51.234 [D] [main.go:17] 加载配置dev
  394 +2019/11/22 16:36:52.377 [D] [main.go:23] 应用启动
  395 +2019/11/22 16:36:52.472 [I] [app.go:215] http server Running on http://:8081
  396 +2019/11/22 16:39:03.039 [D] [main.go:17] 加载配置dev
  397 +2019/11/22 16:39:03.240 [D] [main.go:23] 应用启动
  398 +2019/11/22 16:39:03.325 [I] [app.go:215] http server Running on http://:8081
  399 +2019/11/22 16:40:02.095 [D] [main.go:17] 加载配置dev
  400 +2019/11/22 16:40:02.338 [D] [main.go:23] 应用启动
  401 +2019/11/22 16:40:02.387 [I] [app.go:215] http server Running on http://:8081
  402 +2019/11/22 16:41:44.495 [D] [main.go:17] 加载配置dev
  403 +2019/11/22 16:41:44.690 [D] [main.go:23] 应用启动
  404 +2019/11/22 16:41:44.743 [I] [app.go:215] http server Running on http://:8081
  405 +2019/11/22 16:42:11.583 [D] [main.go:17] 加载配置dev
  406 +2019/11/22 16:42:15.632 [D] [main.go:23] 应用启动
  407 +2019/11/22 16:42:15.716 [I] [app.go:215] http server Running on http://:8081
  408 +2019/11/22 16:42:27.003 [D] [main.go:17] 加载配置dev
  409 +2019/11/22 16:42:34.425 [D] [main.go:23] 应用启动
  410 +2019/11/22 16:42:34.496 [I] [app.go:215] http server Running on http://:8081
  411 +2019/11/22 16:44:05.564 [D] [main.go:17] 加载配置dev
  412 +2019/11/22 16:44:06.329 [D] [main.go:23] 应用启动
  413 +2019/11/22 16:44:06.394 [I] [app.go:215] http server Running on http://:8081
  414 +2019/11/22 16:44:06.785 [D] [main.go:17] 加载配置dev
  415 +2019/11/22 16:44:09.953 [D] [main.go:23] 应用启动
  416 +2019/11/22 16:44:10.002 [I] [app.go:215] http server Running on http://:8081
  417 +2019/11/22 16:44:42.074 [D] [main.go:17] 加载配置dev
  418 +2019/11/22 16:44:42.553 [D] [main.go:23] 应用启动
  419 +2019/11/22 16:44:42.601 [I] [app.go:215] http server Running on http://:8081
  420 +2019/11/22 16:45:31.567 [D] [main.go:17] 加载配置dev
  421 +2019/11/22 16:45:31.958 [D] [main.go:23] 应用启动
  422 +2019/11/22 16:45:32.030 [I] [app.go:215] http server Running on http://:8081
  423 +2019/11/22 16:45:40.362 [D] [main.go:17] 加载配置dev
  424 +2019/11/22 16:45:40.787 [D] [main.go:23] 应用启动
  425 +2019/11/22 16:45:40.844 [I] [app.go:215] http server Running on http://:8081
  426 +2019/11/22 16:45:41.592 [D] [main.go:17] 加载配置dev
  427 +2019/11/22 16:45:42.761 [D] [main.go:17] 加载配置dev
  428 +2019/11/22 16:45:42.926 [D] [main.go:23] 应用启动
  429 +2019/11/22 16:45:42.983 [I] [app.go:215] http server Running on http://:8081
  430 +2019/11/22 16:46:19.031 [D] [main.go:17] 加载配置dev
  431 +2019/11/22 16:46:20.204 [D] [main.go:23] 应用启动
  432 +2019/11/22 16:46:20.253 [I] [app.go:215] http server Running on http://:8081
  433 +2019/11/22 16:46:21.293 [D] [main.go:17] 加载配置dev
  434 +2019/11/22 16:46:21.475 [D] [main.go:23] 应用启动
  435 +2019/11/22 16:46:21.537 [I] [app.go:215] http server Running on http://:8081
  436 +2019/11/22 16:53:02.075 [D] [main.go:17] 加载配置dev
  437 +2019/11/22 16:53:02.311 [D] [main.go:23] 应用启动
  438 +2019/11/22 16:53:02.360 [I] [app.go:215] http server Running on http://:8081
  439 +2019/11/22 17:01:12.630 [D] [main.go:17] 加载配置dev
  440 +2019/11/22 17:01:17.016 [D] [main.go:23] 应用启动
  441 +2019/11/22 17:01:17.094 [I] [app.go:215] http server Running on http://:8081
  442 +2019/11/22 17:07:05.719 [D] [main.go:17] 加载配置dev
  443 +2019/11/22 17:07:06.016 [D] [main.go:23] 应用启动
  444 +2019/11/22 17:07:06.083 [I] [app.go:215] http server Running on http://:8081
  445 +2019/11/22 17:07:07.864 [D] [main.go:17] 加载配置dev
  446 +2019/11/22 17:07:08.315 [D] [main.go:23] 应用启动
  447 +2019/11/22 17:07:08.364 [I] [app.go:215] http server Running on http://:8081
  448 +2019/11/22 17:07:09.026 [D] [main.go:17] 加载配置dev
  449 +2019/11/22 17:07:09.199 [D] [main.go:23] 应用启动
  450 +2019/11/22 17:07:09.253 [I] [app.go:215] http server Running on http://:8081
  451 +2019/11/22 17:07:10.263 [D] [main.go:17] 加载配置dev
  452 +2019/11/22 17:07:10.906 [D] [main.go:23] 应用启动
  453 +2019/11/22 17:07:10.956 [I] [app.go:215] http server Running on http://:8081
  454 +2019/11/22 17:07:11.507 [D] [main.go:17] 加载配置dev
  455 +2019/11/22 17:07:11.748 [D] [main.go:23] 应用启动
  456 +2019/11/22 17:07:11.796 [I] [app.go:215] http server Running on http://:8081
  457 +2019/11/22 17:08:05.253 [D] [main.go:17] 加载配置dev
  458 +2019/11/22 17:08:05.549 [D] [main.go:23] 应用启动
  459 +2019/11/22 17:08:05.598 [I] [app.go:215] http server Running on http://:8081
  460 +2019/11/22 17:08:53.302 [D] [main.go:17] 加载配置dev
  461 +2019/11/22 17:08:53.644 [D] [main.go:23] 应用启动
  462 +2019/11/22 17:08:53.697 [I] [app.go:215] http server Running on http://:8081
  463 +2019/11/22 17:08:54.475 [D] [main.go:17] 加载配置dev
  464 +2019/11/22 17:08:54.638 [D] [main.go:23] 应用启动
  465 +2019/11/22 17:08:54.684 [I] [app.go:215] http server Running on http://:8081
  466 +2019/11/22 17:10:36.292 [D] [main.go:17] 加载配置dev
  467 +2019/11/22 17:10:36.459 [D] [main.go:23] 应用启动
  468 +2019/11/22 17:10:36.514 [I] [app.go:215] http server Running on http://:8081
  469 +2019/11/22 17:10:37.473 [D] [main.go:17] 加载配置dev
  470 +2019/11/22 17:10:37.612 [D] [main.go:23] 应用启动
  471 +2019/11/22 17:10:37.668 [I] [app.go:215] http server Running on http://:8081
  472 +2019/11/22 17:11:05.972 [D] [main.go:17] 加载配置dev
  473 +2019/11/22 17:11:06.182 [D] [main.go:23] 应用启动
  474 +2019/11/22 17:11:06.233 [I] [app.go:215] http server Running on http://:8081
  475 +2019/11/22 17:11:22.643 [D] [main.go:17] 加载配置dev
  476 +2019/11/22 17:11:22.806 [D] [main.go:23] 应用启动
  477 +2019/11/22 17:11:22.887 [I] [app.go:215] http server Running on http://:8081
  478 +2019/11/22 17:11:55.021 [D] [main.go:17] 加载配置dev
  479 +2019/11/22 17:11:57.751 [D] [main.go:23] 应用启动
  480 +2019/11/22 17:11:57.840 [I] [app.go:215] http server Running on http://:8081
  481 +2019/11/22 17:12:04.495 [D] [main.go:17] 加载配置dev
  482 +2019/11/22 17:12:04.720 [D] [main.go:23] 应用启动
  483 +2019/11/22 17:12:04.769 [I] [app.go:215] http server Running on http://:8081
  484 +2019/11/22 17:12:15.633 [D] [main.go:17] 加载配置dev
  485 +2019/11/22 17:12:16.816 [D] [main.go:23] 应用启动
  486 +2019/11/22 17:12:16.900 [I] [app.go:215] http server Running on http://:8081
  487 +2019/11/22 17:12:20.133 [D] [main.go:17] 加载配置dev
  488 +2019/11/22 17:12:20.708 [D] [main.go:23] 应用启动
  489 +2019/11/22 17:12:20.784 [I] [app.go:215] http server Running on http://:8081
  490 +2019/11/22 17:12:28.142 [D] [main.go:17] 加载配置dev
  491 +2019/11/22 17:12:28.324 [D] [main.go:23] 应用启动
  492 +2019/11/22 17:12:28.372 [I] [app.go:215] http server Running on http://:8081
  493 +2019/11/22 17:26:08.700 [D] [main.go:17] 加载配置dev
  494 +2019/11/22 17:26:08.880 [D] [main.go:23] 应用启动
  495 +2019/11/22 17:26:08.964 [I] [app.go:215] http server Running on http://:8081
  496 +2019/11/22 17:26:09.874 [D] [main.go:17] 加载配置dev
  497 +2019/11/22 17:26:10.020 [D] [main.go:23] 应用启动
  498 +2019/11/22 17:26:10.077 [I] [app.go:215] http server Running on http://:8081
  499 +2019/11/22 17:26:52.546 [D] [main.go:17] 加载配置dev
  500 +2019/11/22 17:26:54.619 [D] [main.go:23] 应用启动
  501 +2019/11/22 17:26:54.671 [I] [app.go:215] http server Running on http://:8081
  502 +2019/11/22 17:28:46.538 [D] [main.go:17] 加载配置dev
  503 +2019/11/22 17:28:46.676 [D] [main.go:23] 应用启动
  504 +2019/11/22 17:28:46.724 [I] [app.go:215] http server Running on http://:8081
  505 +2019/11/22 17:32:04.147 [D] [main.go:17] 加载配置dev
  506 +2019/11/22 17:32:04.721 [D] [main.go:23] 应用启动
  507 +2019/11/22 17:32:04.781 [I] [app.go:215] http server Running on http://:8081
  508 +2019/11/22 17:33:01.166 [D] [main.go:17] 加载配置dev
  509 +2019/11/22 17:33:02.550 [D] [main.go:23] 应用启动
  510 +2019/11/22 17:33:02.635 [I] [app.go:215] http server Running on http://:8081
  511 +2019/11/22 17:35:42.989 [D] [main.go:17] 加载配置dev
  512 +2019/11/22 17:35:43.144 [D] [main.go:23] 应用启动
  513 +2019/11/22 17:35:43.201 [I] [app.go:215] http server Running on http://:8081
1 package middleware 1 package middleware
2 2
3 import ( 3 import (
  4 + "crypto/sha256"
  5 + "encoding/hex"
  6 + "fmt"
4 "oppmg/common/log" 7 "oppmg/common/log"
  8 + "oppmg/protocol"
  9 + "strings"
5 10
6 "github.com/astaxie/beego/context" 11 "github.com/astaxie/beego/context"
7 ) 12 )
8 13
9 -//AuthToken ... 14 +//LogRequestData Before Router
  15 +var LogRequestData = func(ctx *context.Context) {
  16 + log.Info("====>Recv Request:%s", ctx.Input.URI())
  17 + if ctx.Input.RequestBody != nil {
  18 + log.Info("====>Recv data from client:\nHeadData: %s \nBodyData: %s", ctx.Request.Header, string(ctx.Input.RequestBody))
  19 + } else {
  20 + log.Info("====>Recv data from client:\nHeadData: %s ", ctx.Request.Header)
  21 + }
  22 +}
  23 +
  24 +//CheckSign Before Router
  25 +var CheckSign = func(ctx *context.Context) {
  26 + var (
  27 + headTimeStamp string
  28 + headUuid string
  29 + headAccessToken string
  30 + headSign string
  31 + signHex string
  32 + )
  33 + headTimeStamp = ctx.Input.Header(protocol.HeaderTimestamp)
  34 + headUuid = ctx.Input.Header(protocol.HeaderUUID)
  35 + headSign = ctx.Input.Header(protocol.HeaderSign)
  36 + setsign := fmt.Sprintf("v!(MmM%v%v%vMmM)i^", headTimeStamp, headUuid, headAccessToken)
  37 + sha256 := sha256.New()
  38 + sha256.Write([]byte(setsign))
  39 + signHex = hex.EncodeToString(sha256.Sum(nil))
  40 + if strings.Compare(signHex, headSign) != 0 {
  41 + msg := protocol.BadRequestParam("113")
  42 + ctx.Output.JSON(msg, false, false)
  43 + return
  44 + }
  45 + return
  46 +}
  47 +
  48 +//AuthToken Before Router
10 var AuthToken = func(ctx *context.Context) { 49 var AuthToken = func(ctx *context.Context) {
11 log.Debug("执行中间件AuthToken") 50 log.Debug("执行中间件AuthToken")
12 - ctx.Output.Body([]byte("{}")) 51 +
  52 + // ctx.Output.Body([]byte("{}"))
13 return 53 return
14 } 54 }
15 55
  1 +package models
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "github.com/astaxie/beego/orm"
  8 +)
  9 +
  10 +type Company struct {
  11 + Id int `orm:"column(id);auto"`
  12 + Name string `orm:"column(name);size(40)"`
  13 + UserId int `orm:"column(user_id)"`
  14 + CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now"`
  15 + UpdateAt time.Time `orm:"column(update_at);type(timestamp)"`
  16 + DeleteAt time.Time `orm:"column(delete_at);type(timestamp)"`
  17 + Logo string `orm:"column(logo);size(255)"`
  18 +}
  19 +
  20 +func (t *Company) TableName() string {
  21 + return "company"
  22 +}
  23 +
  24 +func init() {
  25 + orm.RegisterModel(new(Company))
  26 +}
  27 +
  28 +// AddCompany insert a new Company into database and returns
  29 +// last inserted Id on success.
  30 +func AddCompany(m *Company) (id int64, err error) {
  31 + o := orm.NewOrm()
  32 + id, err = o.Insert(m)
  33 + return
  34 +}
  35 +
  36 +// GetCompanyById retrieves Company by Id. Returns error if
  37 +// Id doesn't exist
  38 +func GetCompanyById(id int) (v *Company, err error) {
  39 + o := orm.NewOrm()
  40 + v = &Company{Id: id}
  41 + if err = o.Read(v); err == nil {
  42 + return v, nil
  43 + }
  44 + return nil, err
  45 +}
  46 +
  47 +// UpdateCompany updates Company by Id and returns error if
  48 +// the record to be updated doesn't exist
  49 +func UpdateCompanyById(m *Company) (err error) {
  50 + o := orm.NewOrm()
  51 + v := Company{Id: m.Id}
  52 + // ascertain id exists in the database
  53 + if err = o.Read(&v); err == nil {
  54 + var num int64
  55 + if num, err = o.Update(m); err == nil {
  56 + fmt.Println("Number of records updated in database:", num)
  57 + }
  58 + }
  59 + return
  60 +}
  61 +
  62 +// DeleteCompany deletes Company by Id and returns error if
  63 +// the record to be deleted doesn't exist
  64 +func DeleteCompany(id int) (err error) {
  65 + o := orm.NewOrm()
  66 + v := Company{Id: id}
  67 + // ascertain id exists in the database
  68 + if err = o.Read(&v); err == nil {
  69 + var num int64
  70 + if num, err = o.Delete(&Company{Id: id}); err == nil {
  71 + fmt.Println("Number of records deleted in database:", num)
  72 + }
  73 + }
  74 + return
  75 +}
@@ -5,49 +5,57 @@ import ( @@ -5,49 +5,57 @@ import (
5 "fmt" 5 "fmt"
6 "reflect" 6 "reflect"
7 "strings" 7 "strings"
  8 + "time"
8 9
9 "github.com/astaxie/beego/orm" 10 "github.com/astaxie/beego/orm"
10 ) 11 )
11 12
12 -type Permission struct {  
13 - Id int `orm:"column(id);pk"`  
14 - Name string `orm:"column(name);size(30)"`  
15 - Pid int `orm:"column(pid);null"` 13 +type Department struct {
  14 + Id int `orm:"column(id);auto"`
  15 + CompanyId int `orm:"column(company_id)" description:"公司id"`
  16 + Name string `orm:"column(name);size(30)" description:"部门名称"`
  17 + CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
  18 + ParentId int `orm:"column(parent_id)" description:"父级id"`
  19 + Relation string `orm:"column(relation);size(1024)" description:"父子级关系树"`
  20 + DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"`
  21 + UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
  22 + Member int `orm:"column(member)" description:"成员数量"`
  23 + Admin int `orm:"column(admin);null" description:"部门负责人id"`
16 } 24 }
17 25
18 -func (t *Permission) TableName() string {  
19 - return "permission" 26 +func (t *Department) TableName() string {
  27 + return "department"
20 } 28 }
21 29
22 func init() { 30 func init() {
23 - orm.RegisterModel(new(Permission)) 31 + orm.RegisterModel(new(Department))
24 } 32 }
25 33
26 -// AddPermission insert a new Permission into database and returns 34 +// AddDepartment insert a new Department into database and returns
27 // last inserted Id on success. 35 // last inserted Id on success.
28 -func AddPermission(m *Permission) (id int64, err error) { 36 +func AddDepartment(m *Department) (id int64, err error) {
29 o := orm.NewOrm() 37 o := orm.NewOrm()
30 id, err = o.Insert(m) 38 id, err = o.Insert(m)
31 return 39 return
32 } 40 }
33 41
34 -// GetPermissionById retrieves Permission by Id. Returns error if 42 +// GetDepartmentById retrieves Department by Id. Returns error if
35 // Id doesn't exist 43 // Id doesn't exist
36 -func GetPermissionById(id int) (v *Permission, err error) { 44 +func GetDepartmentById(id int) (v *Department, err error) {
37 o := orm.NewOrm() 45 o := orm.NewOrm()
38 - v = &Permission{Id: id} 46 + v = &Department{Id: id}
39 if err = o.Read(v); err == nil { 47 if err = o.Read(v); err == nil {
40 return v, nil 48 return v, nil
41 } 49 }
42 return nil, err 50 return nil, err
43 } 51 }
44 52
45 -// GetAllPermission retrieves all Permission matches certain condition. Returns empty list if 53 +// GetAllDepartment retrieves all Department matches certain condition. Returns empty list if
46 // no records exist 54 // no records exist
47 -func GetAllPermission(query map[string]string, fields []string, sortby []string, order []string, 55 +func GetAllDepartment(query map[string]string, fields []string, sortby []string, order []string,
48 offset int64, limit int64) (ml []interface{}, err error) { 56 offset int64, limit int64) (ml []interface{}, err error) {
49 o := orm.NewOrm() 57 o := orm.NewOrm()
50 - qs := o.QueryTable(new(Permission)) 58 + qs := o.QueryTable(new(Department))
51 // query k=v 59 // query k=v
52 for k, v := range query { 60 for k, v := range query {
53 // rewrite dot-notation to Object__Attribute 61 // rewrite dot-notation to Object__Attribute
@@ -97,7 +105,7 @@ func GetAllPermission(query map[string]string, fields []string, sortby []string, @@ -97,7 +105,7 @@ func GetAllPermission(query map[string]string, fields []string, sortby []string,
97 } 105 }
98 } 106 }
99 107
100 - var l []Permission 108 + var l []Department
101 qs = qs.OrderBy(sortFields...) 109 qs = qs.OrderBy(sortFields...)
102 if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil { 110 if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
103 if len(fields) == 0 { 111 if len(fields) == 0 {
@@ -120,11 +128,11 @@ func GetAllPermission(query map[string]string, fields []string, sortby []string, @@ -120,11 +128,11 @@ func GetAllPermission(query map[string]string, fields []string, sortby []string,
120 return nil, err 128 return nil, err
121 } 129 }
122 130
123 -// UpdatePermission updates Permission by Id and returns error if 131 +// UpdateDepartment updates Department by Id and returns error if
124 // the record to be updated doesn't exist 132 // the record to be updated doesn't exist
125 -func UpdatePermissionById(m *Permission) (err error) { 133 +func UpdateDepartmentById(m *Department) (err error) {
126 o := orm.NewOrm() 134 o := orm.NewOrm()
127 - v := Permission{Id: m.Id} 135 + v := Department{Id: m.Id}
128 // ascertain id exists in the database 136 // ascertain id exists in the database
129 if err = o.Read(&v); err == nil { 137 if err = o.Read(&v); err == nil {
130 var num int64 138 var num int64
@@ -135,15 +143,15 @@ func UpdatePermissionById(m *Permission) (err error) { @@ -135,15 +143,15 @@ func UpdatePermissionById(m *Permission) (err error) {
135 return 143 return
136 } 144 }
137 145
138 -// DeletePermission deletes Permission by Id and returns error if 146 +// DeleteDepartment deletes Department by Id and returns error if
139 // the record to be deleted doesn't exist 147 // the record to be deleted doesn't exist
140 -func DeletePermission(id int) (err error) { 148 +func DeleteDepartment(id int) (err error) {
141 o := orm.NewOrm() 149 o := orm.NewOrm()
142 - v := Permission{Id: id} 150 + v := Department{Id: id}
143 // ascertain id exists in the database 151 // ascertain id exists in the database
144 if err = o.Read(&v); err == nil { 152 if err = o.Read(&v); err == nil {
145 var num int64 153 var num int64
146 - if num, err = o.Delete(&Permission{Id: id}); err == nil { 154 + if num, err = o.Delete(&Department{Id: id}); err == nil {
147 fmt.Println("Number of records deleted in database:", num) 155 fmt.Println("Number of records deleted in database:", num)
148 } 156 }
149 } 157 }
1 package models 1 package models
2 2
3 import ( 3 import (
4 - "errors"  
5 - "fmt"  
6 - "reflect"  
7 - "strings" 4 + "oppmg/common/log"
8 "time" 5 "time"
9 6
10 "github.com/astaxie/beego/orm" 7 "github.com/astaxie/beego/orm"
@@ -14,8 +11,9 @@ type Role struct { @@ -14,8 +11,9 @@ type Role struct {
14 Id int `orm:"column(id);auto"` 11 Id int `orm:"column(id);auto"`
15 Name string `orm:"column(name);size(30)"` 12 Name string `orm:"column(name);size(30)"`
16 CompanyId int `orm:"column(company_id)"` 13 CompanyId int `orm:"column(company_id)"`
17 - CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now"`  
18 - DeleteAt time.Time `orm:"column(delete_at);type(timestamp);null"` 14 + Descript string `orm:"column(descript)"`
  15 + CreateAt time.Time `orm:"column(create_at);type(timestamp)"`
  16 + DeleteAt time.Time `orm:"column(delete_at);type(timestamp)"`
19 } 17 }
20 18
21 func (t *Role) TableName() string { 19 func (t *Role) TableName() string {
@@ -45,84 +43,6 @@ func GetRoleById(id int) (v *Role, err error) { @@ -45,84 +43,6 @@ func GetRoleById(id int) (v *Role, err error) {
45 return nil, err 43 return nil, err
46 } 44 }
47 45
48 -// GetAllRole retrieves all Role matches certain condition. Returns empty list if  
49 -// no records exist  
50 -func GetAllRole(query map[string]string, fields []string, sortby []string, order []string,  
51 - offset int64, limit int64) (ml []interface{}, err error) {  
52 - o := orm.NewOrm()  
53 - qs := o.QueryTable(new(Role))  
54 - // query k=v  
55 - for k, v := range query {  
56 - // rewrite dot-notation to Object__Attribute  
57 - k = strings.Replace(k, ".", "__", -1)  
58 - if strings.Contains(k, "isnull") {  
59 - qs = qs.Filter(k, (v == "true" || v == "1"))  
60 - } else {  
61 - qs = qs.Filter(k, v)  
62 - }  
63 - }  
64 - // order by:  
65 - var sortFields []string  
66 - if len(sortby) != 0 {  
67 - if len(sortby) == len(order) {  
68 - // 1) for each sort field, there is an associated order  
69 - for i, v := range sortby {  
70 - orderby := ""  
71 - if order[i] == "desc" {  
72 - orderby = "-" + v  
73 - } else if order[i] == "asc" {  
74 - orderby = v  
75 - } else {  
76 - return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")  
77 - }  
78 - sortFields = append(sortFields, orderby)  
79 - }  
80 - qs = qs.OrderBy(sortFields...)  
81 - } else if len(sortby) != len(order) && len(order) == 1 {  
82 - // 2) there is exactly one order, all the sorted fields will be sorted by this order  
83 - for _, v := range sortby {  
84 - orderby := ""  
85 - if order[0] == "desc" {  
86 - orderby = "-" + v  
87 - } else if order[0] == "asc" {  
88 - orderby = v  
89 - } else {  
90 - return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")  
91 - }  
92 - sortFields = append(sortFields, orderby)  
93 - }  
94 - } else if len(sortby) != len(order) && len(order) != 1 {  
95 - return nil, errors.New("Error: 'sortby', 'order' sizes mismatch or 'order' size is not 1")  
96 - }  
97 - } else {  
98 - if len(order) != 0 {  
99 - return nil, errors.New("Error: unused 'order' fields")  
100 - }  
101 - }  
102 -  
103 - var l []Role  
104 - qs = qs.OrderBy(sortFields...)  
105 - if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {  
106 - if len(fields) == 0 {  
107 - for _, v := range l {  
108 - ml = append(ml, v)  
109 - }  
110 - } else {  
111 - // trim unused fields  
112 - for _, v := range l {  
113 - m := make(map[string]interface{})  
114 - val := reflect.ValueOf(v)  
115 - for _, fname := range fields {  
116 - m[fname] = val.FieldByName(fname).Interface()  
117 - }  
118 - ml = append(ml, m)  
119 - }  
120 - }  
121 - return ml, nil  
122 - }  
123 - return nil, err  
124 -}  
125 -  
126 // UpdateRole updates Role by Id and returns error if 46 // UpdateRole updates Role by Id and returns error if
127 // the record to be updated doesn't exist 47 // the record to be updated doesn't exist
128 func UpdateRoleById(m *Role) (err error) { 48 func UpdateRoleById(m *Role) (err error) {
@@ -132,7 +52,7 @@ func UpdateRoleById(m *Role) (err error) { @@ -132,7 +52,7 @@ func UpdateRoleById(m *Role) (err error) {
132 if err = o.Read(&v); err == nil { 52 if err = o.Read(&v); err == nil {
133 var num int64 53 var num int64
134 if num, err = o.Update(m); err == nil { 54 if num, err = o.Update(m); err == nil {
135 - fmt.Println("Number of records updated in database:", num) 55 + log.Debug("Number of records updated in database:%d", num)
136 } 56 }
137 } 57 }
138 return 58 return
@@ -146,8 +66,9 @@ func DeleteRole(id int) (err error) { @@ -146,8 +66,9 @@ func DeleteRole(id int) (err error) {
146 // ascertain id exists in the database 66 // ascertain id exists in the database
147 if err = o.Read(&v); err == nil { 67 if err = o.Read(&v); err == nil {
148 var num int64 68 var num int64
149 - if num, err = o.Delete(&Role{Id: id}); err == nil {  
150 - fmt.Println("Number of records deleted in database:", num) 69 + v.DeleteAt = time.Now()
  70 + if num, err = o.Update(&v); err == nil {
  71 + log.Debug("Number of records deleted in database:%d", num)
151 } 72 }
152 } 73 }
153 return 74 return
1 package models 1 package models
2 2
3 import ( 3 import (
4 - "errors"  
5 "fmt" 4 "fmt"
6 - "reflect"  
7 - "strings"  
8 "time" 5 "time"
9 6
10 "github.com/astaxie/beego/orm" 7 "github.com/astaxie/beego/orm"
@@ -16,12 +13,6 @@ type User struct { @@ -16,12 +13,6 @@ type User struct {
16 Phone string `orm:"column(phone);size(40)" description:"手机号码"` 13 Phone string `orm:"column(phone);size(40)" description:"手机号码"`
17 Passwd string `orm:"column(passwd);size(128)" description:"密码"` 14 Passwd string `orm:"column(passwd);size(128)" description:"密码"`
18 Icon string `orm:"column(icon);size(255)" description:"头像"` 15 Icon string `orm:"column(icon);size(255)" description:"头像"`
19 - CompanyId int `orm:"column(company_id)" description:"公司Id"`  
20 - DepartmentId int `orm:"column(department_id)" description:"部门id"`  
21 - PositionId int `orm:"column(position_id)" description:"职位id"`  
22 - CsAccount int64 `orm:"column(cs_account)" description:"客服有话说ID"`  
23 - IsKefu int8 `orm:"column(is_kefu)" description:"是否是客服 0:否 1:是"`  
24 - ImToken string `orm:"column(im_token);size(128)" description:"网易云token"`  
25 LastLoginTime time.Time `orm:"column(last_login_time);type(timestamp)" description:"最后一次登录时间"` 16 LastLoginTime time.Time `orm:"column(last_login_time);type(timestamp)" description:"最后一次登录时间"`
26 CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now_add" description:"创建时间"` 17 CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now_add" description:"创建时间"`
27 EnableStatus int8 `orm:"column(enable_status)" description:"是否有效"` 18 EnableStatus int8 `orm:"column(enable_status)" description:"是否有效"`
@@ -54,84 +45,6 @@ func GetUserById(id int) (v *User, err error) { @@ -54,84 +45,6 @@ func GetUserById(id int) (v *User, err error) {
54 return nil, err 45 return nil, err
55 } 46 }
56 47
57 -// GetAllUser retrieves all User matches certain condition. Returns empty list if  
58 -// no records exist  
59 -func GetAllUser(query map[string]string, fields []string, sortby []string, order []string,  
60 - offset int64, limit int64) (ml []interface{}, err error) {  
61 - o := orm.NewOrm()  
62 - qs := o.QueryTable(new(User))  
63 - // query k=v  
64 - for k, v := range query {  
65 - // rewrite dot-notation to Object__Attribute  
66 - k = strings.Replace(k, ".", "__", -1)  
67 - if strings.Contains(k, "isnull") {  
68 - qs = qs.Filter(k, (v == "true" || v == "1"))  
69 - } else {  
70 - qs = qs.Filter(k, v)  
71 - }  
72 - }  
73 - // order by:  
74 - var sortFields []string  
75 - if len(sortby) != 0 {  
76 - if len(sortby) == len(order) {  
77 - // 1) for each sort field, there is an associated order  
78 - for i, v := range sortby {  
79 - orderby := ""  
80 - if order[i] == "desc" {  
81 - orderby = "-" + v  
82 - } else if order[i] == "asc" {  
83 - orderby = v  
84 - } else {  
85 - return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")  
86 - }  
87 - sortFields = append(sortFields, orderby)  
88 - }  
89 - qs = qs.OrderBy(sortFields...)  
90 - } else if len(sortby) != len(order) && len(order) == 1 {  
91 - // 2) there is exactly one order, all the sorted fields will be sorted by this order  
92 - for _, v := range sortby {  
93 - orderby := ""  
94 - if order[0] == "desc" {  
95 - orderby = "-" + v  
96 - } else if order[0] == "asc" {  
97 - orderby = v  
98 - } else {  
99 - return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")  
100 - }  
101 - sortFields = append(sortFields, orderby)  
102 - }  
103 - } else if len(sortby) != len(order) && len(order) != 1 {  
104 - return nil, errors.New("Error: 'sortby', 'order' sizes mismatch or 'order' size is not 1")  
105 - }  
106 - } else {  
107 - if len(order) != 0 {  
108 - return nil, errors.New("Error: unused 'order' fields")  
109 - }  
110 - }  
111 -  
112 - var l []User  
113 - qs = qs.OrderBy(sortFields...)  
114 - if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {  
115 - if len(fields) == 0 {  
116 - for _, v := range l {  
117 - ml = append(ml, v)  
118 - }  
119 - } else {  
120 - // trim unused fields  
121 - for _, v := range l {  
122 - m := make(map[string]interface{})  
123 - val := reflect.ValueOf(v)  
124 - for _, fname := range fields {  
125 - m[fname] = val.FieldByName(fname).Interface()  
126 - }  
127 - ml = append(ml, m)  
128 - }  
129 - }  
130 - return ml, nil  
131 - }  
132 - return nil, err  
133 -}  
134 -  
135 // UpdateUser updates User by Id and returns error if 48 // UpdateUser updates User by Id and returns error if
136 // the record to be updated doesn't exist 49 // the record to be updated doesn't exist
137 func UpdateUserById(m *User) (err error) { 50 func UpdateUserById(m *User) (err error) {
  1 +package protocol
  2 +
  3 +const (
  4 + HeaderAccessToken string = "x-mmm-accesstoken"
  5 + HeaderRefreshToken string = "x-mmm-refreshtoken"
  6 + HeaderUID string = "x-mmm-uid"
  7 + HeaderUUID string = "x-mmm-uuid"
  8 + HeaderTimestamp string = "x-mmm-timestamp"
  9 + HeaderDevicetype string = "x-mmm-devicetype"
  10 + HeaderAppproject string = "x-mmm-appproject"
  11 + HeaderSign string = "x-mmm-sign"
  12 +)
  13 +
  14 +//BaseHeader 请求的header数据
  15 +//减少在具体业务方法中使用 this.Ctx.Input.Header("xxxx")
  16 +type BaseHeader struct {
  17 + AccessToken string
  18 + RefreshToken string
  19 + AppProject string
  20 + Devicetype string
  21 + Sign string
  22 + UUID string
  23 + Timestamp int
  24 + UID int
  25 +}
  1 +package protocol
  2 +
  3 +//RequestRoleAdd 添加角色信息操作入参
  4 +type RequestRoleAdd struct {
  5 + CompanyID int `json:"company,omitempty"`
  6 + RoleName string `json:"role_name"`
  7 + Descript string `json:"descript"`
  8 +}
  9 +
  10 +// func (r RequestRoleAdd) Valid() error {
  11 +// return nil
  12 +// }
  13 +
  14 +type RequestRoleDelete struct {
  15 + CompanyID int `json:"company_id"`
  16 + RoleID int `json:"role_id"`
  17 +}
  18 +
  19 +//RequestRoleEdit 编辑角色信息入参
  20 +type RequestRoleEdit struct {
  21 + RoleID int `json:"role_id"`
  22 + RoleName string `json:"role_name"`
  23 + CompanyID int `json:"company_id"`
  24 + Descript string `json:"descript"`
  25 +}
  26 +
  27 +type RequestRolePermission struct {
  28 + CompanyID int `json:"company_id"`
  29 + RoleID int `json:"role_id"`
  30 + PermissionID []int `json:"permission_id"`
  31 +}
@@ -9,11 +9,15 @@ import ( @@ -9,11 +9,15 @@ import (
9 ) 9 )
10 10
11 func init() { 11 func init() {
  12 + nsV1 := beego.NewNamespace("v1",
  13 + beego.NSBefore(middleware.AuthToken),
  14 + )
12 15
13 nsAuth := beego.NewNamespace("/auth", 16 nsAuth := beego.NewNamespace("/auth",
14 - beego.NSBefore(middleware.AuthToken), 17 + beego.NSBefore(middleware.LogRequestData, middleware.AuthToken),
15 beego.NSRouter("/accessToken", &controllers.AuthController{}, "post:AccessToken"), 18 beego.NSRouter("/accessToken", &controllers.AuthController{}, "post:AccessToken"),
16 ) 19 )
17 - 20 + beego.AddNamespace(nsV1)
18 beego.AddNamespace(nsAuth) 21 beego.AddNamespace(nsAuth)
  22 +
19 } 23 }
  1 +package rbac
  2 +
  3 +import (
  4 + "fmt"
  5 + "oppmg/common/log"
  6 + "oppmg/models"
  7 + "oppmg/protocol"
  8 + "time"
  9 +)
  10 +
  11 +func RoleAdd(param protocol.RequestRoleAdd) error {
  12 + role := models.Role{
  13 + CompanyId: param.CompanyID,
  14 + Name: param.RoleName,
  15 + CreateAt: time.Now(),
  16 + Descript: param.Descript,
  17 + }
  18 + _, err := models.AddRole(&role)
  19 + if err != nil {
  20 + log.Error("AddRole err:%s", err)
  21 + return protocol.NewErrWithMessage("1", err)
  22 + }
  23 + return nil
  24 +}
  25 +
  26 +func RoleDelete(param protocol.RequestRoleDelete) error {
  27 + role, err := models.GetRoleById(param.RoleID)
  28 + if err != nil {
  29 + e := fmt.Errorf("GetRoleById err:%s", err)
  30 + log.Error(e.Error())
  31 + return protocol.NewErrWithMessage("1", e)
  32 + }
  33 + if role.CompanyId != param.CompanyID {
  34 + e := fmt.Errorf("role.CompanyId(%d) != param.CompanyID(%d)", role.CompanyId, param.CompanyID)
  35 + log.Error(e.Error())
  36 + return protocol.NewErrWithMessage("1", e)
  37 + }
  38 + if err := models.DeleteRole(param.RoleID); err != nil {
  39 + e := fmt.Errorf("DeleteRole err:%s", err)
  40 + log.Error(e.Error())
  41 + return protocol.NewErrWithMessage("1", e)
  42 + }
  43 +
  44 + return nil
  45 +}
  46 +
  47 +func RoleEdit(param protocol.RequestRoleEdit) error {
  48 + var (
  49 + role *models.Role
  50 + err error
  51 + )
  52 + role, err = models.GetRoleById(param.RoleID)
  53 + if err != nil {
  54 + e := fmt.Errorf("GetRoleById err:%s", err)
  55 + log.Error(e.Error())
  56 + return protocol.NewErrWithMessage("1", e)
  57 + }
  58 + if role.CompanyId != param.CompanyID {
  59 + e := fmt.Errorf("role.CompanyId(%d) != param.CompanyID(%d)", role.CompanyId, param.CompanyID)
  60 + log.Error(e.Error())
  61 + return protocol.NewErrWithMessage("1", e)
  62 + }
  63 + role.Descript = param.Descript
  64 + role.Name = param.RoleName
  65 + if err = models.UpdateRoleById(role); err != nil {
  66 + e := fmt.Errorf("UpdateRoleById err:%s", err)
  67 + log.Error(e.Error())
  68 + return protocol.NewErrWithMessage("1", e)
  69 + }
  70 +
  71 + return nil
  72 +}
  73 +
  74 +func RoleGetOne() error {
  75 + return nil
  76 +}
  77 +
  78 +func RoleGetByPage() error {
  79 + return nil
  80 +}
1 package serveauth 1 package serveauth
2 2
3 import ( 3 import (
  4 + "oppmg/common/config"
  5 + "oppmg/common/log"
4 "oppmg/protocol" 6 "oppmg/protocol"
5 ) 7 )
6 8
7 func GetAccessToken(param protocol.RequestCheckSmsCode) (*protocol.DataUserInfo, error) { 9 func GetAccessToken(param protocol.RequestCheckSmsCode) (*protocol.DataUserInfo, error) {
8 data := &protocol.DataUserInfo{} 10 data := &protocol.DataUserInfo{}
9 err := protocol.NewErrWithMessage("00000") 11 err := protocol.NewErrWithMessage("00000")
  12 + log.Info("log 打印")
  13 + log.Info("%+v", config.MConfig)
10 return data, err 14 return data, err
11 } 15 }
  1 +package utils
  1 +package utils
  2 +
  3 +import (
  4 + "github.com/sony/sonyflake"
  5 +)
  6 +
  7 +var sf = sonyflake.NewSonyflake(sonyflake.Settings{})
  8 +
  9 +func GetUniqueId() int64 {
  10 + num, _ := sf.NextID()
  11 + return int64(num)
  12 +}
1 -package utils  
2 -  
3 -import "time"  
4 -  
5 -var localtime = time.FixedZone("UTC", 8*3600)  
6 -  
7 -//LocalTimeZone 设定时区东八区  
8 -func LocalTimeZone() *time.Location {  
9 -  
10 - return localtime  
11 -}  
12 -  
13 -//LocalTime ....  
14 -func LocalTime() time.Time {  
15 - return new(time.Time).In(localtime)  
16 -}