year_map.go 681 B

123456789101112131415161718192021222324252627282930313233
  1. package model
  2. import (
  3. "fmt"
  4. "strings"
  5. )
  6. const _yearMapInsertSQL = "INSERT INTO es_year_map(year,aid) VALUES %s"
  7. // YearMap .
  8. type YearMap struct {
  9. ID int64 `json:"id"`
  10. Year int64 `json:"year"`
  11. Aid int64 `json:"aid"`
  12. IsDeleted int `json:"is_deleted"`
  13. }
  14. // TableName es_year_map.
  15. func (y YearMap) TableName() string {
  16. return "es_year_map"
  17. }
  18. // BatchAddYearMapSQL .
  19. func BatchAddYearMapSQL(data []*YearMap) string {
  20. if len(data) == 0 {
  21. return ""
  22. }
  23. var rowStrings []string
  24. for _, v := range data {
  25. rowStrings = append(rowStrings, fmt.Sprintf("(%d,%d)", v.Year, v.Aid))
  26. }
  27. return fmt.Sprintf(_yearMapInsertSQL, strings.Join(rowStrings, ","))
  28. }