refactor: 重命名集合常量并优化配置注释
This commit is contained in:
32
config.yml
32
config.yml
@@ -15,13 +15,15 @@ database:
|
|||||||
user: "postgres"
|
user: "postgres"
|
||||||
pass: "Bjang09@686^*^"
|
pass: "Bjang09@686^*^"
|
||||||
name: "oss"
|
name: "oss"
|
||||||
role: "master"
|
role: "master" # (可选)数据库主从角色(master/slave),默认为master。如果不使用应用主从机制请不配置或留空即可。
|
||||||
maxIdle: "5"
|
debug: false # (可选)开启调试模式
|
||||||
maxOpen: "20"
|
dryRun: false # (可选)ORM空跑(只读不写)
|
||||||
maxLifetime: "60s"
|
charset: "utf8" # (可选)数据库编码(如: utf8mb4/utf8/gbk/gb2312),一般设置为utf8mb4。默认为utf8。
|
||||||
charset: "utf8mb4" #数据库编码
|
timezone: "Asia/Shanghai" # (可选)时区配置,例如:Local
|
||||||
debug: true
|
maxIdle: 5 # (可选)连接池最大闲置的连接数(默认10)
|
||||||
dryRun: false #空跑
|
maxOpen: 20 # (可选)连接池最大打开的连接数(默认无限制)
|
||||||
|
maxLifetime: "30s" # (可选)连接对象可重复使用的时间长度(默认30秒)
|
||||||
|
maxIdleConnTime: "30s" # (可选,v2.10新增)连接池中空闲连接的最大生存时间(默认30秒)。可以通过配置文件或SetConnMaxIdleTime方法设置,避免长时间空闲连接占用资源。
|
||||||
createdAt: "created_at" # (可选)自动创建时间字段名称
|
createdAt: "created_at" # (可选)自动创建时间字段名称
|
||||||
updatedAt: "updated_at" # (可选)自动更新时间字段名称
|
updatedAt: "updated_at" # (可选)自动更新时间字段名称
|
||||||
deletedAt: "deleted_at" # (可选)软删除时间字段名称
|
deletedAt: "deleted_at" # (可选)软删除时间字段名称
|
||||||
@@ -32,13 +34,15 @@ database:
|
|||||||
user: "postgres"
|
user: "postgres"
|
||||||
pass: "Bjang09@686^*^"
|
pass: "Bjang09@686^*^"
|
||||||
name: "oss"
|
name: "oss"
|
||||||
role: "slave"
|
role: "slave" # (可选)数据库主从角色(master/slave),默认为master。如果不使用应用主从机制请不配置或留空即可。
|
||||||
maxIdle: "5"
|
debug: false # (可选)开启调试模式
|
||||||
maxOpen: "20"
|
dryRun: false # (可选)ORM空跑(只读不写)
|
||||||
maxLifetime: "60s"
|
charset: "utf8" # (可选)数据库编码(如: utf8mb4/utf8/gbk/gb2312),一般设置为utf8mb4。默认为utf8。
|
||||||
charset: "utf8mb4" #数据库编码
|
timezone: "Asia/Shanghai" # (可选)时区配置,例如:Local
|
||||||
debug: true
|
maxIdle: 5 # (可选)连接池最大闲置的连接数(默认10)
|
||||||
dryRun: false #空跑
|
maxOpen: 20 # (可选)连接池最大打开的连接数(默认无限制)
|
||||||
|
maxLifetime: "30s" # (可选)连接对象可重复使用的时间长度(默认30秒)
|
||||||
|
maxIdleConnTime: "30s" # (可选,v2.10新增)连接池中空闲连接的最大生存时间(默认30秒)。可以通过配置文件或SetConnMaxIdleTime方法设置,避免长时间空闲连接占用资源。
|
||||||
createdAt: "created_at" # (可选)自动创建时间字段名称
|
createdAt: "created_at" # (可选)自动创建时间字段名称
|
||||||
updatedAt: "updated_at" # (可选)自动更新时间字段名称
|
updatedAt: "updated_at" # (可选)自动更新时间字段名称
|
||||||
deletedAt: "deleted_at" # (可选)软删除时间字段名称
|
deletedAt: "deleted_at" # (可选)软删除时间字段名称
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package consts
|
|
||||||
|
|
||||||
// MongoDB集合名称常量
|
|
||||||
const (
|
|
||||||
FileCollection = "file"
|
|
||||||
TenantOssTotalCollection = "tenant_oss_total"
|
|
||||||
)
|
|
||||||
7
consts/table_name.go
Normal file
7
consts/table_name.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package consts
|
||||||
|
|
||||||
|
// 数据库表名
|
||||||
|
const (
|
||||||
|
TableNameFile = "file"
|
||||||
|
TableNameTenantOssTotal = "tenant_oss_total"
|
||||||
|
)
|
||||||
@@ -20,7 +20,7 @@ func (d *file) Insert(ctx context.Context, req *dto.UploadFile) (id int64, err e
|
|||||||
if err = gconv.Struct(req, &res); err != nil {
|
if err = gconv.Struct(req, &res); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r, err := gfdb.DB(ctx).Model(ctx, consts.FileCollection).Insert(&res)
|
r, err := gfdb.DB(ctx).Model(ctx, consts.TableNameFile).Insert(&res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func (d *tenantOssTotal) SaveOrUpdate(ctx context.Context, updateData []*dto.Upd
|
|||||||
if err = gconv.Structs(updateData, &res); err != nil {
|
if err = gconv.Structs(updateData, &res); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r, err := gfdb.DB(ctx).Model(ctx, consts.TenantOssTotalCollection).Data(res).OnConflict(entity.TenantOssCol.TenantId).Save()
|
r, err := gfdb.DB(ctx).Model(ctx, consts.TableNameTenantOssTotal).Data(res).OnConflict(entity.TenantOssCol.TenantId).Save()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ func (d *tenantOssTotal) SaveOrUpdate(ctx context.Context, updateData []*dto.Upd
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *tenantOssTotal) GetOneByTenantId(ctx context.Context, req *dto.GetByTenantIdReq) (res *entity.TenantOssTotal, err error) {
|
func (d *tenantOssTotal) GetOneByTenantId(ctx context.Context, req *dto.GetByTenantIdReq) (res *entity.TenantOssTotal, err error) {
|
||||||
model := gfdb.DB(ctx).Model(ctx, consts.TenantOssTotalCollection).Where(entity.TenantOssCol.TenantId, req.TenantId)
|
model := gfdb.DB(ctx).Model(ctx, consts.TableNameTenantOssTotal).Where(entity.TenantOssCol.TenantId, req.TenantId)
|
||||||
record, err := model.One()
|
record, err := model.One()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user