chat_msg_template.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/enum"
  5. )
  6. var ChatMsgTemplate = &chatMsgTemplateConfig{}
  7. func init() {
  8. _allList = append(_allList, ChatMsgTemplate)
  9. }
  10. type (
  11. ChatMsgTemplateRow struct {
  12. ChatMsgType enum.ChatMsgType `json:"ChatMsgType"` // 消息类型
  13. }
  14. chatMsgTemplateConfig struct {
  15. baseConfig
  16. list []*ChatMsgTemplateRow // all list
  17. chatMsgTypeUniMaps map[enum.ChatMsgType]*ChatMsgTemplateRow // key:chatMsgType
  18. }
  19. )
  20. func (p *chatMsgTemplateConfig) Name() string {
  21. return "chat_msg_template"
  22. }
  23. func (p *chatMsgTemplateConfig) Init() {
  24. p.chatMsgTypeUniMaps = map[enum.ChatMsgType]*ChatMsgTemplateRow{}
  25. }
  26. func (p *chatMsgTemplateConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  27. if reload && p.denyLoad {
  28. return 0, nil
  29. }
  30. var list []*ChatMsgTemplateRow
  31. if err := DecodeData(maps, &list); err != nil {
  32. return 0, err
  33. }
  34. p.list = list
  35. chatMsgTypeUniMaps := map[enum.ChatMsgType]*ChatMsgTemplateRow{}
  36. for _, row := range list {
  37. chatMsgTypeUniMaps[row.ChatMsgType] = row
  38. }
  39. p.chatMsgTypeUniMaps = chatMsgTypeUniMaps
  40. return len(list), nil
  41. }
  42. // func (p *chatMsgTemplateConfig) OnAfterLoad(_ bool) {
  43. // }
  44. func (p *chatMsgTemplateConfig) List() []*ChatMsgTemplateRow {
  45. return p.list
  46. }
  47. func (p *chatMsgTemplateConfig) GetByChatMsgType(chatMsgType enum.ChatMsgType) (*ChatMsgTemplateRow, bool) {
  48. value, found := p.chatMsgTypeUniMaps[chatMsgType]
  49. return value, found
  50. }
  51. func (p *chatMsgTemplateConfig) ContainChatMsgType(chatMsgType enum.ChatMsgType) bool {
  52. _, found := p.chatMsgTypeUniMaps[chatMsgType]
  53. return found
  54. }