// Code generated by excel export. DO NOT EDIT. package data var Area = &areaConfig{} func init() { _allList = append(_allList, Area) } type ( AreaRow struct { Pid int32 `json:"Pid"` // PID AreaID int32 `json:"AreaID"` // 大区ID AreaName string `json:"AreaName"` // 大区名 Gate string `json:"Gate"` // 网关地址 } areaConfig struct { baseConfig list []*AreaRow // all list pidListMaps map[int32][]*AreaRow // key:pid pidAreaIDUniMaps map[int32]map[int32]*AreaRow // key:pid, areaID } ) func (p *areaConfig) Name() string { return "area" } func (p *areaConfig) Init() { p.pidListMaps = map[int32][]*AreaRow{} p.pidAreaIDUniMaps = map[int32]map[int32]*AreaRow{} } func (p *areaConfig) OnLoad(maps interface{}, reload bool) (int, error) { if reload && p.denyLoad { return 0, nil } var list []*AreaRow if err := DecodeData(maps, &list); err != nil { return 0, err } p.list = list pidListMaps := map[int32][]*AreaRow{} for _, row := range list { pidListMaps[row.Pid] = append(pidListMaps[row.Pid], row) } p.pidListMaps = pidListMaps pidAreaIDUniMaps := map[int32]map[int32]*AreaRow{} for _, row := range list { itemMap := pidAreaIDUniMaps[row.Pid] if itemMap == nil { itemMap = map[int32]*AreaRow{} pidAreaIDUniMaps[row.Pid] = itemMap } itemMap[row.AreaID] = row } p.pidAreaIDUniMaps = pidAreaIDUniMaps return len(list), nil } // func (p *areaConfig) OnAfterLoad(_ bool) { // } func (p *areaConfig) List() []*AreaRow { return p.list } func (p *areaConfig) ListByPid(pid int32) ([]*AreaRow, bool) { value, found := p.pidListMaps[pid] return value, found } func (p *areaConfig) ListContainPid(pid int32) bool { _, found := p.pidListMaps[pid] return found } func (p *areaConfig) GetByPidAreaID(pid int32, areaID int32) (*AreaRow, bool) { mapItem, found := p.pidAreaIDUniMaps[pid] if !found { return nil, false } value, found := mapItem[areaID] return value, found } func (p *areaConfig) ContainPidAreaID(pid int32, areaID int32) bool { mapItem, found := p.pidAreaIDUniMaps[pid] if !found { return false } _, found = mapItem[areaID] return found }