作者 唐旭辉

新增

... ... @@ -12,7 +12,7 @@ func ResetCommonConfig() {
var setlog log.SetLoggerConfig
if mconfig.LogOutput == "console" {
setlog = &log.LoggerConsole{
Level: log.LogLevelDebug, Color: true,
Level: log.LogLevelDebug, Color: false,
}
} else if mconfig.LogOutput == "file" {
setlog = &log.LoggerFile{
... ...
... ... @@ -26,7 +26,7 @@ func RestMyConfig() *MyConfig {
RedisAddPort: beego.AppConfig.String("redis_add_port"),
RedisAuth: beego.AppConfig.DefaultString("redis_auth", ""),
RedisDB: beego.AppConfig.DefaultString("redis_db", "0"),
LogOutput: beego.AppConfig.DefaultString("log_outpur", "console"),
LogOutput: beego.AppConfig.DefaultString("log_output", "console"),
LogFilename: beego.AppConfig.DefaultString("log_filename", "./log/ability.log"),
LogLevel: beego.AppConfig.DefaultString("log_Level", "debug"),
}
... ...
... ... @@ -68,12 +68,10 @@ var logger *logs.BeeLogger
func ResetLog(config SetLoggerConfig, funcCall bool) {
logger = logs.GetBeeLogger()
logger.Async(1000)
out := config.Name()
logconf := config.MarshalString()
logger.EnableFuncCallDepth(funcCall)
logger.SetLogFuncCallDepth(3)
logger.SetLogger(out, logconf)
return
}
... ...
... ... @@ -4,24 +4,20 @@ config_name = "dev"
#端口号
httpport = 8081
#开启应用内监控
EnableAdmin = true
EnableAdmin = false
AdminPort = 8088
#---beego的默认配置 结束---
#---自定义配置 开始----
##数据库连接
sqlconn ="root:root@tcp(127.0.0.1:3306)/ability_display?charset=utf8"
# sqlconn ="${MYSQL_CONN||root:root@tcp(127.0.0.1:3306)/opportunity_dev?charset=utf8}"
sqlconn ="${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8}"
##redis相关配置
redis_add_port = "127.0.0.1:6379"
redis_auth = ""
##log相关配置
##out_put:"console","file"
log_output = "file"
log_filename = "./log/ability.log"
# maxlines =
# maxsize =
# daily =
# maxdays =
# rotate =
log_level = "debug"
log_filename = "${LOG_FILENAME||./log/ability.log}"
log_level = "${LOG_LEVEL||debug}"
#---自定义配置 结束----
\ No newline at end of file
... ...
... ... @@ -17,6 +17,7 @@ redis_auth = ""
#log相关配置
#out_put:"console","file"
log_output = "file"
#
log_filename = "./log/ability.log"
# maxlines =
# maxsize =
... ...
... ... @@ -8,18 +8,13 @@ httpport = 8080
#---自定义配置 开始----
#数据库连接
sqlconn = "root:root@tcp(127.0.0.1:3306)/ability_display?charset=utf8"
sqlconn = "${MYSQL_CONN||root:sutianxia2015@tcp(115.29.205.99:3306)/opportunity?charset=utf8}"
#redis相关配置
redis_add_port = "127.0.0.1:6379"
redis_auth = ""
#log相关配置
#out_put:"console","file"
log_output = "file"
log_filename = "./log/ability.log"
# maxlines =
# maxsize =
# daily =
# maxdays =
# rotate =
log_level = "debug"
log_filename = "${LOG_FILENAME||./log/ability.log}"
log_level = "${LOG_LEVEL||debug}"
#---自定义配置 结束----
\ No newline at end of file
... ...
... ... @@ -6,21 +6,15 @@ import (
"net/http"
"oppmg/common/log"
"oppmg/protocol"
"strconv"
"github.com/astaxie/beego"
)
//BaseHeader 请求的header数据
//减少在具体业务方法中使用 this.Ctx.Input.Header("xxxx")
type BaseHeader struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
//BaseController 基础
type BaseController struct {
beego.Controller
AppHead BaseHeader
// AppHead protocol.BaseHeader
}
//Options 实现beego.ControllerInterface 的接口
... ... @@ -32,14 +26,18 @@ func (this *BaseController) Options() {
//Prepare 实现beego.ControllerInterface 的接口
func (this *BaseController) Prepare() {
this.AppHead.AccessToken = this.Ctx.Input.Header("access_token")
this.AppHead.RefreshToken = this.Ctx.Input.Header("refresh_token")
//详细header待定 TODO
if this.Ctx.Input.RequestBody != nil {
log.Info(fmt.Sprintf("====>Recv data from client:\nHeadData: %s\n BodyData: %s", this.Ctx.Request.Header, string(this.Ctx.Input.RequestBody)))
} else {
log.Info(fmt.Sprintf("====>Recv data from client:\nHeadData: %s ", this.Ctx.Request.Header))
}
}
func (this *BaseController) GetAppHead() (appHead protocol.BaseHeader) {
appHead.AccessToken = this.Ctx.Input.Header(protocol.HeaderAccessToken)
appHead.RefreshToken = this.Ctx.Input.Header(protocol.HeaderRefreshToken)
appHead.UID, _ = strconv.Atoi(this.Ctx.Input.Header(protocol.HeaderUID))
appHead.UUID = this.Ctx.Input.Header(protocol.HeaderUUID)
appHead.Timestamp, _ = strconv.Atoi(this.Ctx.Input.Header(protocol.HeaderTimestamp))
appHead.Devicetype = this.Ctx.Input.Header(protocol.HeaderDevicetype)
appHead.AppProject = this.Ctx.Input.Header(protocol.HeaderAppproject)
return
}
... ...
package controllers
type RbacController struct {
BaseController
}
//URLMapping 实现ControllerInterface中的URLMapping
func (c *RbacController) URLMapping() {
//c.Mapping("AccessToken", c.AccessToken)
}
... ...
... ... @@ -11,6 +11,7 @@ require (
github.com/onsi/ginkgo v1.10.3 // indirect
github.com/onsi/gomega v1.7.1 // indirect
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/sony/sonyflake v1.0.0
golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba // indirect
google.golang.org/appengine v1.6.5 // indirect
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
github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c=
github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs=
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY=
github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
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/
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
github.com/sony/sonyflake v1.0.0 h1:MpU6Ro7tfXwgn2l5eluf9xQvQJDROTBImNCfRXn/YeM=
github.com/sony/sonyflake v1.0.0/go.mod h1:Jv3cfhf/UFtolOTTRd3q4Nl6ENqM+KfyZ5PseKfZGF4=
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
... ...
2019/09/25 09:30:17.551 [D] [main.go:23] 应用启动
2019/09/25 09:30:17.602 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:41:04.196 [D] [proc.go:203] 应用启动
2019/09/25 09:41:04.245 [I] [asm_amd64.s:1357] http server Running on http://:8080
2019/09/25 09:41:51.479 [D] [main.go:23] 应用启动
2019/09/25 09:41:51.522 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:43:54.102 [D] [main.go:23] 应用启动
2019/09/25 09:43:54.148 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:44:26.483 [D] 应用启动
2019/09/25 09:44:26.527 [I] http server Running on http://:8080
2019/09/25 09:45:14.831 [D] 应用启动
2019/09/25 09:45:14.883 [I] http server Running on http://:8080
2019/09/25 09:46:11.373 [D] [main.go:23] 应用启动
2019/09/25 09:46:11.421 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:46:20.279 [D] 应用启动
2019/09/25 09:46:20.321 [I] http server Running on http://:8080
2019/09/25 09:46:36.286 [D] [main.go:23] 应用启动
2019/09/25 09:46:36.327 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:48:04.055 [D] [logger.go:70] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:48:04.058 [D] [main.go:23] 应用启动
2019/09/25 09:48:04.101 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:48:57.467 [D] [logger.go:68] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:48:57.472 [D] [main.go:23] 应用启动
2019/09/25 09:48:57.513 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:51:29.788 [D] [logger.go:68] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:51:29.790 [D] [main.go:24] 应用启动
2019/09/25 09:51:29.831 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:52:37.088 [D] [logger.go:72] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:52:37.091 [D] [main.go:24] 应用启动
2019/09/25 09:52:37.134 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:53:53.727 [D] [logger.go:74] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:53:53.730 [D] [main.go:24] 应用启动
2019/09/25 09:53:53.774 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:57:45.468 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:57:45.471 [D] [main.go:24] 应用启动
2019/09/25 09:57:45.518 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:58:34.957 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:58:34.961 [D] [main.go:24] 应用启动
2019/09/25 09:58:35.001 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:59:00.222 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:59:00.224 [D] [main.go:24] 应用启动
2019/09/25 09:59:00.267 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:59:21.718 [D] [logger.go:75] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:59:21.720 [D] [main.go:24] 应用启动
2019/09/25 09:59:21.763 [I] [app.go:215] http server Running on http://:8080
2019/09/25 09:59:51.099 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log"}
2019/09/25 09:59:51.102 [D] [main.go:24] 应用启动
2019/09/25 09:59:51.144 [I] [app.go:215] http server Running on http://:8080
2019/09/25 10:00:08.480 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log"}
2019/09/25 10:00:08.482 [D] [main.go:24] 应用启动
2019/09/25 10:00:08.529 [I] [app.go:215] http server Running on http://:8080
2019/09/25 10:00:24.442 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log"}
2019/09/25 10:00:24.444 [D] [main.go:24] 应用启动
2019/09/25 10:00:24.487 [I] [app.go:215] http server Running on http://:8080
2019/09/25 10:00:43.449 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}
2019/09/25 10:00:43.451 [D] [main.go:24] 应用启动
2019/09/25 10:00:43.491 [I] [app.go:215] http server Running on http://:8080
2019/09/25 10:01:06.019 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}
2019/09/25 10:01:06.021 [D] [main.go:23] 应用启动
2019/09/25 10:01:06.063 [I] [app.go:215] http server Running on http://:8080
2019/09/25 10:01:11.803 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}
2019/09/25 10:01:11.805 [D] [main.go:23] 应用启动
2019/09/25 10:01:11.849 [I] [app.go:215] http server Running on http://:8080
2019/09/25 10:01:12.837 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}
2019/09/25 10:01:12.838 [D] [main.go:23] 应用启动
2019/09/25 10:01:12.880 [I] [app.go:215] http server Running on http://:8080
2019/09/25 10:01:46.181 [D] [logger.go:76] log 配置:{"filename":"./log/ability.log","level":7}
2019/09/25 10:01:46.184 [D] [main.go:23] 应用启动
2019/09/25 10:01:46.231 [I] [app.go:215] http server Running on http://:8080
2019/11/22 14:41:25.960 [D] [main.go:17] 加载配置dev
2019/11/22 14:41:26.134 [D] [main.go:23] 应用启动
2019/11/22 14:41:26.191 [I] [app.go:215] http server Running on http://:8081
2019/11/22 14:41:37.001 [D] [middle.go:11] 执行中间件AuthToken
2019/11/22 14:41:37.001 [I] [base.go:39] ====>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:[f81da1ed-6c04-4f71-93fd-0bc58e154b43] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 14:41:37.001 [D] [auth.go:26] 运行cotrollers
2019/11/22 14:41:37.001 [I] [auth.go:12] log 打印
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}
2019/11/22 14:41:37.002 [I] [base.go:53] <====Send to client: RspBodyData: {"code":"","msg":"","data":null}
2019/11/22 14:42:51.461 [D] [middle.go:11] 执行中间件AuthToken
2019/11/22 14:42:51.461 [I] [base.go:39] ====>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:[03f7d5a9-78cf-4a2a-8b31-f0186d912527] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 14:42:51.461 [D] [auth.go:26] 运行cotrollers
2019/11/22 14:42:51.461 [I] [auth.go:12] log 打印
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}
2019/11/22 14:42:51.462 [I] [base.go:53] <====Send to client: RspBodyData: {"code":"","msg":"","data":null}
2019/11/22 14:43:44.834 [D] [main.go:17] 加载配置dev
2019/11/22 14:43:44.985 [D] [main.go:23] 应用启动
2019/11/22 14:43:45.066 [I] [app.go:215] http server Running on http://:8081
2019/11/22 14:43:50.079 [D] [main.go:17] 加载配置dev
2019/11/22 14:43:50.293 [D] [main.go:23] 应用启动
2019/11/22 14:43:50.353 [I] [app.go:215] http server Running on http://:8081
2019/11/22 14:47:39.742 [D] [main.go:17] 加载配置dev
2019/11/22 14:47:39.895 [D] [main.go:23] 应用启动
2019/11/22 14:47:39.974 [I] [app.go:215] http server Running on http://:8081
2019/11/22 14:48:35.534 [D] [main.go:17] 加载配置dev
2019/11/22 14:48:35.694 [D] [main.go:23] 应用启动
2019/11/22 14:48:35.740 [I] [app.go:215] http server Running on http://:8081
2019/11/22 14:49:47.158 [D] [main.go:17] 加载配置dev
2019/11/22 14:49:47.334 [D] [main.go:23] 应用启动
2019/11/22 14:49:47.384 [I] [app.go:215] http server Running on http://:8081
2019/11/22 14:50:06.917 [D] [main.go:17] 加载配置dev
2019/11/22 14:50:07.074 [D] [main.go:23] 应用启动
2019/11/22 14:50:07.123 [I] [app.go:215] http server Running on http://:8081
2019/11/22 14:50:08.866 [D] [main.go:17] 加载配置dev
2019/11/22 14:50:09.012 [D] [main.go:23] 应用启动
2019/11/22 14:50:09.060 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:00:38.764 [D] [main.go:17] 加载配置dev
2019/11/22 15:00:38.912 [D] [main.go:23] 应用启动
2019/11/22 15:00:39.016 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:00:43.438 [D] [main.go:17] 加载配置dev
2019/11/22 15:00:43.630 [D] [main.go:23] 应用启动
2019/11/22 15:00:43.680 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:01:38.946 [D] [main.go:17] 加载配置dev
2019/11/22 15:01:39.096 [D] [main.go:23] 应用启动
2019/11/22 15:01:39.143 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:02:17.069 [D] [main.go:17] 加载配置dev
2019/11/22 15:02:17.457 [D] [main.go:23] 应用启动
2019/11/22 15:02:17.509 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:03:36.700 [D] [main.go:17] 加载配置dev
2019/11/22 15:03:36.865 [D] [main.go:23] 应用启动
2019/11/22 15:03:36.912 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:03:51.792 [D] [main.go:17] 加载配置dev
2019/11/22 15:03:51.980 [D] [main.go:23] 应用启动
2019/11/22 15:03:52.031 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:04:49.305 [D] [main.go:17] 加载配置dev
2019/11/22 15:04:49.476 [D] [main.go:23] 应用启动
2019/11/22 15:04:49.531 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:05:37.282 [D] [main.go:17] 加载配置dev
2019/11/22 15:05:37.431 [D] [main.go:23] 应用启动
2019/11/22 15:05:37.498 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:05:38.493 [D] [main.go:17] 加载配置dev
2019/11/22 15:05:38.699 [D] [main.go:23] 应用启动
2019/11/22 15:05:38.747 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:45.490 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:45.697 [D] [main.go:23] 应用启动
2019/11/22 15:06:45.774 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:46.777 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:46.920 [D] [main.go:23] 应用启动
2019/11/22 15:06:46.970 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:47.948 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:48.085 [D] [main.go:23] 应用启动
2019/11/22 15:06:48.138 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:49.224 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:49.367 [D] [main.go:23] 应用启动
2019/11/22 15:06:49.451 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:51.306 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:51.472 [D] [main.go:23] 应用启动
2019/11/22 15:06:51.553 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:52.971 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:53.119 [D] [main.go:23] 应用启动
2019/11/22 15:06:53.207 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:57.659 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:57.825 [D] [main.go:23] 应用启动
2019/11/22 15:06:57.877 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:06:59.273 [D] [main.go:17] 加载配置dev
2019/11/22 15:06:59.445 [D] [main.go:23] 应用启动
2019/11/22 15:06:59.491 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:07:12.721 [D] [main.go:17] 加载配置dev
2019/11/22 15:07:12.933 [D] [main.go:23] 应用启动
2019/11/22 15:07:12.994 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:07:24.903 [D] [main.go:17] 加载配置dev
2019/11/22 15:07:25.054 [D] [main.go:23] 应用启动
2019/11/22 15:07:25.141 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:07:53.161 [D] [main.go:17] 加载配置dev
2019/11/22 15:07:53.318 [D] [main.go:23] 应用启动
2019/11/22 15:07:53.395 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:08:37.443 [D] [main.go:17] 加载配置dev
2019/11/22 15:08:37.639 [D] [main.go:23] 应用启动
2019/11/22 15:08:37.712 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:10:52.050 [D] [main.go:17] 加载配置dev
2019/11/22 15:10:52.302 [D] [main.go:23] 应用启动
2019/11/22 15:10:52.367 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:11:50.664 [D] [main.go:17] 加载配置dev
2019/11/22 15:11:50.815 [D] [main.go:23] 应用启动
2019/11/22 15:11:50.889 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:12:51.210 [D] [main.go:17] 加载配置dev
2019/11/22 15:12:51.837 [D] [main.go:23] 应用启动
2019/11/22 15:12:51.886 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:13:52.273 [D] [main.go:17] 加载配置dev
2019/11/22 15:13:52.560 [D] [main.go:23] 应用启动
2019/11/22 15:13:52.610 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:13:54.444 [D] [main.go:17] 加载配置dev
2019/11/22 15:13:54.595 [D] [main.go:23] 应用启动
2019/11/22 15:13:54.646 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:17:51.875 [D] [main.go:17] 加载配置dev
2019/11/22 15:17:52.122 [D] [main.go:23] 应用启动
2019/11/22 15:17:52.173 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:18:07.474 [D] [main.go:17] 加载配置dev
2019/11/22 15:18:07.744 [D] [main.go:23] 应用启动
2019/11/22 15:18:07.793 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:19:44.221 [D] [main.go:17] 加载配置dev
2019/11/22 15:19:44.669 [D] [main.go:23] 应用启动
2019/11/22 15:19:44.718 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:20:15.139 [D] [main.go:17] 加载配置dev
2019/11/22 15:20:15.330 [D] [main.go:23] 应用启动
2019/11/22 15:20:15.380 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:21:02.445 [D] [main.go:17] 加载配置dev
2019/11/22 15:21:02.827 [D] [main.go:23] 应用启动
2019/11/22 15:21:02.874 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:21:27.848 [D] [main.go:17] 加载配置dev
2019/11/22 15:21:28.250 [D] [main.go:23] 应用启动
2019/11/22 15:21:28.297 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:25:27.707 [D] [main.go:17] 加载配置dev
2019/11/22 15:25:28.041 [D] [main.go:23] 应用启动
2019/11/22 15:25:28.092 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:25:28.675 [D] [main.go:17] 加载配置dev
2019/11/22 15:25:28.835 [D] [main.go:23] 应用启动
2019/11/22 15:25:28.897 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:25:33.162 [D] [main.go:17] 加载配置dev
2019/11/22 15:25:33.356 [D] [main.go:23] 应用启动
2019/11/22 15:25:33.416 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:25:43.894 [D] [main.go:17] 加载配置dev
2019/11/22 15:25:44.034 [D] [main.go:23] 应用启动
2019/11/22 15:25:44.083 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:25:57.701 [D] [main.go:17] 加载配置dev
2019/11/22 15:25:59.257 [D] [main.go:23] 应用启动
2019/11/22 15:25:59.322 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:33:17.823 [D] [main.go:17] 加载配置dev
2019/11/22 15:33:19.387 [D] [main.go:23] 应用启动
2019/11/22 15:33:19.439 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:33:34.216 [D] [main.go:17] 加载配置dev
2019/11/22 15:33:35.405 [D] [main.go:23] 应用启动
2019/11/22 15:33:35.466 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:34:43.958 [D] [main.go:17] 加载配置dev
2019/11/22 15:34:45.033 [D] [main.go:23] 应用启动
2019/11/22 15:34:45.124 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:36:16.254 [D] [main.go:17] 加载配置dev
2019/11/22 15:36:17.502 [D] [main.go:23] 应用启动
2019/11/22 15:36:17.555 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:42:01.353 [D] [main.go:17] 加载配置dev
2019/11/22 15:42:01.585 [D] [main.go:23] 应用启动
2019/11/22 15:42:01.645 [I] [app.go:215] http server Running on http://:8081
2019/11/22 15:42:40.558 [D] [main.go:17] 加载配置dev
2019/11/22 15:42:40.761 [D] [main.go:23] 应用启动
2019/11/22 15:42:40.810 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:01:37.148 [D] [main.go:17] 加载配置dev
2019/11/22 16:01:37.299 [D] [main.go:23] 应用启动
2019/11/22 16:01:37.364 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:03:15.644 [D] [main.go:17] 加载配置dev
2019/11/22 16:03:16.120 [D] [main.go:23] 应用启动
2019/11/22 16:03:16.265 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:04:33.623 [D] [main.go:17] 加载配置dev
2019/11/22 16:04:33.892 [D] [main.go:23] 应用启动
2019/11/22 16:04:33.942 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:05:31.493 [D] [main.go:17] 加载配置dev
2019/11/22 16:05:31.636 [D] [main.go:23] 应用启动
2019/11/22 16:05:31.711 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:07:08.172 [D] [main.go:17] 加载配置dev
2019/11/22 16:07:08.446 [D] [main.go:23] 应用启动
2019/11/22 16:07:08.500 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:07:28.868 [D] [main.go:17] 加载配置dev
2019/11/22 16:07:29.281 [D] [main.go:23] 应用启动
2019/11/22 16:07:29.347 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:07:32.558 [D] [middle.go:41] 执行中间件AuthToken
2019/11/22 16:07:32.559 [I] [base.go:31] ====>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:[8dcc67e1-0292-4658-96df-a96ee77a1635] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 16:07:32.559 [D] [auth.go:26] 运行cotrollers
2019/11/22 16:07:32.559 [I] [auth.go:12] log 打印
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}
2019/11/22 16:07:32.559 [I] [base.go:56] <====Send to client: RspBodyData: {"code":"","msg":"","data":null}
2019/11/22 16:07:58.280 [D] [main.go:17] 加载配置dev
2019/11/22 16:07:58.749 [D] [main.go:23] 应用启动
2019/11/22 16:07:58.799 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:08:02.218 [D] [middle.go:41] 执行中间件AuthToken
2019/11/22 16:08:02.218 [E] [middle.go:32] ====>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:[3f39d7af-2850-41d9-a708-0d2054cbcd0f] User-Agent:[PostmanRuntime/7.20.1]]
2019/11/22 16:08:36.273 [D] 加载配置prod
2019/11/22 16:08:37.610 [D] 应用启动
2019/11/22 16:08:37.700 [I] http server Running on http://:8080
2019/11/22 16:09:20.974 [D] 执行中间件AuthToken
2019/11/22 16:09:20.974 [E] ====>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:[9e148ff8-775f-40e3-b2a3-bf7de819d250] User-Agent:[PostmanRuntime/7.20.1]]
2019/11/22 16:10:24.026 [D] 加载配置prod
2019/11/22 16:17:48.486 [D] [main.go:17] 加载配置dev
2019/11/22 16:17:48.827 [D] [main.go:23] 应用启动
2019/11/22 16:17:48.877 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:17:57.265 [I] [middle.go:15] ====>Recv Request:%!(EXTRA func() string=0x8da2e0)
2019/11/22 16:17:57.265 [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:[6b9f73aa-bb5f-470d-aef8-9dc4007e856e] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 16:17:57.265 [D] [middle.go:51] 执行中间件AuthToken
2019/11/22 16:17:57.265 [E] [middle.go:42] ===>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:[6b9f73aa-bb5f-470d-aef8-9dc4007e856e] User-Agent:[PostmanRuntime/7.20.1]]
2019/11/22 16:18:22.449 [D] [main.go:17] 加载配置dev
2019/11/22 16:18:23.704 [D] [main.go:23] 应用启动
2019/11/22 16:18:23.785 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:18:30.882 [D] [main.go:17] 加载配置dev
2019/11/22 16:18:31.034 [D] [main.go:23] 应用启动
2019/11/22 16:18:31.083 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:18:34.022 [I] [middle.go:15] ====>Recv Request:%!s(func() string=0x8da230)
2019/11/22 16:18:34.022 [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:[7a5a07e4-0613-40da-be0e-ce1e4292f596] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 16:18:34.022 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:18:53.959 [D] [main.go:17] 加载配置dev
2019/11/22 16:18:55.133 [D] [main.go:23] 应用启动
2019/11/22 16:18:55.208 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:18:57.320 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:18:57.320 [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:[a2dc6549-d2bf-473a-8e15-1bdaaee1f4ce] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 16:18:57.320 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:20:04.808 [D] [main.go:17] 加载配置dev
2019/11/22 16:20:05.380 [D] [main.go:23] 应用启动
2019/11/22 16:20:05.430 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:20:07.999 [D] [main.go:17] 加载配置dev
2019/11/22 16:20:08.533 [D] [main.go:23] 应用启动
2019/11/22 16:20:08.639 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:20:12.534 [D] [main.go:17] 加载配置dev
2019/11/22 16:20:12.799 [D] [main.go:23] 应用启动
2019/11/22 16:20:12.860 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:20:15.158 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:20:15.158 [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:[a2ee5689-f082-4a72-b954-ce5f0ac80580] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 16:20:15.158 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:22:48.479 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:22:48.479 [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:[f1868394-7b9b-41ce-8924-b7273a57590b] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 16:22:48.479 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:24:15.594 [D] [main.go:17] 加载配置dev
2019/11/22 16:24:15.841 [D] [main.go:23] 应用启动
2019/11/22 16:24:15.891 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:24:18.455 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:24:18.455 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:25:52.592 [D] [main.go:17] 加载配置dev
2019/11/22 16:25:52.934 [D] [main.go:23] 应用启动
2019/11/22 16:25:52.982 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:26:02.004 [D] [main.go:17] 加载配置dev
2019/11/22 16:26:02.559 [D] [main.go:23] 应用启动
2019/11/22 16:26:02.646 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:26:05.922 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
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: {
}
2019/11/22 16:26:05.922 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:26:29.022 [D] [main.go:17] 加载配置dev
2019/11/22 16:26:30.724 [D] [main.go:23] 应用启动
2019/11/22 16:26:30.809 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:26:34.724 [D] [main.go:17] 加载配置dev
2019/11/22 16:26:34.879 [D] [main.go:23] 应用启动
2019/11/22 16:26:34.941 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:26:40.470 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:26:40.470 [I] [middle.go:17] ====>Recv data from client:BodyData: {
}
2019/11/22 16:26:40.470 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:27:46.044 [D] [main.go:17] 加载配置dev
2019/11/22 16:27:46.215 [D] [main.go:23] 应用启动
2019/11/22 16:27:46.263 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:27:48.767 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
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]]
2019/11/22 16:27:48.767 [D] [middle.go:50] 执行中间件AuthToken
2019/11/22 16:28:07.472 [D] [main.go:17] 加载配置dev
2019/11/22 16:28:07.856 [D] [main.go:23] 应用启动
2019/11/22 16:28:07.909 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:28:12.794 [D] [main.go:17] 加载配置dev
2019/11/22 16:28:14.424 [D] [main.go:23] 应用启动
2019/11/22 16:28:14.484 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:28:15.761 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:28:15.761 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
2019/11/22 16:28:15.761 [D] [middle.go:50] 执行中间件AuthToken
2019/11/22 16:28:30.463 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:28:30.463 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
2019/11/22 16:28:30.463 [D] [middle.go:50] 执行中间件AuthToken
2019/11/22 16:29:11.856 [D] [main.go:17] 加载配置dev
2019/11/22 16:29:12.463 [D] [main.go:23] 应用启动
2019/11/22 16:29:12.517 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:29:15.066 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:29:15.066 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
2019/11/22 16:29:15.066 [D] [middle.go:50] 执行中间件AuthToken
2019/11/22 16:29:44.861 [D] [main.go:17] 加载配置dev
2019/11/22 16:29:45.137 [D] [main.go:23] 应用启动
2019/11/22 16:29:45.204 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:29:47.213 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:29:47.213 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
2019/11/22 16:29:47.213 [D] [middle.go:50] 执行中间件AuthToken
2019/11/22 16:33:05.350 [D] [main.go:17] 加载配置dev
2019/11/22 16:33:05.764 [D] [main.go:23] 应用启动
2019/11/22 16:33:05.825 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:33:06.599 [D] [main.go:17] 加载配置dev
2019/11/22 16:33:06.746 [D] [main.go:23] 应用启动
2019/11/22 16:33:06.818 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:33:07.875 [D] [main.go:17] 加载配置dev
2019/11/22 16:33:08.335 [D] [main.go:23] 应用启动
2019/11/22 16:33:08.384 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:33:09.094 [D] [main.go:17] 加载配置dev
2019/11/22 16:33:09.271 [D] [main.go:23] 应用启动
2019/11/22 16:33:09.317 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:33:12.363 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:33:12.363 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
2019/11/22 16:33:12.363 [D] [middle.go:50] 执行中间件AuthToken
2019/11/22 16:33:28.517 [D] [main.go:17] 加载配置dev
2019/11/22 16:33:28.799 [D] [main.go:23] 应用启动
2019/11/22 16:33:28.847 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:33:33.961 [D] [main.go:17] 加载配置dev
2019/11/22 16:33:34.183 [D] [main.go:23] 应用启动
2019/11/22 16:33:34.239 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:33:37.783 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:33:37.784 [I] [middle.go:16] ====>Recv Request:/auth/accessToken
2019/11/22 16:33:37.785 [D] [middle.go:50] 执行中间件AuthToken
2019/11/22 16:33:54.888 [D] [main.go:17] 加载配置dev
2019/11/22 16:33:55.214 [D] [main.go:23] 应用启动
2019/11/22 16:33:55.264 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:34:14.502 [D] [main.go:17] 加载配置dev
2019/11/22 16:34:16.075 [D] [main.go:23] 应用启动
2019/11/22 16:34:16.136 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:34:16.399 [D] [main.go:17] 加载配置dev
2019/11/22 16:34:16.779 [D] [main.go:23] 应用启动
2019/11/22 16:34:16.847 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:34:20.114 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
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: {
}
2019/11/22 16:34:20.115 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:34:43.123 [D] [main.go:17] 加载配置dev
2019/11/22 16:34:44.647 [D] [main.go:23] 应用启动
2019/11/22 16:34:44.790 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:34:46.920 [D] [main.go:17] 加载配置dev
2019/11/22 16:34:47.313 [D] [main.go:23] 应用启动
2019/11/22 16:34:47.375 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:34:49.202 [D] [main.go:17] 加载配置dev
2019/11/22 16:34:49.866 [D] [main.go:23] 应用启动
2019/11/22 16:34:49.939 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:34:50.446 [I] [middle.go:15] ====>Recv Request:/auth/accessToken
2019/11/22 16:34:50.446 [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:[3314f1ce-4ee8-493a-b815-d28c546ccc94] User-Agent:[PostmanRuntime/7.20.1]]
BodyData: {
}
2019/11/22 16:34:50.450 [D] [middle.go:49] 执行中间件AuthToken
2019/11/22 16:35:38.163 [D] [main.go:17] 加载配置dev
2019/11/22 16:35:39.383 [D] [main.go:23] 应用启动
2019/11/22 16:35:39.459 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:36:21.655 [D] [main.go:17] 加载配置dev
2019/11/22 16:36:21.908 [D] [main.go:23] 应用启动
2019/11/22 16:36:21.966 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:36:51.234 [D] [main.go:17] 加载配置dev
2019/11/22 16:36:52.377 [D] [main.go:23] 应用启动
2019/11/22 16:36:52.472 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:39:03.039 [D] [main.go:17] 加载配置dev
2019/11/22 16:39:03.240 [D] [main.go:23] 应用启动
2019/11/22 16:39:03.325 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:40:02.095 [D] [main.go:17] 加载配置dev
2019/11/22 16:40:02.338 [D] [main.go:23] 应用启动
2019/11/22 16:40:02.387 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:41:44.495 [D] [main.go:17] 加载配置dev
2019/11/22 16:41:44.690 [D] [main.go:23] 应用启动
2019/11/22 16:41:44.743 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:42:11.583 [D] [main.go:17] 加载配置dev
2019/11/22 16:42:15.632 [D] [main.go:23] 应用启动
2019/11/22 16:42:15.716 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:42:27.003 [D] [main.go:17] 加载配置dev
2019/11/22 16:42:34.425 [D] [main.go:23] 应用启动
2019/11/22 16:42:34.496 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:44:05.564 [D] [main.go:17] 加载配置dev
2019/11/22 16:44:06.329 [D] [main.go:23] 应用启动
2019/11/22 16:44:06.394 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:44:06.785 [D] [main.go:17] 加载配置dev
2019/11/22 16:44:09.953 [D] [main.go:23] 应用启动
2019/11/22 16:44:10.002 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:44:42.074 [D] [main.go:17] 加载配置dev
2019/11/22 16:44:42.553 [D] [main.go:23] 应用启动
2019/11/22 16:44:42.601 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:45:31.567 [D] [main.go:17] 加载配置dev
2019/11/22 16:45:31.958 [D] [main.go:23] 应用启动
2019/11/22 16:45:32.030 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:45:40.362 [D] [main.go:17] 加载配置dev
2019/11/22 16:45:40.787 [D] [main.go:23] 应用启动
2019/11/22 16:45:40.844 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:45:41.592 [D] [main.go:17] 加载配置dev
2019/11/22 16:45:42.761 [D] [main.go:17] 加载配置dev
2019/11/22 16:45:42.926 [D] [main.go:23] 应用启动
2019/11/22 16:45:42.983 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:46:19.031 [D] [main.go:17] 加载配置dev
2019/11/22 16:46:20.204 [D] [main.go:23] 应用启动
2019/11/22 16:46:20.253 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:46:21.293 [D] [main.go:17] 加载配置dev
2019/11/22 16:46:21.475 [D] [main.go:23] 应用启动
2019/11/22 16:46:21.537 [I] [app.go:215] http server Running on http://:8081
2019/11/22 16:53:02.075 [D] [main.go:17] 加载配置dev
2019/11/22 16:53:02.311 [D] [main.go:23] 应用启动
2019/11/22 16:53:02.360 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:01:12.630 [D] [main.go:17] 加载配置dev
2019/11/22 17:01:17.016 [D] [main.go:23] 应用启动
2019/11/22 17:01:17.094 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:07:05.719 [D] [main.go:17] 加载配置dev
2019/11/22 17:07:06.016 [D] [main.go:23] 应用启动
2019/11/22 17:07:06.083 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:07:07.864 [D] [main.go:17] 加载配置dev
2019/11/22 17:07:08.315 [D] [main.go:23] 应用启动
2019/11/22 17:07:08.364 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:07:09.026 [D] [main.go:17] 加载配置dev
2019/11/22 17:07:09.199 [D] [main.go:23] 应用启动
2019/11/22 17:07:09.253 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:07:10.263 [D] [main.go:17] 加载配置dev
2019/11/22 17:07:10.906 [D] [main.go:23] 应用启动
2019/11/22 17:07:10.956 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:07:11.507 [D] [main.go:17] 加载配置dev
2019/11/22 17:07:11.748 [D] [main.go:23] 应用启动
2019/11/22 17:07:11.796 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:08:05.253 [D] [main.go:17] 加载配置dev
2019/11/22 17:08:05.549 [D] [main.go:23] 应用启动
2019/11/22 17:08:05.598 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:08:53.302 [D] [main.go:17] 加载配置dev
2019/11/22 17:08:53.644 [D] [main.go:23] 应用启动
2019/11/22 17:08:53.697 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:08:54.475 [D] [main.go:17] 加载配置dev
2019/11/22 17:08:54.638 [D] [main.go:23] 应用启动
2019/11/22 17:08:54.684 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:10:36.292 [D] [main.go:17] 加载配置dev
2019/11/22 17:10:36.459 [D] [main.go:23] 应用启动
2019/11/22 17:10:36.514 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:10:37.473 [D] [main.go:17] 加载配置dev
2019/11/22 17:10:37.612 [D] [main.go:23] 应用启动
2019/11/22 17:10:37.668 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:11:05.972 [D] [main.go:17] 加载配置dev
2019/11/22 17:11:06.182 [D] [main.go:23] 应用启动
2019/11/22 17:11:06.233 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:11:22.643 [D] [main.go:17] 加载配置dev
2019/11/22 17:11:22.806 [D] [main.go:23] 应用启动
2019/11/22 17:11:22.887 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:11:55.021 [D] [main.go:17] 加载配置dev
2019/11/22 17:11:57.751 [D] [main.go:23] 应用启动
2019/11/22 17:11:57.840 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:12:04.495 [D] [main.go:17] 加载配置dev
2019/11/22 17:12:04.720 [D] [main.go:23] 应用启动
2019/11/22 17:12:04.769 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:12:15.633 [D] [main.go:17] 加载配置dev
2019/11/22 17:12:16.816 [D] [main.go:23] 应用启动
2019/11/22 17:12:16.900 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:12:20.133 [D] [main.go:17] 加载配置dev
2019/11/22 17:12:20.708 [D] [main.go:23] 应用启动
2019/11/22 17:12:20.784 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:12:28.142 [D] [main.go:17] 加载配置dev
2019/11/22 17:12:28.324 [D] [main.go:23] 应用启动
2019/11/22 17:12:28.372 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:26:08.700 [D] [main.go:17] 加载配置dev
2019/11/22 17:26:08.880 [D] [main.go:23] 应用启动
2019/11/22 17:26:08.964 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:26:09.874 [D] [main.go:17] 加载配置dev
2019/11/22 17:26:10.020 [D] [main.go:23] 应用启动
2019/11/22 17:26:10.077 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:26:52.546 [D] [main.go:17] 加载配置dev
2019/11/22 17:26:54.619 [D] [main.go:23] 应用启动
2019/11/22 17:26:54.671 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:28:46.538 [D] [main.go:17] 加载配置dev
2019/11/22 17:28:46.676 [D] [main.go:23] 应用启动
2019/11/22 17:28:46.724 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:32:04.147 [D] [main.go:17] 加载配置dev
2019/11/22 17:32:04.721 [D] [main.go:23] 应用启动
2019/11/22 17:32:04.781 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:33:01.166 [D] [main.go:17] 加载配置dev
2019/11/22 17:33:02.550 [D] [main.go:23] 应用启动
2019/11/22 17:33:02.635 [I] [app.go:215] http server Running on http://:8081
2019/11/22 17:35:42.989 [D] [main.go:17] 加载配置dev
2019/11/22 17:35:43.144 [D] [main.go:23] 应用启动
2019/11/22 17:35:43.201 [I] [app.go:215] http server Running on http://:8081
... ...
package middleware
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"oppmg/common/log"
"oppmg/protocol"
"strings"
"github.com/astaxie/beego/context"
)
//AuthToken ...
//LogRequestData Before Router
var LogRequestData = func(ctx *context.Context) {
log.Info("====>Recv Request:%s", ctx.Input.URI())
if ctx.Input.RequestBody != nil {
log.Info("====>Recv data from client:\nHeadData: %s \nBodyData: %s", ctx.Request.Header, string(ctx.Input.RequestBody))
} else {
log.Info("====>Recv data from client:\nHeadData: %s ", ctx.Request.Header)
}
}
//CheckSign Before Router
var CheckSign = func(ctx *context.Context) {
var (
headTimeStamp string
headUuid string
headAccessToken string
headSign string
signHex string
)
headTimeStamp = ctx.Input.Header(protocol.HeaderTimestamp)
headUuid = ctx.Input.Header(protocol.HeaderUUID)
headSign = ctx.Input.Header(protocol.HeaderSign)
setsign := fmt.Sprintf("v!(MmM%v%v%vMmM)i^", headTimeStamp, headUuid, headAccessToken)
sha256 := sha256.New()
sha256.Write([]byte(setsign))
signHex = hex.EncodeToString(sha256.Sum(nil))
if strings.Compare(signHex, headSign) != 0 {
msg := protocol.BadRequestParam("113")
ctx.Output.JSON(msg, false, false)
return
}
return
}
//AuthToken Before Router
var AuthToken = func(ctx *context.Context) {
log.Debug("执行中间件AuthToken")
ctx.Output.Body([]byte("{}"))
// ctx.Output.Body([]byte("{}"))
return
}
... ...
package models
import (
"fmt"
"time"
"github.com/astaxie/beego/orm"
)
type Company struct {
Id int `orm:"column(id);auto"`
Name string `orm:"column(name);size(40)"`
UserId int `orm:"column(user_id)"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)"`
DeleteAt time.Time `orm:"column(delete_at);type(timestamp)"`
Logo string `orm:"column(logo);size(255)"`
}
func (t *Company) TableName() string {
return "company"
}
func init() {
orm.RegisterModel(new(Company))
}
// AddCompany insert a new Company into database and returns
// last inserted Id on success.
func AddCompany(m *Company) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetCompanyById retrieves Company by Id. Returns error if
// Id doesn't exist
func GetCompanyById(id int) (v *Company, err error) {
o := orm.NewOrm()
v = &Company{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// UpdateCompany updates Company by Id and returns error if
// the record to be updated doesn't exist
func UpdateCompanyById(m *Company) (err error) {
o := orm.NewOrm()
v := Company{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
}
}
return
}
// DeleteCompany deletes Company by Id and returns error if
// the record to be deleted doesn't exist
func DeleteCompany(id int) (err error) {
o := orm.NewOrm()
v := Company{Id: id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&Company{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
}
}
return
}
... ...
... ... @@ -5,49 +5,57 @@ import (
"fmt"
"reflect"
"strings"
"time"
"github.com/astaxie/beego/orm"
)
type Permission struct {
Id int `orm:"column(id);pk"`
Name string `orm:"column(name);size(30)"`
Pid int `orm:"column(pid);null"`
type Department struct {
Id int `orm:"column(id);auto"`
CompanyId int `orm:"column(company_id)" description:"公司id"`
Name string `orm:"column(name);size(30)" description:"部门名称"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)" description:"创建时间"`
ParentId int `orm:"column(parent_id)" description:"父级id"`
Relation string `orm:"column(relation);size(1024)" description:"父子级关系树"`
DeleteAt time.Time `orm:"column(delete_at);type(timestamp)" description:"删除时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
Member int `orm:"column(member)" description:"成员数量"`
Admin int `orm:"column(admin);null" description:"部门负责人id"`
}
func (t *Permission) TableName() string {
return "permission"
func (t *Department) TableName() string {
return "department"
}
func init() {
orm.RegisterModel(new(Permission))
orm.RegisterModel(new(Department))
}
// AddPermission insert a new Permission into database and returns
// AddDepartment insert a new Department into database and returns
// last inserted Id on success.
func AddPermission(m *Permission) (id int64, err error) {
func AddDepartment(m *Department) (id int64, err error) {
o := orm.NewOrm()
id, err = o.Insert(m)
return
}
// GetPermissionById retrieves Permission by Id. Returns error if
// GetDepartmentById retrieves Department by Id. Returns error if
// Id doesn't exist
func GetPermissionById(id int) (v *Permission, err error) {
func GetDepartmentById(id int) (v *Department, err error) {
o := orm.NewOrm()
v = &Permission{Id: id}
v = &Department{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
// GetAllPermission retrieves all Permission matches certain condition. Returns empty list if
// GetAllDepartment retrieves all Department matches certain condition. Returns empty list if
// no records exist
func GetAllPermission(query map[string]string, fields []string, sortby []string, order []string,
func GetAllDepartment(query map[string]string, fields []string, sortby []string, order []string,
offset int64, limit int64) (ml []interface{}, err error) {
o := orm.NewOrm()
qs := o.QueryTable(new(Permission))
qs := o.QueryTable(new(Department))
// query k=v
for k, v := range query {
// rewrite dot-notation to Object__Attribute
... ... @@ -97,7 +105,7 @@ func GetAllPermission(query map[string]string, fields []string, sortby []string,
}
}
var l []Permission
var l []Department
qs = qs.OrderBy(sortFields...)
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
... ... @@ -120,11 +128,11 @@ func GetAllPermission(query map[string]string, fields []string, sortby []string,
return nil, err
}
// UpdatePermission updates Permission by Id and returns error if
// UpdateDepartment updates Department by Id and returns error if
// the record to be updated doesn't exist
func UpdatePermissionById(m *Permission) (err error) {
func UpdateDepartmentById(m *Department) (err error) {
o := orm.NewOrm()
v := Permission{Id: m.Id}
v := Department{Id: m.Id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
... ... @@ -135,15 +143,15 @@ func UpdatePermissionById(m *Permission) (err error) {
return
}
// DeletePermission deletes Permission by Id and returns error if
// DeleteDepartment deletes Department by Id and returns error if
// the record to be deleted doesn't exist
func DeletePermission(id int) (err error) {
func DeleteDepartment(id int) (err error) {
o := orm.NewOrm()
v := Permission{Id: id}
v := Department{Id: id}
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&Permission{Id: id}); err == nil {
if num, err = o.Delete(&Department{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
}
}
... ...
package models
import (
"errors"
"fmt"
"reflect"
"strings"
"oppmg/common/log"
"time"
"github.com/astaxie/beego/orm"
... ... @@ -14,8 +11,9 @@ type Role struct {
Id int `orm:"column(id);auto"`
Name string `orm:"column(name);size(30)"`
CompanyId int `orm:"column(company_id)"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now"`
DeleteAt time.Time `orm:"column(delete_at);type(timestamp);null"`
Descript string `orm:"column(descript)"`
CreateAt time.Time `orm:"column(create_at);type(timestamp)"`
DeleteAt time.Time `orm:"column(delete_at);type(timestamp)"`
}
func (t *Role) TableName() string {
... ... @@ -45,84 +43,6 @@ func GetRoleById(id int) (v *Role, err error) {
return nil, err
}
// GetAllRole retrieves all Role matches certain condition. Returns empty list if
// no records exist
func GetAllRole(query map[string]string, fields []string, sortby []string, order []string,
offset int64, limit int64) (ml []interface{}, err error) {
o := orm.NewOrm()
qs := o.QueryTable(new(Role))
// query k=v
for k, v := range query {
// rewrite dot-notation to Object__Attribute
k = strings.Replace(k, ".", "__", -1)
if strings.Contains(k, "isnull") {
qs = qs.Filter(k, (v == "true" || v == "1"))
} else {
qs = qs.Filter(k, v)
}
}
// order by:
var sortFields []string
if len(sortby) != 0 {
if len(sortby) == len(order) {
// 1) for each sort field, there is an associated order
for i, v := range sortby {
orderby := ""
if order[i] == "desc" {
orderby = "-" + v
} else if order[i] == "asc" {
orderby = v
} else {
return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")
}
sortFields = append(sortFields, orderby)
}
qs = qs.OrderBy(sortFields...)
} else if len(sortby) != len(order) && len(order) == 1 {
// 2) there is exactly one order, all the sorted fields will be sorted by this order
for _, v := range sortby {
orderby := ""
if order[0] == "desc" {
orderby = "-" + v
} else if order[0] == "asc" {
orderby = v
} else {
return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")
}
sortFields = append(sortFields, orderby)
}
} else if len(sortby) != len(order) && len(order) != 1 {
return nil, errors.New("Error: 'sortby', 'order' sizes mismatch or 'order' size is not 1")
}
} else {
if len(order) != 0 {
return nil, errors.New("Error: unused 'order' fields")
}
}
var l []Role
qs = qs.OrderBy(sortFields...)
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
for _, v := range l {
ml = append(ml, v)
}
} else {
// trim unused fields
for _, v := range l {
m := make(map[string]interface{})
val := reflect.ValueOf(v)
for _, fname := range fields {
m[fname] = val.FieldByName(fname).Interface()
}
ml = append(ml, m)
}
}
return ml, nil
}
return nil, err
}
// UpdateRole updates Role by Id and returns error if
// the record to be updated doesn't exist
func UpdateRoleById(m *Role) (err error) {
... ... @@ -132,7 +52,7 @@ func UpdateRoleById(m *Role) (err error) {
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Update(m); err == nil {
fmt.Println("Number of records updated in database:", num)
log.Debug("Number of records updated in database:%d", num)
}
}
return
... ... @@ -146,8 +66,9 @@ func DeleteRole(id int) (err error) {
// ascertain id exists in the database
if err = o.Read(&v); err == nil {
var num int64
if num, err = o.Delete(&Role{Id: id}); err == nil {
fmt.Println("Number of records deleted in database:", num)
v.DeleteAt = time.Now()
if num, err = o.Update(&v); err == nil {
log.Debug("Number of records deleted in database:%d", num)
}
}
return
... ...
package models
import (
"errors"
"fmt"
"reflect"
"strings"
"time"
"github.com/astaxie/beego/orm"
... ... @@ -16,12 +13,6 @@ type User struct {
Phone string `orm:"column(phone);size(40)" description:"手机号码"`
Passwd string `orm:"column(passwd);size(128)" description:"密码"`
Icon string `orm:"column(icon);size(255)" description:"头像"`
CompanyId int `orm:"column(company_id)" description:"公司Id"`
DepartmentId int `orm:"column(department_id)" description:"部门id"`
PositionId int `orm:"column(position_id)" description:"职位id"`
CsAccount int64 `orm:"column(cs_account)" description:"客服有话说ID"`
IsKefu int8 `orm:"column(is_kefu)" description:"是否是客服 0:否 1:是"`
ImToken string `orm:"column(im_token);size(128)" description:"网易云token"`
LastLoginTime time.Time `orm:"column(last_login_time);type(timestamp)" description:"最后一次登录时间"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);auto_now_add" description:"创建时间"`
EnableStatus int8 `orm:"column(enable_status)" description:"是否有效"`
... ... @@ -54,84 +45,6 @@ func GetUserById(id int) (v *User, err error) {
return nil, err
}
// GetAllUser retrieves all User matches certain condition. Returns empty list if
// no records exist
func GetAllUser(query map[string]string, fields []string, sortby []string, order []string,
offset int64, limit int64) (ml []interface{}, err error) {
o := orm.NewOrm()
qs := o.QueryTable(new(User))
// query k=v
for k, v := range query {
// rewrite dot-notation to Object__Attribute
k = strings.Replace(k, ".", "__", -1)
if strings.Contains(k, "isnull") {
qs = qs.Filter(k, (v == "true" || v == "1"))
} else {
qs = qs.Filter(k, v)
}
}
// order by:
var sortFields []string
if len(sortby) != 0 {
if len(sortby) == len(order) {
// 1) for each sort field, there is an associated order
for i, v := range sortby {
orderby := ""
if order[i] == "desc" {
orderby = "-" + v
} else if order[i] == "asc" {
orderby = v
} else {
return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")
}
sortFields = append(sortFields, orderby)
}
qs = qs.OrderBy(sortFields...)
} else if len(sortby) != len(order) && len(order) == 1 {
// 2) there is exactly one order, all the sorted fields will be sorted by this order
for _, v := range sortby {
orderby := ""
if order[0] == "desc" {
orderby = "-" + v
} else if order[0] == "asc" {
orderby = v
} else {
return nil, errors.New("Error: Invalid order. Must be either [asc|desc]")
}
sortFields = append(sortFields, orderby)
}
} else if len(sortby) != len(order) && len(order) != 1 {
return nil, errors.New("Error: 'sortby', 'order' sizes mismatch or 'order' size is not 1")
}
} else {
if len(order) != 0 {
return nil, errors.New("Error: unused 'order' fields")
}
}
var l []User
qs = qs.OrderBy(sortFields...)
if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil {
if len(fields) == 0 {
for _, v := range l {
ml = append(ml, v)
}
} else {
// trim unused fields
for _, v := range l {
m := make(map[string]interface{})
val := reflect.ValueOf(v)
for _, fname := range fields {
m[fname] = val.FieldByName(fname).Interface()
}
ml = append(ml, m)
}
}
return ml, nil
}
return nil, err
}
// UpdateUser updates User by Id and returns error if
// the record to be updated doesn't exist
func UpdateUserById(m *User) (err error) {
... ...
package protocol
const (
HeaderAccessToken string = "x-mmm-accesstoken"
HeaderRefreshToken string = "x-mmm-refreshtoken"
HeaderUID string = "x-mmm-uid"
HeaderUUID string = "x-mmm-uuid"
HeaderTimestamp string = "x-mmm-timestamp"
HeaderDevicetype string = "x-mmm-devicetype"
HeaderAppproject string = "x-mmm-appproject"
HeaderSign string = "x-mmm-sign"
)
//BaseHeader 请求的header数据
//减少在具体业务方法中使用 this.Ctx.Input.Header("xxxx")
type BaseHeader struct {
AccessToken string
RefreshToken string
AppProject string
Devicetype string
Sign string
UUID string
Timestamp int
UID int
}
... ...
package protocol
//RequestRoleAdd 添加角色信息操作入参
type RequestRoleAdd struct {
CompanyID int `json:"company,omitempty"`
RoleName string `json:"role_name"`
Descript string `json:"descript"`
}
// func (r RequestRoleAdd) Valid() error {
// return nil
// }
type RequestRoleDelete struct {
CompanyID int `json:"company_id"`
RoleID int `json:"role_id"`
}
//RequestRoleEdit 编辑角色信息入参
type RequestRoleEdit struct {
RoleID int `json:"role_id"`
RoleName string `json:"role_name"`
CompanyID int `json:"company_id"`
Descript string `json:"descript"`
}
type RequestRolePermission struct {
CompanyID int `json:"company_id"`
RoleID int `json:"role_id"`
PermissionID []int `json:"permission_id"`
}
... ...
... ... @@ -9,11 +9,15 @@ import (
)
func init() {
nsV1 := beego.NewNamespace("v1",
beego.NSBefore(middleware.AuthToken),
)
nsAuth := beego.NewNamespace("/auth",
beego.NSBefore(middleware.AuthToken),
beego.NSBefore(middleware.LogRequestData, middleware.AuthToken),
beego.NSRouter("/accessToken", &controllers.AuthController{}, "post:AccessToken"),
)
beego.AddNamespace(nsV1)
beego.AddNamespace(nsAuth)
}
... ...
package rbac
import (
"fmt"
"oppmg/common/log"
"oppmg/models"
"oppmg/protocol"
"time"
)
func RoleAdd(param protocol.RequestRoleAdd) error {
role := models.Role{
CompanyId: param.CompanyID,
Name: param.RoleName,
CreateAt: time.Now(),
Descript: param.Descript,
}
_, err := models.AddRole(&role)
if err != nil {
log.Error("AddRole err:%s", err)
return protocol.NewErrWithMessage("1", err)
}
return nil
}
func RoleDelete(param protocol.RequestRoleDelete) error {
role, err := models.GetRoleById(param.RoleID)
if err != nil {
e := fmt.Errorf("GetRoleById err:%s", err)
log.Error(e.Error())
return protocol.NewErrWithMessage("1", e)
}
if role.CompanyId != param.CompanyID {
e := fmt.Errorf("role.CompanyId(%d) != param.CompanyID(%d)", role.CompanyId, param.CompanyID)
log.Error(e.Error())
return protocol.NewErrWithMessage("1", e)
}
if err := models.DeleteRole(param.RoleID); err != nil {
e := fmt.Errorf("DeleteRole err:%s", err)
log.Error(e.Error())
return protocol.NewErrWithMessage("1", e)
}
return nil
}
func RoleEdit(param protocol.RequestRoleEdit) error {
var (
role *models.Role
err error
)
role, err = models.GetRoleById(param.RoleID)
if err != nil {
e := fmt.Errorf("GetRoleById err:%s", err)
log.Error(e.Error())
return protocol.NewErrWithMessage("1", e)
}
if role.CompanyId != param.CompanyID {
e := fmt.Errorf("role.CompanyId(%d) != param.CompanyID(%d)", role.CompanyId, param.CompanyID)
log.Error(e.Error())
return protocol.NewErrWithMessage("1", e)
}
role.Descript = param.Descript
role.Name = param.RoleName
if err = models.UpdateRoleById(role); err != nil {
e := fmt.Errorf("UpdateRoleById err:%s", err)
log.Error(e.Error())
return protocol.NewErrWithMessage("1", e)
}
return nil
}
func RoleGetOne() error {
return nil
}
func RoleGetByPage() error {
return nil
}
... ...
package serveauth
import (
"oppmg/common/config"
"oppmg/common/log"
"oppmg/protocol"
)
func GetAccessToken(param protocol.RequestCheckSmsCode) (*protocol.DataUserInfo, error) {
data := &protocol.DataUserInfo{}
err := protocol.NewErrWithMessage("00000")
log.Info("log 打印")
log.Info("%+v", config.MConfig)
return data, err
}
... ...
package tests
... ...
package utils
... ...
package utils
import (
"github.com/sony/sonyflake"
)
var sf = sonyflake.NewSonyflake(sonyflake.Settings{})
func GetUniqueId() int64 {
num, _ := sf.NextID()
return int64(num)
}
... ...
package utils
import "time"
var localtime = time.FixedZone("UTC", 8*3600)
//LocalTimeZone 设定时区东八区
func LocalTimeZone() *time.Location {
return localtime
}
//LocalTime ....
func LocalTime() time.Time {
return new(time.Time).In(localtime)
}