resource.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dao
  2. import (
  3. "go-common/app/job/main/vip/model"
  4. "go-common/library/database/sql"
  5. "github.com/pkg/errors"
  6. )
  7. //GetAbleCode get able code
  8. func (d *Dao) GetAbleCode(tx *sql.Tx, batchCodeID int64) (code string, err error) {
  9. row := tx.QueryRow(_getAbleCodeSQL, batchCodeID)
  10. if err = row.Scan(&code); err != nil {
  11. if err == sql.ErrNoRows {
  12. err = nil
  13. return
  14. }
  15. err = errors.WithStack(err)
  16. }
  17. return
  18. }
  19. //UpdateCodeRelationID update code relationID
  20. func (d *Dao) UpdateCodeRelationID(tx *sql.Tx, code, relationID string, bmid int64) (err error) {
  21. if _, err = tx.Exec(_updateCodeRelationIDSQL, relationID, bmid, code); err != nil {
  22. err = errors.WithStack(err)
  23. }
  24. return
  25. }
  26. //SelBatchCodeByID .
  27. func (d *Dao) SelBatchCodeByID(tx *sql.Tx, batchCodeID int64) (r *model.VipResourceBatchCode, err error) {
  28. row := tx.QueryRow(_selBatchCodeSQL, batchCodeID)
  29. r = new(model.VipResourceBatchCode)
  30. if err = row.Scan(&r.ID, &r.BusinessID, &r.PoolID, &r.Status, &r.Type, &r.BatchName, &r.Reason, &r.Unit, &r.Count, &r.SurplusCount, &r.Price, &r.StartTime, &r.EndTime); err != nil {
  31. if err == sql.ErrNoRows {
  32. err = nil
  33. return
  34. }
  35. err = errors.WithStack(err)
  36. }
  37. return
  38. }