feat: 新增创作作品管理模块及相关配置
This commit is contained in:
43
workflow/dao/creation_info_dao.go
Normal file
43
workflow/dao/creation_info_dao.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"ai-agent/workflow/consts"
|
||||
"ai-agent/workflow/model/dto"
|
||||
"ai-agent/workflow/model/entity"
|
||||
"context"
|
||||
|
||||
"gitea.com/red-future/common/db/gfdb"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
var CreationInfoDao = &creationInfoDao{}
|
||||
|
||||
type creationInfoDao struct{}
|
||||
|
||||
func (d *creationInfoDao) List(ctx context.Context, req *dto.ListCreationInfoReq, fields ...string) (res []*entity.CreationInfo, total int, err error) {
|
||||
model := gfdb.DB(ctx, consts.DbNameBlackDeacon).Model(ctx, consts.TableNameCreationInfo).Fields(fields).OmitEmpty()
|
||||
model.Where(entity.CreationInfoCol.Creator, req.Creator)
|
||||
model.OrderDesc(entity.CreationInfoCol.CreatedAt)
|
||||
if req.Page != nil {
|
||||
model.Page(int(req.Page.PageNum), int(req.Page.PageSize))
|
||||
}
|
||||
r, total, err := model.AllAndCount(false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = r.Structs(&res)
|
||||
return
|
||||
}
|
||||
|
||||
// Insert 插入
|
||||
func (d *creationInfoDao) Insert(ctx context.Context, req *dto.Create) (id int64, err error) {
|
||||
e := &entity.CreationInfo{}
|
||||
if err = gconv.Struct(req, e); err != nil {
|
||||
return
|
||||
}
|
||||
r, err := gfdb.DB(ctx, consts.DbNameBlackDeacon).Model(ctx, consts.TableNameCreationInfo).Insert(e)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return r.LastInsertId()
|
||||
}
|
||||
Reference in New Issue
Block a user