fix: 更新数据库表名引用及配置
This commit is contained in:
@@ -23,7 +23,7 @@ func (d *category) Insert(ctx context.Context, req *dto.CreateCategoryReq) (id i
|
||||
if err = gconv.Struct(req, &res); err != nil {
|
||||
return
|
||||
}
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.CategoryCollection).Insert(&res)
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameCategory).Insert(&res)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func (d *category) Insert(ctx context.Context, req *dto.CreateCategoryReq) (id i
|
||||
|
||||
// Update 更新分类
|
||||
func (d *category) Update(ctx context.Context, req *dto.UpdateCategoryReq) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.CategoryCollection).Data(&req).OmitEmpty().Where(entity.CategoryCol.Id, req.Id).Update()
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameCategory).Data(&req).OmitEmpty().Where(entity.CategoryCol.Id, req.Id).Update()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -41,7 +41,7 @@ func (d *category) Update(ctx context.Context, req *dto.UpdateCategoryReq) (rows
|
||||
|
||||
// Delete 删除分类-根据id及父id进行假删
|
||||
func (d *category) Delete(ctx context.Context, req *dto.DeleteCategoryReq) (rows int64, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.CategoryCollection).Where(entity.CategoryCol.Id, req.Id).Delete()
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameCategory).Where(entity.CategoryCol.Id, req.Id).Delete()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (d *category) Delete(ctx context.Context, req *dto.DeleteCategoryReq) (rows
|
||||
|
||||
// GetOne 获取单个分类
|
||||
func (d *category) GetOne(ctx context.Context, req *dto.GetCategoryReq, fields ...string) (res *entity.Category, err error) {
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.CategoryCollection).Where(entity.CategoryCol.Id, req.Id).Fields(fields).One()
|
||||
r, err := gfdb.DB(ctx).Model(ctx, public.TableNameCategory).Where(entity.CategoryCol.Id, req.Id).Fields(fields).One()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -82,7 +82,7 @@ func (d *category) List(ctx context.Context, req *dto.ListCategoryReq, fields ..
|
||||
|
||||
// buildListFilter 构建列表查询的过滤条件
|
||||
func (d *category) buildListFilter(ctx context.Context, req *dto.ListCategoryReq) *gdb.Model {
|
||||
model := gfdb.DB(ctx).Model(ctx, public.CategoryCollection).Cache(ctx)
|
||||
model := gfdb.DB(ctx).Model(ctx, public.TableNameCategory).Cache(ctx)
|
||||
if !g.IsEmpty(req.Keyword) {
|
||||
model.WhereLike(entity.CategoryCol.Name, "%"+req.Keyword+"%")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user