广告平台(总站长使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
779 B

  1. package implement
  2. import (
  3. "applet/app/db/dao"
  4. "applet/app/db/model"
  5. "applet/app/utils/logx"
  6. "xorm.io/xorm"
  7. )
  8. func NewMediumDomainDb(engine *xorm.Engine) dao.MediumDomainDao {
  9. return &MediumDomainDb{Db: engine}
  10. }
  11. type MediumDomainDb struct {
  12. Db *xorm.Engine
  13. }
  14. func (m MediumDomainDb) GetMediumDomain(mediumId int) (medium *model.MediumDomain, err error) {
  15. medium = new(model.MediumDomain)
  16. has, err := m.Db.Where("medium_id =?", mediumId).Get(medium)
  17. if err != nil {
  18. return nil, logx.Error(err)
  19. }
  20. if has == false {
  21. return nil, nil
  22. }
  23. return medium, nil
  24. }
  25. func (m MediumDomainDb) MediumDomainInsert(medium *model.MediumDomain) (int64, error) {
  26. insertAffected, err := m.Db.InsertOne(medium)
  27. if err != nil {
  28. return 0, err
  29. }
  30. return insertAffected, nil
  31. }