62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package repository
|
|
|
|
import (
|
|
"joylink.club/rtss-core/example/data_proto"
|
|
modelimpl "joylink.club/rtss-core/example/model_impl"
|
|
"joylink.club/rtss-core/model"
|
|
"joylink.club/rtss-core/repo"
|
|
)
|
|
|
|
// Id映射
|
|
type IdMapping struct {
|
|
GraphicId uint32
|
|
Uid string
|
|
}
|
|
|
|
func NewIdMapping(graphicId uint32, uid string) *IdMapping {
|
|
return &IdMapping{
|
|
GraphicId: graphicId,
|
|
Uid: uid,
|
|
}
|
|
}
|
|
|
|
type Repository struct {
|
|
id string
|
|
StationDataMap map[uint32]*data_proto.Station
|
|
SectionDataMap map[uint32]*data_proto.Section
|
|
TurnoutDataMap map[uint32]*data_proto.Turnout
|
|
IpMapping []*IdMapping
|
|
StationMap map[string]*modelimpl.Station
|
|
SectionMap map[string]*modelimpl.Section
|
|
TurnoutMap map[string]*modelimpl.Turnout
|
|
}
|
|
|
|
func NewRepository(id string) repo.Repo {
|
|
return &Repository{
|
|
id: id,
|
|
StationDataMap: make(map[uint32]*data_proto.Station),
|
|
SectionDataMap: make(map[uint32]*data_proto.Section),
|
|
TurnoutDataMap: make(map[uint32]*data_proto.Turnout),
|
|
IpMapping: make([]*IdMapping, 0),
|
|
StationMap: make(map[string]*modelimpl.Station),
|
|
SectionMap: make(map[string]*modelimpl.Section),
|
|
TurnoutMap: make(map[string]*modelimpl.Turnout),
|
|
}
|
|
}
|
|
|
|
func (r *Repository) Id() string {
|
|
return r.id
|
|
}
|
|
|
|
func (r *Repository) GetStationByUid(uid string) model.Station {
|
|
return r.StationMap[uid]
|
|
}
|
|
|
|
func (r *Repository) GetSectionByUid(uid string) model.Section {
|
|
return r.SectionMap[uid]
|
|
}
|
|
|
|
func (r *Repository) GetTurnoutByUid(uid string) model.Turnout {
|
|
return r.TurnoutMap[uid]
|
|
}
|