package implement import ( "applet/app/db/dao" "applet/app/db/model" "applet/app/utils/logx" "xorm.io/xorm" ) func NewMediumDomainDb(engine *xorm.Engine) dao.MediumDomainDao { return &MediumDomainDb{Db: engine} } type MediumDomainDb struct { Db *xorm.Engine } func (m MediumDomainDb) GetMediumDomain(mediumId int) (medium *model.MediumDomain, err error) { medium = new(model.MediumDomain) has, err := m.Db.Where("medium_id =?", mediumId).Get(medium) if err != nil { return nil, logx.Error(err) } if has == false { return nil, nil } return medium, nil } func (m MediumDomainDb) MediumDomainInsert(medium *model.MediumDomain) (int64, error) { insertAffected, err := m.Db.InsertOne(medium) if err != nil { return 0, err } return insertAffected, nil }