|
|
@@ -1,4 +1,4 @@
|
|
|
-package base
|
|
|
+package service
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
@@ -9,14 +9,14 @@ import (
|
|
|
)
|
|
|
|
|
|
// Context 上下文管理服务
|
|
|
-type contextService struct {
|
|
|
+type ContextService struct {
|
|
|
Tenant string `json:"tenant"`
|
|
|
CxtUser *request.UserInfo `json:"cxtUser"`
|
|
|
}
|
|
|
|
|
|
// Init 初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改。
|
|
|
-func (c *contextService) Init(ctx context.Context) (*contextService, error) {
|
|
|
- c = new(contextService)
|
|
|
+func (c *ContextService) Init(ctx context.Context) (*ContextService, error) {
|
|
|
+ c = new(ContextService)
|
|
|
// 获取租户码
|
|
|
tenant, err := micro_srv.GetTenant(ctx)
|
|
|
if err != nil {
|
|
|
@@ -36,28 +36,28 @@ func (c *contextService) Init(ctx context.Context) (*contextService, error) {
|
|
|
return c, nil
|
|
|
}
|
|
|
|
|
|
-func (c *contextService) GetCxtUserId() int {
|
|
|
+func (c *ContextService) GetCxtUserId() int {
|
|
|
if c.CxtUser == nil {
|
|
|
return -1
|
|
|
}
|
|
|
return c.CxtUser.Id
|
|
|
}
|
|
|
|
|
|
-func (c *contextService) GetCxtUserUuid() string {
|
|
|
+func (c *ContextService) GetCxtUserUuid() string {
|
|
|
if c.CxtUser == nil {
|
|
|
return "-1"
|
|
|
}
|
|
|
return c.CxtUser.Uuid
|
|
|
}
|
|
|
|
|
|
-func (c *contextService) GetCxtUserName() string {
|
|
|
+func (c *ContextService) GetCxtUserName() string {
|
|
|
if c.CxtUser == nil {
|
|
|
return "-1"
|
|
|
}
|
|
|
return c.CxtUser.UserName
|
|
|
}
|
|
|
|
|
|
-func (c *contextService) GetCxtUserDeptId() int {
|
|
|
+func (c *ContextService) GetCxtUserDeptId() int {
|
|
|
if c.CxtUser == nil {
|
|
|
return -1
|
|
|
}
|