package dao import ( "ai-agent/workflow/consts/public" "ai-agent/workflow/model/dto" "ai-agent/workflow/model/entity" "context" "gitea.redpowerfuture.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, public.DbNameBlackDeacon).Model(ctx, public.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, public.DbNameBlackDeacon).Model(ctx, public.TableNameCreationInfo).Insert(e) if err != nil { return } return r.LastInsertId() }