正在显示
14 个修改的文件
包含
153 行增加
和
78 行删除
| 1 | package constant | 1 | package constant |
| 2 | 2 | ||
| 3 | -import "os" | ||
| 4 | - | ||
| 5 | -const SERVICE_NAME = "terms.base" | 3 | +import ( |
| 4 | + "fmt" | ||
| 5 | + "os" | ||
| 6 | +) | ||
| 6 | 7 | ||
| 8 | +var SERVICE_NAME = "allied-creation-user" | ||
| 9 | +var SERVICE_ENV = "dev" | ||
| 10 | +var CACHE_PREFIX = "allied-creation-user-dev" | ||
| 7 | var LOG_LEVEL = "debug" | 11 | var LOG_LEVEL = "debug" |
| 8 | var EnableCaching = false | 12 | var EnableCaching = false |
| 9 | 13 | ||
| @@ -11,4 +15,5 @@ func init() { | @@ -11,4 +15,5 @@ func init() { | ||
| 11 | if os.Getenv("LOG_LEVEL") != "" { | 15 | if os.Getenv("LOG_LEVEL") != "" { |
| 12 | LOG_LEVEL = os.Getenv("LOG_LEVEL") | 16 | LOG_LEVEL = os.Getenv("LOG_LEVEL") |
| 13 | } | 17 | } |
| 18 | + CACHE_PREFIX = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV) | ||
| 14 | } | 19 | } |
pkg/constant/kafka.go
0 → 100644
| 1 | +package constant | ||
| 2 | + | ||
| 3 | +import "os" | ||
| 4 | + | ||
| 5 | +var ( | ||
| 6 | + // kafka 地址 | ||
| 7 | + KAFKA_HOST = "192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092" | ||
| 8 | + // kafka topic log stash | ||
| 9 | + TOPIC_LOG_STASH = "go_stash_dev" | ||
| 10 | + // 是否启用日志收集 (本地不启用) | ||
| 11 | + ENABLE_KAFKA_LOG = false | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +func init() { | ||
| 15 | + if os.Getenv("KAFKA_HOST") != "" { | ||
| 16 | + POSTGRESQL_HOST = os.Getenv("KAFKA_HOST") | ||
| 17 | + } | ||
| 18 | + if os.Getenv("TOPIC_LOG_STASH") != "" { | ||
| 19 | + POSTGRESQL_PORT = os.Getenv("TOPIC_LOG_STASH") | ||
| 20 | + } | ||
| 21 | + if os.Getenv("ENABLE_KAFKA_LOG") != "" { | ||
| 22 | + DISABLE_CREATE_TABLE = true | ||
| 23 | + } | ||
| 24 | +} |
| @@ -9,6 +9,7 @@ var POSTGRESQL_HOST = "127.0.0.1" | @@ -9,6 +9,7 @@ var POSTGRESQL_HOST = "127.0.0.1" | ||
| 9 | var POSTGRESQL_PORT = "5432" | 9 | var POSTGRESQL_PORT = "5432" |
| 10 | var DISABLE_CREATE_TABLE = false | 10 | var DISABLE_CREATE_TABLE = false |
| 11 | var DISABLE_SQL_GENERATE_PRINT = false | 11 | var DISABLE_SQL_GENERATE_PRINT = false |
| 12 | +var DISABLE_SQL_GENERATE_COMMENT = false | ||
| 12 | 13 | ||
| 13 | func init() { | 14 | func init() { |
| 14 | if os.Getenv("POSTGRESQL_DB_NAME") != "" { | 15 | if os.Getenv("POSTGRESQL_DB_NAME") != "" { |
| @@ -2,9 +2,13 @@ package constant | @@ -2,9 +2,13 @@ package constant | ||
| 2 | 2 | ||
| 3 | import "os" | 3 | import "os" |
| 4 | 4 | ||
| 5 | -var REDIS_HOST = "127.0.0.1" | ||
| 6 | -var REDIS_PORT = "6379" | ||
| 7 | -var REDIS_AUTH = "" | 5 | +var ( |
| 6 | + REDIS_HOST = "127.0.0.1" | ||
| 7 | + REDIS_PORT = "6379" | ||
| 8 | + REDIS_AUTH = "" | ||
| 9 | + // 是否启用仓储层缓存 | ||
| 10 | + ENABLE_REPOSITORY_CACHE = true | ||
| 11 | +) | ||
| 8 | 12 | ||
| 9 | func init() { | 13 | func init() { |
| 10 | if os.Getenv("REDIS_HOST") != "" { | 14 | if os.Getenv("REDIS_HOST") != "" { |
| @@ -17,4 +21,10 @@ func init() { | @@ -17,4 +21,10 @@ func init() { | ||
| 17 | if _, ok := os.LookupEnv("REDIS_AUTH"); ok { | 21 | if _, ok := os.LookupEnv("REDIS_AUTH"); ok { |
| 18 | REDIS_AUTH = os.Getenv("REDIS_AUTH") | 22 | REDIS_AUTH = os.Getenv("REDIS_AUTH") |
| 19 | } | 23 | } |
| 24 | + if os.Getenv("ENABLE_REPOSITORY_CACHE") != "" { | ||
| 25 | + ENABLE_REPOSITORY_CACHE = true | ||
| 26 | + } | ||
| 27 | + if os.Getenv("DISABLE_REPOSITORY_CACHE") != "" { | ||
| 28 | + ENABLE_REPOSITORY_CACHE = false | ||
| 29 | + } | ||
| 20 | } | 30 | } |
| @@ -17,7 +17,7 @@ type Company struct { | @@ -17,7 +17,7 @@ type Company struct { | ||
| 17 | CompanyConfig *CompanyConfig `json:"companyConfig"` | 17 | CompanyConfig *CompanyConfig `json:"companyConfig"` |
| 18 | // 企业基本信息 | 18 | // 企业基本信息 |
| 19 | CompanyInfo *CompanyInfo `json:"companyInfo"` | 19 | CompanyInfo *CompanyInfo `json:"companyInfo"` |
| 20 | - // 公司状态 | 20 | + // 公司状态 1:已注册 2:待认证 3:已认证 |
| 21 | Status int `json:"status"` | 21 | Status int `json:"status"` |
| 22 | // 创建时间 | 22 | // 创建时间 |
| 23 | CreatedAt time.Time `json:"createdAt"` | 23 | CreatedAt time.Time `json:"createdAt"` |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | "fmt" | 5 | "fmt" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg/models" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/infrastructure/pg/models" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/log" |
| 8 | + "reflect" | ||
| 8 | 9 | ||
| 9 | "github.com/go-pg/pg/v10" | 10 | "github.com/go-pg/pg/v10" |
| 10 | "github.com/go-pg/pg/v10/orm" | 11 | "github.com/go-pg/pg/v10/orm" |
| @@ -38,6 +39,9 @@ func init() { | @@ -38,6 +39,9 @@ func init() { | ||
| 38 | if err != nil { | 39 | if err != nil { |
| 39 | panic(err) | 40 | panic(err) |
| 40 | } | 41 | } |
| 42 | + if !constant.DISABLE_SQL_GENERATE_COMMENT { | ||
| 43 | + AddComments(DB, model) | ||
| 44 | + } | ||
| 41 | } | 45 | } |
| 42 | } | 46 | } |
| 43 | } | 47 | } |
| @@ -56,3 +60,26 @@ func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent) | @@ -56,3 +60,26 @@ func (hook SqlGeneratePrintHook) AfterQuery(c context.Context, q *pg.QueryEvent) | ||
| 56 | log.Logger.Debug(string(sqlStr)) | 60 | log.Logger.Debug(string(sqlStr)) |
| 57 | return nil | 61 | return nil |
| 58 | } | 62 | } |
| 63 | + | ||
| 64 | +func AddComments(db *pg.DB, model interface{}) { | ||
| 65 | + tableName := db.Model(model).TableModel().Table().SQLName | ||
| 66 | + columnsMap := make(map[string]*orm.Field) | ||
| 67 | + columns := db.Model(model).TableModel().Table().Fields | ||
| 68 | + for _, item := range columns { | ||
| 69 | + columnsMap[item.GoName] = item | ||
| 70 | + } | ||
| 71 | + valueOf := reflect.TypeOf(model) | ||
| 72 | + for i := 0; i < valueOf.Elem().NumField(); i++ { | ||
| 73 | + field := valueOf.Elem().Field(i) | ||
| 74 | + comment := field.Tag.Get("comment") | ||
| 75 | + if comment != "" { | ||
| 76 | + if field.Name == "tableName" { | ||
| 77 | + _, _ = db.Exec(fmt.Sprintf("COMMENT ON TABLE %s IS '%s';", tableName, comment)) | ||
| 78 | + } else { | ||
| 79 | + if columnField, ok := columnsMap[field.Name]; ok { | ||
| 80 | + _, _ = db.Exec(fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s';", tableName, columnField.SQLName, comment)) | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | +} |
| @@ -6,17 +6,17 @@ import ( | @@ -6,17 +6,17 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type Company struct { | 8 | type Company struct { |
| 9 | - tableName string `pg:"users.company,alias:company"` | 9 | + tableName string `pg:"users.company,alias:company" comment:"企业"` |
| 10 | // 企业id | 10 | // 企业id |
| 11 | - CompanyId int64 | 11 | + CompanyId int64 `comment:"企业id"` |
| 12 | // 企业配置信息 | 12 | // 企业配置信息 |
| 13 | - CompanyConfig *domain.CompanyConfig | 13 | + CompanyConfig *domain.CompanyConfig `comment:"企业配置信息"` |
| 14 | // 企业基本信息 | 14 | // 企业基本信息 |
| 15 | - CompanyInfo *domain.CompanyInfo | ||
| 16 | - // 公司状态 | ||
| 17 | - Status int | 15 | + CompanyInfo *domain.CompanyInfo `comment:"企业基本信息"` |
| 16 | + // 公司状态 1:已注册 2:待认证 3:已认证 | ||
| 17 | + Status int `comment:"公司状态 1:已注册 2:待认证 3:已认证"` | ||
| 18 | // 创建时间 | 18 | // 创建时间 |
| 19 | - CreatedAt time.Time | 19 | + CreatedAt time.Time `comment:"创建时间"` |
| 20 | // 更新时间 | 20 | // 更新时间 |
| 21 | - UpdatedAt time.Time | 21 | + UpdatedAt time.Time `comment:"更新时间"` |
| 22 | } | 22 | } |
| 1 | package models | 1 | package models |
| 2 | 2 | ||
| 3 | type Menu struct { | 3 | type Menu struct { |
| 4 | - tableName string `pg:"users.menu,alias:menu"` | 4 | + tableName string `pg:"users.menu,alias:menu" comment:"菜单"` |
| 5 | // 菜单编号 | 5 | // 菜单编号 |
| 6 | - MenuId int64 `pg:",pk"` | 6 | + MenuId int64 `pg:",pk" comment:"菜单编号"` |
| 7 | // 父级id | 7 | // 父级id |
| 8 | - ParentId int64 | 8 | + ParentId int64 `comment:"父级id"` |
| 9 | // 菜单名称 | 9 | // 菜单名称 |
| 10 | - MenuName string | 10 | + MenuName string `comment:"菜单名称"` |
| 11 | // 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码) | 11 | // 菜单编码 SYSTEM_USER_EDIT / 100101 (字符编码) |
| 12 | - Code string | 12 | + Code string `comment:"菜单编码"` |
| 13 | // 权限编码 users:edit | 13 | // 权限编码 users:edit |
| 14 | - AccessCode string | 14 | + AccessCode string `comment:"权限编码"` |
| 15 | // 菜单类型 (目录catalog、菜单menu、按钮button) | 15 | // 菜单类型 (目录catalog、菜单menu、按钮button) |
| 16 | - MenuType string | 16 | + MenuType string `comment:"菜单类型 (目录catalog、菜单menu、按钮button)"` |
| 17 | // 菜单图标 | 17 | // 菜单图标 |
| 18 | - Icon string | 18 | + Icon string `comment:"菜单图标"` |
| 19 | // 排序 | 19 | // 排序 |
| 20 | - Sort int | 20 | + Sort int `comment:"排序"` |
| 21 | // 菜单说明 | 21 | // 菜单说明 |
| 22 | - Remark string | 22 | + Remark string `comment:"菜单说明"` |
| 23 | // 菜单类别 (web:1、app:2) | 23 | // 菜单类别 (web:1、app:2) |
| 24 | - Category string | 24 | + Category string `comment:"菜单类别"` |
| 25 | // 父级节点路径("0,11,12,") | 25 | // 父级节点路径("0,11,12,") |
| 26 | - ParentPath string | 26 | + ParentPath string `comment:"父级节点路径(0,11,12)"` |
| 27 | // 菜单是否公开状态,[2:隐藏],[1:显示],默认显示 | 27 | // 菜单是否公开状态,[2:隐藏],[1:显示],默认显示 |
| 28 | - IsPublish int | 28 | + IsPublish int `comment:"菜单是否公开状态,[2:隐藏],[1:显示],默认显示"` |
| 29 | // 启用状态(启用:1 禁用:2),默认启用 | 29 | // 启用状态(启用:1 禁用:2),默认启用 |
| 30 | - EnableStatus int | 30 | + EnableStatus int `comment:"启用状态(启用:1 禁用:2),默认启用"` |
| 31 | } | 31 | } |
| @@ -6,29 +6,29 @@ import ( | @@ -6,29 +6,29 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type Org struct { | 8 | type Org struct { |
| 9 | - tableName string `pg:"users.org,alias:org"` | 9 | + tableName string `pg:"users.org,alias:org" comment:"组织"` |
| 10 | // 组织ID | 10 | // 组织ID |
| 11 | - OrgId int64 | 11 | + OrgId int64 `comment:"组织ID"` |
| 12 | // 企业id | 12 | // 企业id |
| 13 | - CompanyId int64 | 13 | + CompanyId int64 `comment:"企业id"` |
| 14 | // 创建时间 | 14 | // 创建时间 |
| 15 | - CreatedAt time.Time | 15 | + CreatedAt time.Time `comment:"创建时间"` |
| 16 | // 更新时间 | 16 | // 更新时间 |
| 17 | - UpdatedAt time.Time | 17 | + UpdatedAt time.Time `comment:"更新时间"` |
| 18 | // 删除时间 | 18 | // 删除时间 |
| 19 | - DeletedAt time.Time | 19 | + DeletedAt time.Time `comment:"删除时间"` |
| 20 | // 组织编码 | 20 | // 组织编码 |
| 21 | - OrgCode string | 21 | + OrgCode string `comment:"组织编码"` |
| 22 | // 组织名称 | 22 | // 组织名称 |
| 23 | - OrgName string | 23 | + OrgName string `comment:"组织名称"` |
| 24 | // 扩展数据 | 24 | // 扩展数据 |
| 25 | - Ext *domain.Ext | 25 | + Ext *domain.Ext `comment:"扩展数据"` |
| 26 | // 是否是组织标识 1:是 2:不是 | 26 | // 是否是组织标识 1:是 2:不是 |
| 27 | - IsOrg int | 27 | + IsOrg int `comment:"是否是组织标识 1:是 2:不是"` |
| 28 | // 组织状态 1:启用 2:禁用 3.删除 | 28 | // 组织状态 1:启用 2:禁用 3.删除 |
| 29 | - OrgStatus int `json:"orgStatus"` | 29 | + OrgStatus int `json:"orgStatus" comment:"组织状态 1:启用 2:禁用 3.删除"` |
| 30 | // 父级ID | 30 | // 父级ID |
| 31 | - ParentId int64 | 31 | + ParentId int64 `comment:"父级ID"` |
| 32 | // 父级节点路径("0,11,12,") | 32 | // 父级节点路径("0,11,12,") |
| 33 | - ParentPath string | 33 | + ParentPath string `comment:"父级节点路径"` |
| 34 | } | 34 | } |
| @@ -6,25 +6,25 @@ import ( | @@ -6,25 +6,25 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type Role struct { | 8 | type Role struct { |
| 9 | - tableName string `pg:"users.role,alias:role"` | 9 | + tableName string `pg:"users.role,alias:role" comment:"角色"` |
| 10 | // 角色ID | 10 | // 角色ID |
| 11 | - RoleId int64 | 11 | + RoleId int64 `comment:"角色ID"` |
| 12 | // 企业id | 12 | // 企业id |
| 13 | - CompanyId int64 | 13 | + CompanyId int64 `comment:"企业id"` |
| 14 | // 组织ID | 14 | // 组织ID |
| 15 | - OrgId int64 | 15 | + OrgId int64 `comment:"组织ID"` |
| 16 | // 角色类型 1.普通角色 1024:超级管理员 | 16 | // 角色类型 1.普通角色 1024:超级管理员 |
| 17 | - RoleType int | 17 | + RoleType int `comment:"角色类型 1.普通角色 1024:超级管理员"` |
| 18 | // 角色名称 | 18 | // 角色名称 |
| 19 | - RoleName string | 19 | + RoleName string `comment:"角色名称"` |
| 20 | // 有权限的菜单 | 20 | // 有权限的菜单 |
| 21 | - AccessMenus []int64 `pg:",array"` | 21 | + AccessMenus []int64 `pg:",array" comment:"有权限的菜单"` |
| 22 | // 描述 | 22 | // 描述 |
| 23 | - Desc int64 | 23 | + Desc int64 `comment:"描述"` |
| 24 | // 扩展数据 | 24 | // 扩展数据 |
| 25 | - Ext *domain.Ext | 25 | + Ext *domain.Ext `comment:"扩展数据"` |
| 26 | // 创建时间 | 26 | // 创建时间 |
| 27 | - CreatedAt time.Time | 27 | + CreatedAt time.Time `comment:"创建时间"` |
| 28 | // 更新时间 | 28 | // 更新时间 |
| 29 | - UpdatedAt time.Time | 29 | + UpdatedAt time.Time `comment:"更新时间"` |
| 30 | } | 30 | } |
| @@ -8,35 +8,35 @@ import ( | @@ -8,35 +8,35 @@ import ( | ||
| 8 | type Users struct { | 8 | type Users struct { |
| 9 | tableName string `pg:"users.users,alias:users"` | 9 | tableName string `pg:"users.users,alias:users"` |
| 10 | // 用户Id 用户唯一标识 | 10 | // 用户Id 用户唯一标识 |
| 11 | - UsersId int64 | 11 | + UsersId int64 `comment:"用户Id"` |
| 12 | // 企业id | 12 | // 企业id |
| 13 | - CompanyId int64 | 13 | + CompanyId int64 `comment:"企业id"` |
| 14 | // 用户基础数据id | 14 | // 用户基础数据id |
| 15 | - UsersBaseId int64 | 15 | + UsersBaseId int64 `comment:"用户基础数据id"` |
| 16 | // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加) | 16 | // 用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加) |
| 17 | - UsersType int | 17 | + UsersType int `comment:"用户类型 1:企业内部用户(内部添加) 2:共创用户 1024:企业注册用户(注册添加"` |
| 18 | // 用户编号 企业内标识 | 18 | // 用户编号 企业内标识 |
| 19 | - UsersCode string | 19 | + UsersCode string `comment:"用户编号"` |
| 20 | // 组织机构 | 20 | // 组织机构 |
| 21 | - OrganizationId int64 | 21 | + OrganizationId int64 `comment:"组织机构"` |
| 22 | // 所属部门 | 22 | // 所属部门 |
| 23 | - DepartmentId int64 | 23 | + DepartmentId int64 `comment:"所属部门"` |
| 24 | // 用户信息 (冗余,数据存在usersBase里面) | 24 | // 用户信息 (冗余,数据存在usersBase里面) |
| 25 | //UsersInfo *domain.UsersInfo | 25 | //UsersInfo *domain.UsersInfo |
| 26 | // 用户关联的组织 | 26 | // 用户关联的组织 |
| 27 | - UsersOrg []*domain.Org `pg:",array"` | 27 | + UsersOrg []*domain.Org `pg:",array" comment:"用户关联的组织"` |
| 28 | // 用户关联的角色 | 28 | // 用户关联的角色 |
| 29 | - UsersRole []*domain.Role `pg:",array"` | 29 | + UsersRole []*domain.Role `pg:",array" comment:"用户关联的角色"` |
| 30 | // 收藏的菜单(工作台)(菜单编码列表) | 30 | // 收藏的菜单(工作台)(菜单编码列表) |
| 31 | - FavoriteMenus []string `pg:",array"` | 31 | + FavoriteMenus []string `pg:",array" comment:"收藏的菜单"` |
| 32 | // 共创信息 (共创用户有效) | 32 | // 共创信息 (共创用户有效) |
| 33 | - CooperationInfo *domain.CooperationInfo | 33 | + CooperationInfo *domain.CooperationInfo `comment:"共创信息 (共创用户有效)"` |
| 34 | // 状态(1:启用 2:禁用 3:注销) | 34 | // 状态(1:启用 2:禁用 3:注销) |
| 35 | - EnableStatus int | 35 | + EnableStatus int `comment:" 状态(1:启用 2:禁用 3:注销)"` |
| 36 | // 扩展数据 | 36 | // 扩展数据 |
| 37 | - Ext *domain.Ext | 37 | + Ext *domain.Ext `comment:"扩展数据"` |
| 38 | // 创建时间 | 38 | // 创建时间 |
| 39 | - CreatedAt time.Time | 39 | + CreatedAt time.Time `comment:"创建时间"` |
| 40 | // 更新时间 | 40 | // 更新时间 |
| 41 | - UpdatedAt time.Time | 41 | + UpdatedAt time.Time `comment:"更新时间"` |
| 42 | } | 42 | } |
| @@ -6,23 +6,23 @@ import ( | @@ -6,23 +6,23 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type UsersBase struct { | 8 | type UsersBase struct { |
| 9 | - tableName string `pg:"users.users_base,alias:users_base"` | 9 | + tableName string `pg:"users.users_base,alias:users_base" comment:"用户基础"` |
| 10 | // 用户基础数据id | 10 | // 用户基础数据id |
| 11 | - UsersBaseId int64 | 11 | + UsersBaseId int64 `comment:"用户基础数据id"` |
| 12 | // 用户信息 | 12 | // 用户信息 |
| 13 | - UsersInfo *domain.UsersInfo | 13 | + UsersInfo *domain.UsersInfo `comment:"用户信息"` |
| 14 | // 手机号码 | 14 | // 手机号码 |
| 15 | - Phone string | 15 | + Phone string `comment:"手机号码"` |
| 16 | // 密码 | 16 | // 密码 |
| 17 | - Password string | 17 | + Password string `comment:"密码"` |
| 18 | // IM信息 | 18 | // IM信息 |
| 19 | - Im *domain.Im | 19 | + Im *domain.Im `comment:"IM信息"` |
| 20 | // 关联的用户 (冗余) | 20 | // 关联的用户 (冗余) |
| 21 | - RelatedUsers []int64 `pg:",array"` | 21 | + RelatedUsers []int64 `pg:",array" comment:"关联的用户 (冗余)"` |
| 22 | // 账号状态 1:正常 2.禁用 3:注销 | 22 | // 账号状态 1:正常 2.禁用 3:注销 |
| 23 | - Status int | 23 | + Status int `comment:"账号状态 1:正常 2.禁用 3:注销"` |
| 24 | // 创建时间 | 24 | // 创建时间 |
| 25 | - CreatedAt time.Time | 25 | + CreatedAt time.Time `comment:"创建时间"` |
| 26 | // 更新时间 | 26 | // 更新时间 |
| 27 | - UpdatedAt time.Time | 27 | + UpdatedAt time.Time `comment:"更新时间"` |
| 28 | } | 28 | } |
| @@ -12,4 +12,9 @@ func init() { | @@ -12,4 +12,9 @@ func init() { | ||
| 12 | Logger = logrus.NewLogrusLogger() | 12 | Logger = logrus.NewLogrusLogger() |
| 13 | Logger.SetServiceName(constant.SERVICE_NAME) | 13 | Logger.SetServiceName(constant.SERVICE_NAME) |
| 14 | Logger.SetLevel(constant.LOG_LEVEL) | 14 | Logger.SetLevel(constant.LOG_LEVEL) |
| 15 | + | ||
| 16 | + if constant.ENABLE_KAFKA_LOG { | ||
| 17 | + w, _ := logrus.NewKafkaWriter(constant.KAFKA_HOST, constant.TOPIC_LOG_STASH, false) | ||
| 18 | + Logger.AddHook(w) | ||
| 19 | + } | ||
| 15 | } | 20 | } |
-
请 注册 或 登录 后发表评论