package mysqldao import ( "context" "git.lzcwy.cn/zhengchiliu/zt-closet-backend/global" "git.lzcwy.cn/zhengchiliu/zt-closet-backend/internal/mysqlmodel" "gorm.io/gorm" ) // ClosetAuditLogDao 衣柜分享审核日志数据访问 type ClosetAuditLogDao struct { db *gorm.DB } // NewClosetAuditLogDao 创建衣柜分享审核日志 DAO func NewClosetAuditLogDao() *ClosetAuditLogDao { return &ClosetAuditLogDao{db: global.MysqlEngine} } // ClosetAuditLogCreate 创建衣柜分享审核日志 func (d *ClosetAuditLogDao) ClosetAuditLogCreate(ctx context.Context, log *mysqlmodel.ClosetAuditLog) error { ctx, span := global.Tracer.Start(ctx, "mysqldao.ClosetAuditLogCreate") defer span.End() if err := d.db.WithContext(ctx).Create(log).Error; err != nil { span.RecordError(err) return err } return nil } // ClosetAuditLogListByTargetID 查询目标衣柜分享的审核日志 func (d *ClosetAuditLogDao) ClosetAuditLogListByTargetID(ctx context.Context, targetID int64) ([]mysqlmodel.ClosetAuditLog, error) { ctx, span := global.Tracer.Start(ctx, "mysqldao.ClosetAuditLogListByTargetID") defer span.End() var list []mysqlmodel.ClosetAuditLog if err := d.db.WithContext(ctx).Where("target_id = ?", targetID).Find(&list).Error; err != nil { span.RecordError(err) return nil, err } return list, nil } // OutfitAuditLogDao 穿搭审核日志数据访问 type OutfitAuditLogDao struct { db *gorm.DB } // NewOutfitAuditLogDao 创建穿搭审核日志 DAO func NewOutfitAuditLogDao() *OutfitAuditLogDao { return &OutfitAuditLogDao{db: global.MysqlEngine} } // OutfitAuditLogCreate 创建穿搭审核日志 func (d *OutfitAuditLogDao) OutfitAuditLogCreate(ctx context.Context, log *mysqlmodel.OutfitAuditLog) error { ctx, span := global.Tracer.Start(ctx, "mysqldao.OutfitAuditLogCreate") defer span.End() if err := d.db.WithContext(ctx).Create(log).Error; err != nil { span.RecordError(err) return err } return nil } // OutfitAuditLogListByTargetID 查询目标穿搭的审核日志 func (d *OutfitAuditLogDao) OutfitAuditLogListByTargetID(ctx context.Context, targetID int64) ([]mysqlmodel.OutfitAuditLog, error) { ctx, span := global.Tracer.Start(ctx, "mysqldao.OutfitAuditLogListByTargetID") defer span.End() var list []mysqlmodel.OutfitAuditLog if err := d.db.WithContext(ctx).Where("target_id = ?", targetID).Find(&list).Error; err != nil { span.RecordError(err) return nil, err } return list, nil }