// ================================================================================= // This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. // ================================================================================= package dao import ( "context" "github.com/gogf/gf/v2/errors/gerror" "hotgo/internal/dao/internal" "hotgo/internal/model/entity" ) // internalAdminMemberPostDao is internal type for wrapping internal DAO implements. type internalAdminMemberPostDao = *internal.AdminMemberPostDao // adminMemberPostDao is the data access object for table hg_admin_member_post. // You can define custom methods on it to extend its functionality as you wish. type adminMemberPostDao struct { internalAdminMemberPostDao } var ( // AdminMemberPost is globally common accessible object for table hg_admin_member_post operations. AdminMemberPost = adminMemberPostDao{ internal.NewAdminMemberPostDao(), } ) // UpdatePostIds 更新管理员岗位 func (dao *adminMemberPostDao) UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error) { _, err = dao.Ctx(ctx). Where("member_id", memberId). Delete() if err != nil { err = gerror.Wrap(err, "删除失败") return err } for i := 0; i < len(postIds); i++ { _, err = dao.Ctx(ctx). Insert(entity.AdminMemberPost{ MemberId: memberId, PostId: postIds[i], }) if err != nil { err = gerror.Wrap(err, "插入用户岗位失败") return err } } return nil }