package dao import ( "context" "model-gateway/consts/public" "model-gateway/model/dto" "model-gateway/model/entity" "gitea.redpowerfuture.com/red-future/common/db/gfdb" "github.com/gogf/gf/v2/util/gconv" ) var ModelSession = &modelSessionDao{} type modelSessionDao struct{} // Insert 插入 func (d *modelSessionDao) Insert(ctx context.Context, req *dto.CreateModelSessionReq) (id int64, err error) { m := new(entity.ModelSession) err = gconv.Struct(req, &m) if err != nil { return } r, err := gfdb.DB(ctx, public.DbNameModelGateway).Model(ctx, public.TableNameModelSession).Insert(m) if err != nil { return } return r.LastInsertId() } // Update 更新(按ID) func (d *modelSessionDao) Update(ctx context.Context, req *dto.UpdateModelSessionReq) (rows int64, err error) { r, err := gfdb.DB(ctx, public.DbNameModelGateway).Model(ctx, public.TableNameModelSession). OmitEmpty(). Data(req). Where(entity.ModelSessionCol.Id, req.Id). Update() if err != nil { return } return r.RowsAffected() }