storm.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/live/xlottery/model"
  5. "github.com/pkg/errors"
  6. )
  7. // InsertSpecialGift 插入SpecialGift
  8. func (d *Dao) InsertSpecialGift(sg *model.SpecialGift) (int64, error) {
  9. stmt, err := d.db.Prepare("insert into ap_special_gift (uid,room_id,gift_id,gift_num,create_time, custom_field) values (?,?,?,?,?,?) ")
  10. if err != nil {
  11. return 0, errors.WithStack(err)
  12. }
  13. result, err := stmt.Exec(context.TODO(), sg.UID, sg.RoomID, sg.GiftID, sg.GiftNum, sg.CreateTime, sg.CustomField)
  14. if err != nil {
  15. return 0, errors.WithStack(err)
  16. }
  17. return result.LastInsertId()
  18. }
  19. // FindBeatByBeatIDAndUID 根据beatid 和 uid 查询 beat
  20. func (d *Dao) FindBeatByBeatIDAndUID(id, uid int64) (*model.Beat, error) {
  21. row := d.db.QueryRow(context.TODO(), "select id ,uid ,content,status, operator,update_time,ctime ,mtime from ap_user_beats_info where id = ? and uid = ?", id, uid)
  22. var b model.Beat
  23. err := row.Scan(&b.ID, &b.UID, &b.Content, &b.Status, &b.Operator, &b.UpdateTime, &b.Ctime, &b.Mtime)
  24. if err != nil {
  25. return nil, errors.WithStack(err)
  26. }
  27. return &b, nil
  28. }
  29. // FindShieldKeyWorkByUID 根据uid 查找屏蔽词
  30. func (d *Dao) FindShieldKeyWorkByUID(uid int64) ([]*model.ShieldKeyWork, error) {
  31. row, err := d.db.Query(context.TODO(), "select id, uid ,original_keyword, keyword, ctime from ap_shield_keywork where uid = ?", uid)
  32. if err != nil {
  33. return nil, errors.WithStack(err)
  34. }
  35. skArray := make([]*model.ShieldKeyWork, 0)
  36. for row.Next() {
  37. var b model.ShieldKeyWork
  38. err := row.Scan(&b.ID, &b.UID, &b.OriginalKeyword, &b.KeyWord, &b.Ctime)
  39. if err != nil {
  40. return nil, errors.WithStack(err)
  41. }
  42. skArray = append(skArray, &b)
  43. }
  44. return skArray, nil
  45. }