blacklist.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package model
  2. import (
  3. "fmt"
  4. "strings"
  5. "go-common/library/time"
  6. )
  7. const (
  8. //_blacklistBatchAddSQL add blacklist batch sql
  9. _blacklistBatchAddSQL = "INSERT INTO blacklist (`mid`) VALUES %s"
  10. _blacklistBatchUpdateSQL = "UPDATE blacklist SET `status` = 0 WHERE id in (%s)"
  11. //StatusBlack blacklist
  12. StatusBlack = 0
  13. )
  14. // Blacklist .
  15. type Blacklist struct {
  16. ID int64 `json:"id" form:"id"`
  17. Mid int64 `json:"mid" form:"mid"`
  18. Status int `json:"status" form:"status"`
  19. Mtime time.Time `json:"mtime"`
  20. }
  21. //BlacklistPager blacklist pager
  22. type BlacklistPager struct {
  23. Item []*Blacklist
  24. Page Page
  25. }
  26. // BlacklistBatchAddSQL .
  27. func BlacklistBatchAddSQL(mids []int64) string {
  28. if len(mids) == 0 {
  29. return ""
  30. }
  31. var rowStrings []string
  32. for _, mid := range mids {
  33. rowStrings = append(rowStrings, fmt.Sprintf("(%d)", mid))
  34. }
  35. return fmt.Sprintf(_blacklistBatchAddSQL, strings.Join(rowStrings, ","))
  36. }
  37. // BlacklistBatchUpdateSQL .
  38. func BlacklistBatchUpdateSQL(mids []int64) string {
  39. if len(mids) == 0 {
  40. return ""
  41. }
  42. var rowStrings []string
  43. for _, mid := range mids {
  44. rowStrings = append(rowStrings, fmt.Sprintf("%d", mid))
  45. }
  46. return fmt.Sprintf(_blacklistBatchUpdateSQL, strings.Join(rowStrings, ","))
  47. }
  48. // TableName .
  49. func (a Blacklist) TableName() string {
  50. return "blacklist"
  51. }