正在显示
16 个修改的文件
包含
27 行增加
和
25 行删除
@@ -48,7 +48,7 @@ func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx | @@ -48,7 +48,7 @@ func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx | ||
48 | } | 48 | } |
49 | token, _ := common.GenerateToken(fmt.Sprintf("%v", user.Id), user.Passwd, common.WithExpire(domain.TokenExpire), common.WithAddData(map[string]interface{}{"UserName": user.Name})) | 49 | token, _ := common.GenerateToken(fmt.Sprintf("%v", user.Id), user.Passwd, common.WithExpire(domain.TokenExpire), common.WithAddData(map[string]interface{}{"UserName": user.Name})) |
50 | rsp.Access = map[string]interface{}{ | 50 | rsp.Access = map[string]interface{}{ |
51 | - "accessToken": "Bearer " + token, | 51 | + "accessToken": token, //"Bearer " + token, |
52 | "expiresIn": domain.TokenExpire, | 52 | "expiresIn": domain.TokenExpire, |
53 | } | 53 | } |
54 | 54 |
@@ -28,6 +28,7 @@ func (svr *CacheService) CacheUserAccess(userId int64) func() (interface{}, erro | @@ -28,6 +28,7 @@ func (svr *CacheService) CacheUserAccess(userId int64) func() (interface{}, erro | ||
28 | AccessRepository, _ = factory.CreateAccessRepository(transactionContext) | 28 | AccessRepository, _ = factory.CreateAccessRepository(transactionContext) |
29 | err error | 29 | err error |
30 | ) | 30 | ) |
31 | + transactionContext.SetTransactionClose() | ||
31 | if err = transactionContext.StartTransaction(); err != nil { | 32 | if err = transactionContext.StartTransaction(); err != nil { |
32 | log.Error(err) | 33 | log.Error(err) |
33 | return nil, err | 34 | return nil, err |
@@ -54,6 +55,7 @@ func (svr *CacheService) ValidUser(userId int64) (isAdmin bool, err error) { | @@ -54,6 +55,7 @@ func (svr *CacheService) ValidUser(userId int64) (isAdmin bool, err error) { | ||
54 | transactionContext, _ = factory.CreateTransactionContext(nil) | 55 | transactionContext, _ = factory.CreateTransactionContext(nil) |
55 | UserRepository, _ = factory.CreateUserRepository(transactionContext) | 56 | UserRepository, _ = factory.CreateUserRepository(transactionContext) |
56 | ) | 57 | ) |
58 | + transactionContext.SetTransactionClose() | ||
57 | if err = transactionContext.StartTransaction(); err != nil { | 59 | if err = transactionContext.StartTransaction(); err != nil { |
58 | log.Error(err) | 60 | log.Error(err) |
59 | return isAdmin, err | 61 | return isAdmin, err |
@@ -175,7 +175,7 @@ func (svr *RoleService) ListRole(header *protocol.RequestHeader, request *protoc | @@ -175,7 +175,7 @@ func (svr *RoleService) ListRole(header *protocol.RequestHeader, request *protoc | ||
175 | var RoleRepository, _ = factory.CreateRoleRepository(transactionContext) | 175 | var RoleRepository, _ = factory.CreateRoleRepository(transactionContext) |
176 | var role []*domain.Role | 176 | var role []*domain.Role |
177 | var total int64 | 177 | var total int64 |
178 | - if _, role, err = RoleRepository.Find(map[string]interface{}{"orderById": "DESC"}); err != nil { | 178 | + if total, role, err = RoleRepository.Find(map[string]interface{}{"orderById": "DESC"}); err != nil { |
179 | return | 179 | return |
180 | } | 180 | } |
181 | rsp = map[string]interface{}{ | 181 | rsp = map[string]interface{}{ |
@@ -47,7 +47,7 @@ func (repository *AccessRepository) Remove(Access *domain.Access) (*domain.Acces | @@ -47,7 +47,7 @@ func (repository *AccessRepository) Remove(Access *domain.Access) (*domain.Acces | ||
47 | } | 47 | } |
48 | 48 | ||
49 | func (repository *AccessRepository) FindOne(queryOptions map[string]interface{}) (*domain.Access, error) { | 49 | func (repository *AccessRepository) FindOne(queryOptions map[string]interface{}) (*domain.Access, error) { |
50 | - tx := repository.transactionContext.PgTx | 50 | + tx := repository.transactionContext.PgDd |
51 | AccessModel := new(models.Access) | 51 | AccessModel := new(models.Access) |
52 | query := NewQuery(tx.Model(AccessModel), queryOptions) | 52 | query := NewQuery(tx.Model(AccessModel), queryOptions) |
53 | query.SetWhere("id = ?", "id") | 53 | query.SetWhere("id = ?", "id") |
@@ -61,7 +61,7 @@ func (repository *AccessRepository) FindOne(queryOptions map[string]interface{}) | @@ -61,7 +61,7 @@ func (repository *AccessRepository) FindOne(queryOptions map[string]interface{}) | ||
61 | } | 61 | } |
62 | 62 | ||
63 | func (repository *AccessRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Access, error) { | 63 | func (repository *AccessRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Access, error) { |
64 | - tx := repository.transactionContext.PgTx | 64 | + tx := repository.transactionContext.PgDd |
65 | var AccessModels []*models.Access | 65 | var AccessModels []*models.Access |
66 | Accesss := make([]*domain.Access, 0) | 66 | Accesss := make([]*domain.Access, 0) |
67 | query := NewQuery(tx.Model(&AccessModels), queryOptions). | 67 | query := NewQuery(tx.Model(&AccessModels), queryOptions). |
@@ -46,7 +46,7 @@ func (repository *CasbinRuleRepository) Remove(CasbinRule *domain.CasbinRule) (* | @@ -46,7 +46,7 @@ func (repository *CasbinRuleRepository) Remove(CasbinRule *domain.CasbinRule) (* | ||
46 | } | 46 | } |
47 | 47 | ||
48 | func (repository *CasbinRuleRepository) FindOne(queryOptions map[string]interface{}) (*domain.CasbinRule, error) { | 48 | func (repository *CasbinRuleRepository) FindOne(queryOptions map[string]interface{}) (*domain.CasbinRule, error) { |
49 | - tx := repository.transactionContext.PgTx | 49 | + tx := repository.transactionContext.PgDd |
50 | CasbinRuleModel := new(models.CasbinRule) | 50 | CasbinRuleModel := new(models.CasbinRule) |
51 | query := NewQuery(tx.Model(CasbinRuleModel), queryOptions) | 51 | query := NewQuery(tx.Model(CasbinRuleModel), queryOptions) |
52 | query.SetWhere("id = ?", "id") | 52 | query.SetWhere("id = ?", "id") |
@@ -60,7 +60,7 @@ func (repository *CasbinRuleRepository) FindOne(queryOptions map[string]interfac | @@ -60,7 +60,7 @@ func (repository *CasbinRuleRepository) FindOne(queryOptions map[string]interfac | ||
60 | } | 60 | } |
61 | 61 | ||
62 | func (repository *CasbinRuleRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CasbinRule, error) { | 62 | func (repository *CasbinRuleRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CasbinRule, error) { |
63 | - tx := repository.transactionContext.PgTx | 63 | + tx := repository.transactionContext.PgDd |
64 | var CasbinRuleModels []*models.CasbinRule | 64 | var CasbinRuleModels []*models.CasbinRule |
65 | CasbinRules := make([]*domain.CasbinRule, 0) | 65 | CasbinRules := make([]*domain.CasbinRule, 0) |
66 | query := NewQuery(tx.Model(&CasbinRuleModels), queryOptions). | 66 | query := NewQuery(tx.Model(&CasbinRuleModels), queryOptions). |
@@ -90,7 +90,7 @@ func (repository *ClientVersionRepository) FindOne(queryOptions map[string]inter | @@ -90,7 +90,7 @@ func (repository *ClientVersionRepository) FindOne(queryOptions map[string]inter | ||
90 | } | 90 | } |
91 | 91 | ||
92 | func (repository *ClientVersionRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ClientVersion, error) { | 92 | func (repository *ClientVersionRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ClientVersion, error) { |
93 | - tx := repository.transactionContext.PgTx | 93 | + tx := repository.transactionContext.PgDd |
94 | var ClientVersionModels []*models.ClientVersion | 94 | var ClientVersionModels []*models.ClientVersion |
95 | ClientVersions := make([]*domain.ClientVersion, 0) | 95 | ClientVersions := make([]*domain.ClientVersion, 0) |
96 | query := NewQuery(tx.Model(&ClientVersionModels), queryOptions). | 96 | query := NewQuery(tx.Model(&ClientVersionModels), queryOptions). |
@@ -46,7 +46,7 @@ func (repository *MenuRepository) Remove(Menu *domain.Menu) (*domain.Menu, error | @@ -46,7 +46,7 @@ func (repository *MenuRepository) Remove(Menu *domain.Menu) (*domain.Menu, error | ||
46 | } | 46 | } |
47 | 47 | ||
48 | func (repository *MenuRepository) FindOne(queryOptions map[string]interface{}) (*domain.Menu, error) { | 48 | func (repository *MenuRepository) FindOne(queryOptions map[string]interface{}) (*domain.Menu, error) { |
49 | - tx := repository.transactionContext.PgTx | 49 | + tx := repository.transactionContext.PgDd |
50 | MenuModel := new(models.Menu) | 50 | MenuModel := new(models.Menu) |
51 | query := NewQuery(tx.Model(MenuModel), queryOptions) | 51 | query := NewQuery(tx.Model(MenuModel), queryOptions) |
52 | query.SetWhere("id = ?", "id") | 52 | query.SetWhere("id = ?", "id") |
@@ -60,7 +60,7 @@ func (repository *MenuRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -60,7 +60,7 @@ func (repository *MenuRepository) FindOne(queryOptions map[string]interface{}) ( | ||
60 | } | 60 | } |
61 | 61 | ||
62 | func (repository *MenuRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Menu, error) { | 62 | func (repository *MenuRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Menu, error) { |
63 | - tx := repository.transactionContext.PgTx | 63 | + tx := repository.transactionContext.PgDd |
64 | var MenuModels []*models.Menu | 64 | var MenuModels []*models.Menu |
65 | Menus := make([]*domain.Menu, 0) | 65 | Menus := make([]*domain.Menu, 0) |
66 | query := NewQuery(tx.Model(&MenuModels), queryOptions). | 66 | query := NewQuery(tx.Model(&MenuModels), queryOptions). |
@@ -89,7 +89,7 @@ func (repository *OperatorLogRepository) FindOne(queryOptions map[string]interfa | @@ -89,7 +89,7 @@ func (repository *OperatorLogRepository) FindOne(queryOptions map[string]interfa | ||
89 | } | 89 | } |
90 | 90 | ||
91 | func (repository *OperatorLogRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OperatorLog, error) { | 91 | func (repository *OperatorLogRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OperatorLog, error) { |
92 | - tx := repository.transactionContext.PgTx | 92 | + tx := repository.transactionContext.PgDd |
93 | var OperatorLogModels []*models.OperatorLog | 93 | var OperatorLogModels []*models.OperatorLog |
94 | OperatorLogs := make([]*domain.OperatorLog, 0) | 94 | OperatorLogs := make([]*domain.OperatorLog, 0) |
95 | query := NewQuery(tx.Model(&OperatorLogModels), queryOptions). | 95 | query := NewQuery(tx.Model(&OperatorLogModels), queryOptions). |
@@ -47,7 +47,7 @@ func (repository *ProjectModuleFilesRepository) Remove(ProjectModuleFiles *domai | @@ -47,7 +47,7 @@ func (repository *ProjectModuleFilesRepository) Remove(ProjectModuleFiles *domai | ||
47 | } | 47 | } |
48 | 48 | ||
49 | func (repository *ProjectModuleFilesRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModuleFiles, error) { | 49 | func (repository *ProjectModuleFilesRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModuleFiles, error) { |
50 | - tx := repository.transactionContext.PgTx | 50 | + tx := repository.transactionContext.PgDd |
51 | ProjectModuleFilesModel := new(models.ProjectModuleFiles) | 51 | ProjectModuleFilesModel := new(models.ProjectModuleFiles) |
52 | query := NewQuery(tx.Model(ProjectModuleFilesModel), queryOptions) | 52 | query := NewQuery(tx.Model(ProjectModuleFilesModel), queryOptions) |
53 | query.SetWhere("id = ?", "id") | 53 | query.SetWhere("id = ?", "id") |
@@ -66,7 +66,7 @@ func (repository *ProjectModuleFilesRepository) FindOne(queryOptions map[string] | @@ -66,7 +66,7 @@ func (repository *ProjectModuleFilesRepository) FindOne(queryOptions map[string] | ||
66 | } | 66 | } |
67 | 67 | ||
68 | func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ProjectModuleFiles, error) { | 68 | func (repository *ProjectModuleFilesRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ProjectModuleFiles, error) { |
69 | - tx := repository.transactionContext.PgTx | 69 | + tx := repository.transactionContext.PgDd |
70 | var ProjectModuleFilesModels []*models.ProjectModuleFiles | 70 | var ProjectModuleFilesModels []*models.ProjectModuleFiles |
71 | ProjectModuleFiless := make([]*domain.ProjectModuleFiles, 0) | 71 | ProjectModuleFiless := make([]*domain.ProjectModuleFiles, 0) |
72 | query := NewQuery(tx.Model(&ProjectModuleFilesModels), queryOptions). | 72 | query := NewQuery(tx.Model(&ProjectModuleFilesModels), queryOptions). |
@@ -48,7 +48,7 @@ func (repository *ProjectModuleRepository) Remove(ProjectModule *domain.ProjectM | @@ -48,7 +48,7 @@ func (repository *ProjectModuleRepository) Remove(ProjectModule *domain.ProjectM | ||
48 | } | 48 | } |
49 | 49 | ||
50 | func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModule, error) { | 50 | func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModule, error) { |
51 | - tx := repository.transactionContext.PgTx | 51 | + tx := repository.transactionContext.PgDd |
52 | ProjectModuleModel := new(models.ProjectModule) | 52 | ProjectModuleModel := new(models.ProjectModule) |
53 | query := NewQuery(tx.Model(ProjectModuleModel).Relation("ProjectModuleVersion", func(q *orm.Query) (*orm.Query, error) { | 53 | query := NewQuery(tx.Model(ProjectModuleModel).Relation("ProjectModuleVersion", func(q *orm.Query) (*orm.Query, error) { |
54 | q.Where("status=0") | 54 | q.Where("status=0") |
@@ -66,7 +66,7 @@ func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]inter | @@ -66,7 +66,7 @@ func (repository *ProjectModuleRepository) FindOne(queryOptions map[string]inter | ||
66 | } | 66 | } |
67 | 67 | ||
68 | func (repository *ProjectModuleRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ProjectModule, error) { | 68 | func (repository *ProjectModuleRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ProjectModule, error) { |
69 | - tx := repository.transactionContext.PgTx | 69 | + tx := repository.transactionContext.PgDd |
70 | var ProjectModuleModels []*models.ProjectModule | 70 | var ProjectModuleModels []*models.ProjectModule |
71 | ProjectModules := make([]*domain.ProjectModule, 0) | 71 | ProjectModules := make([]*domain.ProjectModule, 0) |
72 | query := NewQuery(tx.Model(&ProjectModuleModels), queryOptions). | 72 | query := NewQuery(tx.Model(&ProjectModuleModels), queryOptions). |
@@ -57,7 +57,7 @@ func (repository *ProjectModuleVersionRepository) Remove(ProjectModuleVersion *d | @@ -57,7 +57,7 @@ func (repository *ProjectModuleVersionRepository) Remove(ProjectModuleVersion *d | ||
57 | } | 57 | } |
58 | 58 | ||
59 | func (repository *ProjectModuleVersionRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModuleVersion, error) { | 59 | func (repository *ProjectModuleVersionRepository) FindOne(queryOptions map[string]interface{}) (*domain.ProjectModuleVersion, error) { |
60 | - tx := repository.transactionContext.PgTx | 60 | + tx := repository.transactionContext.PgDd |
61 | ProjectModuleVersionModel := new(models.ProjectModuleVersion) | 61 | ProjectModuleVersionModel := new(models.ProjectModuleVersion) |
62 | query := NewQuery(tx.Model(ProjectModuleVersionModel), queryOptions) | 62 | query := NewQuery(tx.Model(ProjectModuleVersionModel), queryOptions) |
63 | query.SetWhere("id = ?", "id") | 63 | query.SetWhere("id = ?", "id") |
@@ -73,7 +73,7 @@ func (repository *ProjectModuleVersionRepository) FindOne(queryOptions map[strin | @@ -73,7 +73,7 @@ func (repository *ProjectModuleVersionRepository) FindOne(queryOptions map[strin | ||
73 | } | 73 | } |
74 | 74 | ||
75 | func (repository *ProjectModuleVersionRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ProjectModuleVersion, error) { | 75 | func (repository *ProjectModuleVersionRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ProjectModuleVersion, error) { |
76 | - tx := repository.transactionContext.PgTx | 76 | + tx := repository.transactionContext.PgDd |
77 | var ProjectModuleVersionModels []*models.ProjectModuleVersion | 77 | var ProjectModuleVersionModels []*models.ProjectModuleVersion |
78 | ProjectModuleVersions := make([]*domain.ProjectModuleVersion, 0) | 78 | ProjectModuleVersions := make([]*domain.ProjectModuleVersion, 0) |
79 | query := NewQuery(tx.Model(&ProjectModuleVersionModels), queryOptions). | 79 | query := NewQuery(tx.Model(&ProjectModuleVersionModels), queryOptions). |
@@ -46,7 +46,7 @@ func (repository *RoleAccessRepository) Remove(RoleAccess *domain.RoleAccess) (* | @@ -46,7 +46,7 @@ func (repository *RoleAccessRepository) Remove(RoleAccess *domain.RoleAccess) (* | ||
46 | } | 46 | } |
47 | 47 | ||
48 | func (repository *RoleAccessRepository) FindOne(queryOptions map[string]interface{}) (*domain.RoleAccess, error) { | 48 | func (repository *RoleAccessRepository) FindOne(queryOptions map[string]interface{}) (*domain.RoleAccess, error) { |
49 | - tx := repository.transactionContext.PgTx | 49 | + tx := repository.transactionContext.PgDd |
50 | RoleAccessModel := new(models.RoleAccess) | 50 | RoleAccessModel := new(models.RoleAccess) |
51 | query := NewQuery(tx.Model(RoleAccessModel), queryOptions) | 51 | query := NewQuery(tx.Model(RoleAccessModel), queryOptions) |
52 | query.SetWhere("id = ?", "id") | 52 | query.SetWhere("id = ?", "id") |
@@ -60,7 +60,7 @@ func (repository *RoleAccessRepository) FindOne(queryOptions map[string]interfac | @@ -60,7 +60,7 @@ func (repository *RoleAccessRepository) FindOne(queryOptions map[string]interfac | ||
60 | } | 60 | } |
61 | 61 | ||
62 | func (repository *RoleAccessRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.RoleAccess, error) { | 62 | func (repository *RoleAccessRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.RoleAccess, error) { |
63 | - tx := repository.transactionContext.PgTx | 63 | + tx := repository.transactionContext.PgDd |
64 | var RoleAccessModels []*models.RoleAccess | 64 | var RoleAccessModels []*models.RoleAccess |
65 | RoleAccesss := make([]*domain.RoleAccess, 0) | 65 | RoleAccesss := make([]*domain.RoleAccess, 0) |
66 | query := NewQuery(tx.Model(&RoleAccessModels), queryOptions). | 66 | query := NewQuery(tx.Model(&RoleAccessModels), queryOptions). |
@@ -87,7 +87,7 @@ func (repository *RoleRepository) FindOne(queryOptions map[string]interface{}) ( | @@ -87,7 +87,7 @@ func (repository *RoleRepository) FindOne(queryOptions map[string]interface{}) ( | ||
87 | } | 87 | } |
88 | 88 | ||
89 | func (repository *RoleRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Role, error) { | 89 | func (repository *RoleRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Role, error) { |
90 | - tx := repository.transactionContext.PgTx | 90 | + tx := repository.transactionContext.PgDd |
91 | var RoleModels []*models.Role | 91 | var RoleModels []*models.Role |
92 | Roles := make([]*domain.Role, 0) | 92 | Roles := make([]*domain.Role, 0) |
93 | query := NewQuery(tx.Model(&RoleModels), queryOptions). | 93 | query := NewQuery(tx.Model(&RoleModels), queryOptions). |
@@ -89,7 +89,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{}) | @@ -89,7 +89,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{}) | ||
89 | } | 89 | } |
90 | 90 | ||
91 | func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Users, error) { | 91 | func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Users, error) { |
92 | - tx := repository.transactionContext.PgTx | 92 | + tx := repository.transactionContext.PgDd |
93 | var UserModels []*models.Users | 93 | var UserModels []*models.Users |
94 | Users := make([]*domain.Users, 0) | 94 | Users := make([]*domain.Users, 0) |
95 | query := NewQuery(tx.Model(&UserModels), queryOptions). | 95 | query := NewQuery(tx.Model(&UserModels), queryOptions). |
@@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
9 | func init() { | 9 | func init() { |
10 | beego.InsertFilter("*", beego.BeforeRouter, middleware.AllowCors()) | 10 | beego.InsertFilter("*", beego.BeforeRouter, middleware.AllowCors()) |
11 | 11 | ||
12 | - beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter()) | 12 | + beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequestLogFilter()) |
13 | beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(), false) | 13 | beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(), false) |
14 | 14 | ||
15 | beego.InsertFilter("/v1/auth/profile", beego.BeforeExec, middleware.CheckAuthorization) | 15 | beego.InsertFilter("/v1/auth/profile", beego.BeforeExec, middleware.CheckAuthorization) |
@@ -99,13 +99,13 @@ func InspectRoleAccess(parentObject string, skipUrl ...string) func(*context.Con | @@ -99,13 +99,13 @@ func InspectRoleAccess(parentObject string, skipUrl ...string) func(*context.Con | ||
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | -func CreateRequstLogFilter() func(ctx *context.Context) { | 102 | +func CreateRequestLogFilter() func(ctx *context.Context) { |
103 | return func(ctx *context.Context) { | 103 | return func(ctx *context.Context) { |
104 | requestId := fmt.Sprintf("%v.%v.%v ", ctx.Input.Method(), ctx.Input.URI(), time.Now().UnixNano()) | 104 | requestId := fmt.Sprintf("%v.%v.%v ", ctx.Input.Method(), ctx.Input.URI(), time.Now().UnixNano()) |
105 | ctx.Request.Header.Add("requestId", requestId) | 105 | ctx.Request.Header.Add("requestId", requestId) |
106 | var body string = "{}" | 106 | var body string = "{}" |
107 | - if ctx.Input.GetData("requestBody") != nil { | ||
108 | - body = string(ctx.Input.GetData("requestBody").([]byte)) | 107 | + if len(ctx.Input.RequestBody) > 0 { |
108 | + body = string(ctx.Input.RequestBody) | ||
109 | } | 109 | } |
110 | log.Debug(fmt.Sprintf("====>Recv RequestId:%s \nBodyData:%s", requestId, body)) | 110 | log.Debug(fmt.Sprintf("====>Recv RequestId:%s \nBodyData:%s", requestId, body)) |
111 | } | 111 | } |
@@ -118,7 +118,7 @@ func CreateResponseLogFilter() func(ctx *context.Context) { | @@ -118,7 +118,7 @@ func CreateResponseLogFilter() func(ctx *context.Context) { | ||
118 | if len(body) > 1000 { | 118 | if len(body) > 1000 { |
119 | body = body[:1000] | 119 | body = body[:1000] |
120 | } | 120 | } |
121 | - log.Debug(fmt.Sprintf("<====Send User:%v RequestId:%v BodyData:%s", ctx.Input.GetData("x-mmm-id"), requestId, body)) | 121 | + log.Debug(fmt.Sprintf("<====Send User:%v RequestId:%v \nResponseData:%s", ctx.Input.GetData("x-mmm-id"), requestId, body)) |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 |
-
请 注册 或 登录 后发表评论