【权限操作、仿真管理socket】

This commit is contained in:
weizhihong 2023-08-30 13:25:57 +08:00
parent 5307bc7bb1
commit 78c81a9228
18 changed files with 788 additions and 90 deletions

View File

@ -163,7 +163,12 @@ func updateRoleInfo(c *gin.Context) {
return
}
int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.UpdateAuthRole(int32(int64Id), &req))
rid := int32(int64Id)
result := service.UpdateAuthRole(rid, &req)
if result {
middleware.ClearUserPermissionByRid(rid)
}
c.JSON(http.StatusOK, result)
}
// 删除角色信息
@ -190,7 +195,12 @@ func deleteRoleInfo(c *gin.Context) {
}
zap.S().Debug("传入参数id为" + id)
int64Id, _ := strconv.ParseInt(id, 10, 64)
c.JSON(http.StatusOK, service.DeleteAuthRole(int32(int64Id)))
rid := int32(int64Id)
result := service.DeleteAuthRole(rid)
if result {
middleware.ClearUserPermissionByRid(rid)
}
c.JSON(http.StatusOK, result)
}
// 分页查询接口路径信息
@ -377,5 +387,9 @@ func assignRoleToUser(c *gin.Context) {
c.JSON(http.StatusBadRequest, "保存参数出错")
return
}
c.JSON(http.StatusOK, service.UserLinkRole(&req))
result := service.UserLinkRole(&req)
if result {
middleware.ClearUserPermission(req.Uid)
}
c.JSON(http.StatusOK, result)
}

View File

@ -64,7 +64,7 @@ func pageQueryProject(c *gin.Context) {
// @Accept json
// @Produce json
// @Param ProjectReqDto query dto.ProjectReqDto true "项目查询条件"
// @Success 200 {object} dto.PageDto
// @Success 200 {object} model.Project
// @Failure 401 {object} dto.ErrorDto
// @Failure 404 {object} dto.ErrorDto
// @Failure 500 {object} dto.ErrorDto

View File

@ -22,6 +22,7 @@ import (
func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
authed := api.Group("/v1/simulation").Use(authMiddleware.MiddlewareFunc(), middleware.PermissMiddleware)
authed.POST("/create", create)
authed.POST("/createByProject", createByProjectId)
authed.GET("/state/:id", findSimulationState)
authed.POST("/destroy/:id", destroy)
authed.GET("/list", findAllSimulations)
@ -33,6 +34,7 @@ func InitSimulationRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
// 初始化地图信息
initPublishMapInfo()
apiproto.RegisterMsgServer(&apiproto.SimulationServer{})
apiproto.RegisterMsgServer(&apiproto.MemoryChangeServer{})
}
func initPublishMapInfo() {
@ -61,7 +63,6 @@ func initPublishMapInfo() {
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/create [post]
func create(c *gin.Context) {
//user,_:=c.Get(middleware.IdentityKey)
req := dto.SimulationCreateReqDto{}
if err := c.ShouldBind(&req); nil != err {
panic(err)
@ -70,7 +71,40 @@ func create(c *gin.Context) {
rsp := dto.SimulationCreateRspDto{
MapId: req.MapId,
}
rsp.SimulationId = simulation.CreateSimulation(req.MapId)
rsp.SimulationId = simulation.CreateSimulation(req.MapId, req.ProjectId)
c.JSON(http.StatusOK, &rsp)
}
// 创建ATS测试仿真通过项目ID
//
// @Summary 创建ATS测试仿真
//
// @Security JwtAuth
//
// @Description 创建ATS测试仿真通过项目ID
// @Tags ATS测试仿真Api
// @Accept json
// @Produce json
// @Param Authorization header string true "JWT Token"
// @Param SimulationCreateReqDto body dto.SimulationCreateReqDto true "创建仿真请求"
// @Success 200 {object} dto.SimulationCreateRspDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/createByProject [post]
func createByProjectId(c *gin.Context) {
req := dto.SimulationCreateReqDto{}
if err := c.ShouldBind(&req); nil != err {
panic(err)
}
zap.S().Debug("创建仿真请求:", req)
rsp := dto.SimulationCreateRspDto{
ProjectId: req.ProjectId,
}
mapInfos := service.QueryPublishedGi(req.ProjectId)
if len(mapInfos) == 0 {
panic(dto.ErrorDto{Code: dto.DataNotExist, Message: "项目未关联地图"})
}
mapInfo := mapInfos[0]
rsp.SimulationId = simulation.CreateSimulation(mapInfo.ID, req.ProjectId)
c.JSON(http.StatusOK, &rsp)
}
@ -85,10 +119,10 @@ func create(c *gin.Context) {
// @Accept json
// @Produce json
// @Param Authorization header string true "JWT Token"
// @Param SimulationCreateReqDto body dto.SimulationCreateReqDto true "创建仿真请求"
// @Param id path int true "仿真id"
// @Success 200 {object} dto.SimulationCreateRspDto
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/create [post]
// @Router /api/v1/simulation/state/:id [get]
func findSimulationState(c *gin.Context) {
simId := c.Param("id")
simulation := checkDeviceDataAndReturn(simId)
@ -124,13 +158,12 @@ func destroy(c *gin.Context) {
//
// @Security JwtAuth
//
// @Description ATS测试仿真-添加列车
// @Description 获取ATS测试系统所有仿真实例的基本信息
// @Tags ATS测试仿真Api
// @Accept json
// @Produce json
// @Param Authorization header string true "JWT Token"
//
// @Success 200 {object} dto.SimulationInfoRepDtoArr
// @Success 200 {object} dto.SimulationInfoRspDtoArr
// @Failure 500 {object} dto.ErrorDto
// @Router /api/v1/simulation/list [get]
func findAllSimulations(c *gin.Context) {
@ -145,7 +178,7 @@ func findAllSimulations(c *gin.Context) {
//
// @Security JwtAuth
//
// @Description ATS测试仿真-添加列车
// @Description 地图数据校验
// @Tags ATS测试仿真Api
// @Accept json
// @Produce json
@ -241,7 +274,7 @@ func removeTrain(c *gin.Context) {
//
// @Security JwtAuth
//
// @Description ATS测试仿真-添加列车
// @Description ATS测试-操作道岔
// @Tags ATS测试仿真Api
// @Accept json
// @Produce json

View File

@ -27,6 +27,8 @@ const (
PictureType_StationLayout PictureType = 0
// * Psl界面
PictureType_Psl PictureType = 1
// * 继电器柜界面
PictureType_RelayCabinetLayout PictureType = 2
)
// Enum value maps for PictureType.
@ -34,10 +36,12 @@ var (
PictureType_name = map[int32]string{
0: "StationLayout",
1: "Psl",
2: "RelayCabinetLayout",
}
PictureType_value = map[string]int32{
"StationLayout": 0,
"Psl": 1,
"RelayCabinetLayout": 2,
}
)
@ -72,12 +76,13 @@ var File_picture_proto protoreflect.FileDescriptor
var file_picture_proto_rawDesc = []byte{
0x0a, 0x0d, 0x70, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a,
0x29, 0x0a, 0x0b, 0x50, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x11,
0x41, 0x0a, 0x0b, 0x50, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x11,
0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x10,
0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x73, 0x6c, 0x10, 0x01, 0x42, 0x21, 0x5a, 0x1f, 0x2e, 0x2f,
0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x73, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x73, 0x6c, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x65,
0x6c, 0x61, 0x79, 0x43, 0x61, 0x62, 0x69, 0x6e, 0x65, 0x74, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74,
0x10, 0x02, 0x42, 0x21, 0x5a, 0x1f, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69,
0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69,
0x63, 0x44, 0x61, 0x74, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -20,12 +20,64 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type PslElementColor int32
const (
PslElementColor_red PslElementColor = 0
PslElementColor_green PslElementColor = 1
PslElementColor_blue PslElementColor = 2
)
// Enum value maps for PslElementColor.
var (
PslElementColor_name = map[int32]string{
0: "red",
1: "green",
2: "blue",
}
PslElementColor_value = map[string]int32{
"red": 0,
"green": 1,
"blue": 2,
}
)
func (x PslElementColor) Enum() *PslElementColor {
p := new(PslElementColor)
*p = x
return p
}
func (x PslElementColor) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (PslElementColor) Descriptor() protoreflect.EnumDescriptor {
return file_pslGraphics_proto_enumTypes[0].Descriptor()
}
func (PslElementColor) Type() protoreflect.EnumType {
return &file_pslGraphics_proto_enumTypes[0]
}
func (x PslElementColor) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use PslElementColor.Descriptor instead.
func (PslElementColor) EnumDescriptor() ([]byte, []int) {
return file_pslGraphics_proto_rawDescGZIP(), []int{0}
}
type PslGraphicStorage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Psllights []*PslLight `protobuf:"bytes,1,rep,name=psllights,proto3" json:"psllights,omitempty"` // psl圆形灯
Canvas *Canvas `protobuf:"bytes,1,opt,name=canvas,proto3" json:"canvas,omitempty"`
PslLights []*PslLight `protobuf:"bytes,2,rep,name=pslLights,proto3" json:"pslLights,omitempty"` // psl圆形灯
PslButtons []*PslButton `protobuf:"bytes,3,rep,name=pslButtons,proto3" json:"pslButtons,omitempty"`
PslKeys []*PslKey `protobuf:"bytes,4,rep,name=pslKeys,proto3" json:"pslKeys,omitempty"`
}
func (x *PslGraphicStorage) Reset() {
@ -60,9 +112,30 @@ func (*PslGraphicStorage) Descriptor() ([]byte, []int) {
return file_pslGraphics_proto_rawDescGZIP(), []int{0}
}
func (x *PslGraphicStorage) GetPsllights() []*PslLight {
func (x *PslGraphicStorage) GetCanvas() *Canvas {
if x != nil {
return x.Psllights
return x.Canvas
}
return nil
}
func (x *PslGraphicStorage) GetPslLights() []*PslLight {
if x != nil {
return x.PslLights
}
return nil
}
func (x *PslGraphicStorage) GetPslButtons() []*PslButton {
if x != nil {
return x.PslButtons
}
return nil
}
func (x *PslGraphicStorage) GetPslKeys() []*PslKey {
if x != nil {
return x.PslKeys
}
return nil
}
@ -75,6 +148,8 @@ type PslLight struct {
Common *CommonInfo `protobuf:"bytes,1,opt,name=common,proto3" json:"common,omitempty"`
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
TopAnnotation string `protobuf:"bytes,3,opt,name=topAnnotation,proto3" json:"topAnnotation,omitempty"`
LightColor PslElementColor `protobuf:"varint,4,opt,name=lightColor,proto3,enum=pslGraphicData.PslElementColor" json:"lightColor,omitempty"`
}
func (x *PslLight) Reset() {
@ -123,6 +198,164 @@ func (x *PslLight) GetCode() string {
return ""
}
func (x *PslLight) GetTopAnnotation() string {
if x != nil {
return x.TopAnnotation
}
return ""
}
func (x *PslLight) GetLightColor() PslElementColor {
if x != nil {
return x.LightColor
}
return PslElementColor_red
}
// * PSL按钮
type PslButton struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Common *CommonInfo `protobuf:"bytes,1,opt,name=common,proto3" json:"common,omitempty"`
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
TopAnnotation string `protobuf:"bytes,3,opt,name=topAnnotation,proto3" json:"topAnnotation,omitempty"`
ButtonColor PslElementColor `protobuf:"varint,4,opt,name=buttonColor,proto3,enum=pslGraphicData.PslElementColor" json:"buttonColor,omitempty"`
}
func (x *PslButton) Reset() {
*x = PslButton{}
if protoimpl.UnsafeEnabled {
mi := &file_pslGraphics_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PslButton) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PslButton) ProtoMessage() {}
func (x *PslButton) ProtoReflect() protoreflect.Message {
mi := &file_pslGraphics_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PslButton.ProtoReflect.Descriptor instead.
func (*PslButton) Descriptor() ([]byte, []int) {
return file_pslGraphics_proto_rawDescGZIP(), []int{2}
}
func (x *PslButton) GetCommon() *CommonInfo {
if x != nil {
return x.Common
}
return nil
}
func (x *PslButton) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
func (x *PslButton) GetTopAnnotation() string {
if x != nil {
return x.TopAnnotation
}
return ""
}
func (x *PslButton) GetButtonColor() PslElementColor {
if x != nil {
return x.ButtonColor
}
return PslElementColor_red
}
// * PSL钥匙
type PslKey struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Common *CommonInfo `protobuf:"bytes,1,opt,name=common,proto3" json:"common,omitempty"`
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
TopAnnotation string `protobuf:"bytes,3,opt,name=topAnnotation,proto3" json:"topAnnotation,omitempty"`
RightAnnotation string `protobuf:"bytes,4,opt,name=rightAnnotation,proto3" json:"rightAnnotation,omitempty"`
}
func (x *PslKey) Reset() {
*x = PslKey{}
if protoimpl.UnsafeEnabled {
mi := &file_pslGraphics_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PslKey) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PslKey) ProtoMessage() {}
func (x *PslKey) ProtoReflect() protoreflect.Message {
mi := &file_pslGraphics_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PslKey.ProtoReflect.Descriptor instead.
func (*PslKey) Descriptor() ([]byte, []int) {
return file_pslGraphics_proto_rawDescGZIP(), []int{3}
}
func (x *PslKey) GetCommon() *CommonInfo {
if x != nil {
return x.Common
}
return nil
}
func (x *PslKey) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
func (x *PslKey) GetTopAnnotation() string {
if x != nil {
return x.TopAnnotation
}
return ""
}
func (x *PslKey) GetRightAnnotation() string {
if x != nil {
return x.RightAnnotation
}
return ""
}
var File_pslGraphics_proto protoreflect.FileDescriptor
var file_pslGraphics_proto_rawDesc = []byte{
@ -130,16 +363,57 @@ var file_pslGraphics_proto_rawDesc = []byte{
0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44,
0x61, 0x74, 0x61, 0x1a, 0x1b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x61, 0x79, 0x6f,
0x75, 0x74, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0x4b, 0x0a, 0x11, 0x50, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x53, 0x74,
0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x70, 0x73, 0x6c, 0x6c, 0x69, 0x67, 0x68,
0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x73, 0x6c, 0x47, 0x72,
0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x73, 0x6c, 0x4c, 0x69, 0x67,
0x68, 0x74, 0x52, 0x09, 0x70, 0x73, 0x6c, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x22, 0x4f, 0x0a,
0x08, 0x50, 0x73, 0x6c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2f, 0x0a, 0x06, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x72, 0x61, 0x70,
0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x49, 0x6e,
0x66, 0x6f, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f,
0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x21,
0x22, 0xe5, 0x01, 0x0a, 0x11, 0x50, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x53,
0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x2b, 0x0a, 0x06, 0x63, 0x61, 0x6e, 0x76, 0x61, 0x73,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63,
0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x61, 0x6e, 0x76, 0x61, 0x73, 0x52, 0x06, 0x63, 0x61, 0x6e,
0x76, 0x61, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x70, 0x73, 0x6c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x73,
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70,
0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x73, 0x6c, 0x4c, 0x69, 0x67, 0x68, 0x74,
0x52, 0x09, 0x70, 0x73, 0x6c, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x70,
0x73, 0x6c, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x19, 0x2e, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61,
0x2e, 0x50, 0x73, 0x6c, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x73, 0x6c, 0x42,
0x75, 0x74, 0x74, 0x6f, 0x6e, 0x73, 0x12, 0x30, 0x0a, 0x07, 0x70, 0x73, 0x6c, 0x4b, 0x65, 0x79,
0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61,
0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x73, 0x6c, 0x4b, 0x65, 0x79, 0x52,
0x07, 0x70, 0x73, 0x6c, 0x4b, 0x65, 0x79, 0x73, 0x22, 0xb6, 0x01, 0x0a, 0x08, 0x50, 0x73, 0x6c,
0x4c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2f, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44,
0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06,
0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x6f,
0x70, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0d, 0x74, 0x6f, 0x70, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x3f, 0x0a, 0x0a, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x04,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69,
0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x50, 0x73, 0x6c, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74,
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x52, 0x0a, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x43, 0x6f, 0x6c, 0x6f,
0x72, 0x22, 0xb9, 0x01, 0x0a, 0x09, 0x50, 0x73, 0x6c, 0x42, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x12,
0x2f, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x17, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f,
0x6d, 0x6d, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x63, 0x6f, 0x64, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x6f, 0x70, 0x41, 0x6e, 0x6e, 0x6f, 0x74,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x6f, 0x70,
0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x0b, 0x62, 0x75,
0x74, 0x74, 0x6f, 0x6e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32,
0x1f, 0x2e, 0x70, 0x73, 0x6c, 0x47, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74, 0x61,
0x2e, 0x50, 0x73, 0x6c, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x52, 0x0b, 0x62, 0x75, 0x74, 0x74, 0x6f, 0x6e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x22, 0x9d, 0x01,
0x0a, 0x06, 0x50, 0x73, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x2f, 0x0a, 0x06, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68,
0x69, 0x63, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x49, 0x6e, 0x66,
0x6f, 0x52, 0x06, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x24, 0x0a,
0x0d, 0x74, 0x6f, 0x70, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x6f, 0x70, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x69, 0x67, 0x68, 0x74, 0x41, 0x6e, 0x6e, 0x6f,
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x69,
0x67, 0x68, 0x74, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x2f, 0x0a,
0x0f, 0x50, 0x73, 0x6c, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
0x12, 0x07, 0x0a, 0x03, 0x72, 0x65, 0x64, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x67, 0x72, 0x65,
0x65, 0x6e, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x62, 0x6c, 0x75, 0x65, 0x10, 0x02, 0x42, 0x21,
0x5a, 0x1f, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x44, 0x61, 0x74,
0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
@ -157,20 +431,32 @@ func file_pslGraphics_proto_rawDescGZIP() []byte {
return file_pslGraphics_proto_rawDescData
}
var file_pslGraphics_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_pslGraphics_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_pslGraphics_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_pslGraphics_proto_goTypes = []interface{}{
(*PslGraphicStorage)(nil), // 0: pslGraphicData.PslGraphicStorage
(*PslLight)(nil), // 1: pslGraphicData.PslLight
(*CommonInfo)(nil), // 2: graphicData.CommonInfo
(PslElementColor)(0), // 0: pslGraphicData.PslElementColor
(*PslGraphicStorage)(nil), // 1: pslGraphicData.PslGraphicStorage
(*PslLight)(nil), // 2: pslGraphicData.PslLight
(*PslButton)(nil), // 3: pslGraphicData.PslButton
(*PslKey)(nil), // 4: pslGraphicData.PslKey
(*Canvas)(nil), // 5: graphicData.Canvas
(*CommonInfo)(nil), // 6: graphicData.CommonInfo
}
var file_pslGraphics_proto_depIdxs = []int32{
1, // 0: pslGraphicData.PslGraphicStorage.psllights:type_name -> pslGraphicData.PslLight
2, // 1: pslGraphicData.PslLight.common:type_name -> graphicData.CommonInfo
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
5, // 0: pslGraphicData.PslGraphicStorage.canvas:type_name -> graphicData.Canvas
2, // 1: pslGraphicData.PslGraphicStorage.pslLights:type_name -> pslGraphicData.PslLight
3, // 2: pslGraphicData.PslGraphicStorage.pslButtons:type_name -> pslGraphicData.PslButton
4, // 3: pslGraphicData.PslGraphicStorage.pslKeys:type_name -> pslGraphicData.PslKey
6, // 4: pslGraphicData.PslLight.common:type_name -> graphicData.CommonInfo
0, // 5: pslGraphicData.PslLight.lightColor:type_name -> pslGraphicData.PslElementColor
6, // 6: pslGraphicData.PslButton.common:type_name -> graphicData.CommonInfo
0, // 7: pslGraphicData.PslButton.buttonColor:type_name -> pslGraphicData.PslElementColor
6, // 8: pslGraphicData.PslKey.common:type_name -> graphicData.CommonInfo
9, // [9:9] is the sub-list for method output_type
9, // [9:9] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
}
func init() { file_pslGraphics_proto_init() }
@ -204,19 +490,44 @@ func file_pslGraphics_proto_init() {
return nil
}
}
file_pslGraphics_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PslButton); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_pslGraphics_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PslKey); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pslGraphics_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumEnums: 1,
NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_pslGraphics_proto_goTypes,
DependencyIndexes: file_pslGraphics_proto_depIdxs,
EnumInfos: file_pslGraphics_proto_enumTypes,
MessageInfos: file_pslGraphics_proto_msgTypes,
}.Build()
File_pslGraphics_proto = out.File

View File

@ -1261,6 +1261,134 @@ func (x *PushedDevicesStatus) GetAllStatus() *AllDevicesStatus {
return nil
}
// 仿真信息状态
type SimulationStatus struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SimulationId string `protobuf:"bytes,1,opt,name=simulationId,proto3" json:"simulationId,omitempty"`
MapId int32 `protobuf:"varint,2,opt,name=mapId,proto3" json:"mapId,omitempty"`
ProjectId int32 `protobuf:"varint,3,opt,name=projectId,proto3" json:"projectId,omitempty"`
}
func (x *SimulationStatus) Reset() {
*x = SimulationStatus{}
if protoimpl.UnsafeEnabled {
mi := &file_device_state_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *SimulationStatus) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SimulationStatus) ProtoMessage() {}
func (x *SimulationStatus) ProtoReflect() protoreflect.Message {
mi := &file_device_state_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SimulationStatus.ProtoReflect.Descriptor instead.
func (*SimulationStatus) Descriptor() ([]byte, []int) {
return file_device_state_proto_rawDescGZIP(), []int{12}
}
func (x *SimulationStatus) GetSimulationId() string {
if x != nil {
return x.SimulationId
}
return ""
}
func (x *SimulationStatus) GetMapId() int32 {
if x != nil {
return x.MapId
}
return 0
}
func (x *SimulationStatus) GetProjectId() int32 {
if x != nil {
return x.ProjectId
}
return 0
}
// 变更信息状态
type MemoryDataStatus struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
AllSimulations []*SimulationStatus `protobuf:"bytes,1,rep,name=allSimulations,proto3" json:"allSimulations,omitempty"`
AddSimulations []*SimulationStatus `protobuf:"bytes,2,rep,name=addSimulations,proto3" json:"addSimulations,omitempty"`
RemoveSimulations []*SimulationStatus `protobuf:"bytes,3,rep,name=removeSimulations,proto3" json:"removeSimulations,omitempty"`
}
func (x *MemoryDataStatus) Reset() {
*x = MemoryDataStatus{}
if protoimpl.UnsafeEnabled {
mi := &file_device_state_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MemoryDataStatus) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MemoryDataStatus) ProtoMessage() {}
func (x *MemoryDataStatus) ProtoReflect() protoreflect.Message {
mi := &file_device_state_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use MemoryDataStatus.ProtoReflect.Descriptor instead.
func (*MemoryDataStatus) Descriptor() ([]byte, []int) {
return file_device_state_proto_rawDescGZIP(), []int{13}
}
func (x *MemoryDataStatus) GetAllSimulations() []*SimulationStatus {
if x != nil {
return x.AllSimulations
}
return nil
}
func (x *MemoryDataStatus) GetAddSimulations() []*SimulationStatus {
if x != nil {
return x.AddSimulations
}
return nil
}
func (x *MemoryDataStatus) GetRemoveSimulations() []*SimulationStatus {
if x != nil {
return x.RemoveSimulations
}
return nil
}
var File_device_state_proto protoreflect.FileDescriptor
var file_device_state_proto_rawDesc = []byte{
@ -1457,16 +1585,37 @@ var file_device_state_proto_rawDesc = []byte{
0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x41, 0x6c, 0x6c, 0x44, 0x65, 0x76, 0x69,
0x63, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x61, 0x6c, 0x6c, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x2a, 0x37, 0x0a, 0x0b, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54,
0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x6e, 0x79, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04,
0x41, 0x78, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10,
0x02, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x68, 0x79, 0x73, 0x69, 0x63, 0x10, 0x03, 0x42, 0x54, 0x0a,
0x25, 0x63, 0x6c, 0x75, 0x62, 0x2e, 0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x62, 0x6a,
0x72, 0x74, 0x73, 0x73, 0x2e, 0x61, 0x74, 0x73, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x42, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74,
0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x5a, 0x19, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f,
0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x74,
0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x61, 0x74, 0x75, 0x73, 0x22, 0x6a, 0x0a, 0x10, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x69, 0x6d, 0x75,
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c,
0x73, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05,
0x6d, 0x61, 0x70, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6d, 0x61, 0x70,
0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x18,
0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64,
0x22, 0xdb, 0x01, 0x0a, 0x10, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x53, 0x69, 0x6d, 0x75,
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e,
0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0e, 0x61, 0x6c, 0x6c, 0x53, 0x69, 0x6d, 0x75, 0x6c,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x61, 0x64, 0x64, 0x53, 0x69, 0x6d,
0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17,
0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0e, 0x61, 0x64, 0x64, 0x53, 0x69, 0x6d, 0x75,
0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x45, 0x0a, 0x11, 0x72, 0x65, 0x6d, 0x6f, 0x76,
0x65, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x17, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2e, 0x53, 0x69, 0x6d, 0x75, 0x6c,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x11, 0x72, 0x65, 0x6d,
0x6f, 0x76, 0x65, 0x53, 0x69, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2a, 0x37,
0x0a, 0x0b, 0x53, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a,
0x03, 0x41, 0x6e, 0x79, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x78, 0x6c, 0x65, 0x10, 0x01,
0x12, 0x09, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x50,
0x68, 0x79, 0x73, 0x69, 0x63, 0x10, 0x03, 0x42, 0x54, 0x0a, 0x25, 0x63, 0x6c, 0x75, 0x62, 0x2e,
0x6a, 0x6f, 0x79, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x62, 0x6a, 0x72, 0x74, 0x73, 0x73, 0x2e, 0x61,
0x74, 0x73, 0x2e, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
0x42, 0x10, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x5a, 0x19, 0x2e, 0x2f, 0x61, 0x74, 0x73, 0x2f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -1482,7 +1631,7 @@ func file_device_state_proto_rawDescGZIP() []byte {
}
var file_device_state_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_device_state_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_device_state_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_device_state_proto_goTypes = []interface{}{
(SectionType)(0), // 0: state.SectionType
(*LinkState)(nil), // 1: state.LinkState
@ -1497,6 +1646,8 @@ var file_device_state_proto_goTypes = []interface{}{
(*VariationStatus)(nil), // 10: state.VariationStatus
(*AllDevicesStatus)(nil), // 11: state.AllDevicesStatus
(*PushedDevicesStatus)(nil), // 12: state.PushedDevicesStatus
(*SimulationStatus)(nil), // 13: state.SimulationStatus
(*MemoryDataStatus)(nil), // 14: state.MemoryDataStatus
}
var file_device_state_proto_depIdxs = []int32{
0, // 0: state.SectionState.type:type_name -> state.SectionType
@ -1510,11 +1661,14 @@ var file_device_state_proto_depIdxs = []int32{
2, // 8: state.AllDevicesStatus.sectionState:type_name -> state.SectionState
10, // 9: state.PushedDevicesStatus.varStatus:type_name -> state.VariationStatus
11, // 10: state.PushedDevicesStatus.allStatus:type_name -> state.AllDevicesStatus
11, // [11:11] is the sub-list for method output_type
11, // [11:11] is the sub-list for method input_type
11, // [11:11] is the sub-list for extension type_name
11, // [11:11] is the sub-list for extension extendee
0, // [0:11] is the sub-list for field type_name
13, // 11: state.MemoryDataStatus.allSimulations:type_name -> state.SimulationStatus
13, // 12: state.MemoryDataStatus.addSimulations:type_name -> state.SimulationStatus
13, // 13: state.MemoryDataStatus.removeSimulations:type_name -> state.SimulationStatus
14, // [14:14] is the sub-list for method output_type
14, // [14:14] is the sub-list for method input_type
14, // [14:14] is the sub-list for extension type_name
14, // [14:14] is the sub-list for extension extendee
0, // [0:14] is the sub-list for field type_name
}
func init() { file_device_state_proto_init() }
@ -1667,6 +1821,30 @@ func file_device_state_proto_init() {
return nil
}
}
file_device_state_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SimulationStatus); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_device_state_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MemoryDataStatus); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -1674,7 +1852,7 @@ func file_device_state_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_device_state_proto_rawDesc,
NumEnums: 1,
NumMessages: 12,
NumMessages: 14,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -82,11 +82,11 @@ func init() {
var simulationMap sync.Map
// 创建仿真对象
func CreateSimulation(mapId int32) string {
func CreateSimulation(mapId, projectId int32) string {
simulationId := createSimulationId(mapId)
_, e := simulationMap.Load(simulationId)
if !e {
verifySimulation := memory.CreateSimulation(mapId, simulationId)
verifySimulation := memory.CreateSimulation(mapId, projectId, simulationId)
//通知动力学
httpCode, _, err := dynamics.SendSimulationStartReq(buildLineBaseInfo(memory.QueryMapVerifyStructure(verifySimulation.MapId)))
if httpCode != http.StatusOK || err != nil {
@ -117,13 +117,14 @@ func createSimulationId(mapId int32) string {
}
// 获取仿真列表
func ListAllSimulations() []*dto.SimulationInfoRepDto {
simArr := []*dto.SimulationInfoRepDto{}
func ListAllSimulations() []*dto.SimulationInfoRspDto {
simArr := []*dto.SimulationInfoRspDto{}
simulationMap.Range(func(_, v any) bool {
s := v.(*memory.VerifySimulation)
simArr = append(simArr, &dto.SimulationInfoRepDto{
simArr = append(simArr, &dto.SimulationInfoRspDto{
SimulationId: s.SimulationId,
MapId: strconv.Itoa(int(s.MapId)),
MapId: s.MapId,
ProjectId: s.ProjectId,
})
return true
})

View File

@ -8,6 +8,8 @@ import (
type VerifySimulation struct {
//地图id
MapId int32
// 项目ID
ProjectId int32
//仿真id
SimulationId string
//仿真内存数据
@ -15,10 +17,11 @@ type VerifySimulation struct {
}
// 创建仿真对象
func CreateSimulation(mapId int32, simulationId string) *VerifySimulation {
func CreateSimulation(mapId, projectId int32, simulationId string) *VerifySimulation {
m := &WaysideMemory{}
verifySimulation := &VerifySimulation{
MapId: mapId,
ProjectId: projectId,
SimulationId: simulationId,
Memory: m.Create(),
}

@ -1 +1 @@
Subproject commit e8d0e1e67593db6463c0b36870a6865e380e7a9e
Subproject commit e33f466f120e257e2b6a30e8d85281aad5f21ec1

View File

@ -56,6 +56,7 @@ const (
)
type AuthUserStorageDto struct {
UID int32 `json:"uid" form:"uid"`
IsAdmin bool `json:"isAdmin" form:"isAdmin"`
RoleIds []int32 `json:"roleIds" form:"roleIds"`
AuthPaths []*AuthPath `json:"authPath" form:"authPath"`

View File

@ -4,12 +4,16 @@ package dto
type SimulationCreateReqDto struct {
//地图id
MapId int32 `json:"mapId" form:"mapId"`
// 项目id
ProjectId int32 `json:"projectId" form:"projectId"`
}
// 创建仿真响应
type SimulationCreateRspDto struct {
//地图id
MapId int32 `json:"mapId" form:"mapId"`
// 项目ID
ProjectId int32 `json:"projectId" form:"projectId"`
//仿真id
SimulationId string `json:"simulationId" form:"simulationId"`
}
@ -72,8 +76,9 @@ type CheckMapDataRspDto struct {
}
// 仿真实例的基本信息响应
type SimulationInfoRepDto struct {
type SimulationInfoRspDto struct {
SimulationId string `form:"simulationId" json:"simulationId"`
MapId string `form:"mapId" json:"mapId"`
MapId int32 `form:"mapId" json:"mapId"`
ProjectId int32 `form:"projectId" json:"projectId"`
}
type SimulationInfoRepDtoArr []SimulationInfoRepDto
type SimulationInfoRspDtoArr []SimulationInfoRspDto

View File

@ -1,6 +1,10 @@
package dto
import "joylink.club/bj-rtsts-server/db/model"
import (
"time"
"joylink.club/bj-rtsts-server/db/model"
)
// 分页查询用户请求
type PageUserReqDto struct {
@ -12,3 +16,11 @@ type PageUserReqDto struct {
}
type RegisterUser = model.User
type UserRspDto struct {
ID int32 `json:"id" form:"id"`
Name string `json:"name" form:"name"` // 名字
Mobile string `json:"mobile" form:"mobile"` // 手机号
RegisterTime time.Time `json:"register_time" form:"register_time"` // 注册时间
Roles []*AuthRoleRspDto `json:"roles" form:"roles"`
}

View File

@ -0,0 +1,70 @@
package apiproto
import (
"time"
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/ats/verify/protos/state"
"joylink.club/bj-rtsts-server/ats/verify/simulation"
)
type MemoryChangeServer struct {
simulationMap map[string]*state.SimulationStatus
}
// 返回通道格式
func (t *MemoryChangeServer) getChannelName() string {
return "memory-data-change"
}
// 消息运行间隔
func (t *MemoryChangeServer) getInterval() time.Duration {
return 1 * time.Second
}
// 返回所有数据
func (t *MemoryChangeServer) allMsgData(params map[string]string) []byte {
arr := make([]*state.SimulationStatus, len(t.simulationMap))
i := 0
for _, v := range t.simulationMap {
arr[i] = v
i++
}
msg := &state.MemoryDataStatus{AllSimulations: arr}
data, err := proto.Marshal(msg)
if err != nil {
panic(err)
}
return data
}
// 定时发送数据
func (t *MemoryChangeServer) onTick() []TopicMsg {
simArr := simulation.GetSimulationArr()
addArr, delArr := []*state.SimulationStatus{}, []*state.SimulationStatus{}
// 增加的仿真
allSim := make(map[string]bool)
for _, v := range simArr {
allSim[v.SimulationId] = true
if t.simulationMap[v.SimulationId] == nil {
addArr = append(addArr, &state.SimulationStatus{
SimulationId: v.SimulationId,
MapId: v.MapId,
ProjectId: v.ProjectId,
})
}
}
// 已经移除的仿真
for k, v := range t.simulationMap {
if !allSim[k] {
delArr = append(delArr, v)
}
}
msg := &state.MemoryDataStatus{AddSimulations: addArr, RemoveSimulations: delArr}
b, err := proto.Marshal(msg)
if err != nil {
panic(err)
}
msgArr := []TopicMsg{{channalName: t.getChannelName(), data: b}}
return msgArr
}

View File

@ -4,7 +4,7 @@ import (
"strings"
"time"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"joylink.club/bj-rtsts-server/ats/verify/simulation"
)

View File

@ -73,6 +73,24 @@ func validateUserPath(path, method string, paths []*dto.AuthPath) bool {
}
// 重新登录时移除权限
func clearUserPermission(userId int32) {
func ClearUserPermission(userId int32) {
delete(userAuthPathMap, userId)
}
// 修改角色后清理用户权限
func ClearUserPermissionByRid(roleId int32) {
uids := []int32{}
for uid, u := range userAuthPathMap {
for _, r := range u.RoleIds {
if r == roleId {
uids = append(uids, uid)
break
}
}
}
if len(uids) > 0 {
for _, uid := range uids {
ClearUserPermission(uid)
}
}
}

View File

@ -52,7 +52,7 @@ func InitGinJwtMiddleware() (authMiddleware *jwt.GinJWTMiddleware) {
return nil, jwt.ErrFailedAuthentication
}
// 清理权限
clearUserPermission(user.ID)
ClearUserPermission(user.ID)
return user, nil
},
// Authorizator: func(data interface{}, c *gin.Context) bool {

View File

@ -238,7 +238,7 @@ func QueryUserAuthApiPath(uid int32) *dto.AuthUserStorageDto {
if err1 != nil {
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err1.Error()})
}
authUser := &dto.AuthUserStorageDto{IsAdmin: false}
authUser := &dto.AuthUserStorageDto{UID: uid, IsAdmin: false}
rn := len(linkRids)
if rn > 0 {
rids := make([]int32, rn)

View File

@ -2,10 +2,12 @@ package service
import (
"fmt"
"time"
"go.uber.org/zap"
"joylink.club/bj-rtsts-server/db/dbquery"
"joylink.club/bj-rtsts-server/db/model"
"joylink.club/bj-rtsts-server/dto"
"time"
)
// 分页查询用户列表
@ -22,7 +24,7 @@ func PagingQueryUser(query *dto.PageUserReqDto) (*dto.PageDto, error) {
if err != nil {
panic(err)
}
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records}, err
return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: linkUserRole(records)}, err
}
func Register(user *dto.RegisterUser) {
@ -65,3 +67,48 @@ func FindUserInfo(userId int32) *dto.RegisterUser {
}
return user
}
// 查询关联用户角色信息
func linkUserRole(users []*model.User) []*dto.UserRspDto {
un := len(users)
uids := make([]int32, un)
userMap := make(map[int32]*dto.UserRspDto, un)
for i, u := range users {
uids[i] = u.ID
userMap[u.ID] = &dto.UserRspDto{
ID: u.ID,
Name: u.Name,
Mobile: u.Mobile,
RegisterTime: u.RegisterTime,
Roles: []*dto.AuthRoleRspDto{},
}
}
// 获取角色信息
roles, err1 := dbquery.AuthRole.Find()
if err1 != nil {
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err1.Error()})
}
roleMap := make(map[int32]*model.AuthRole)
for _, r := range roles {
roleMap[r.ID] = r
}
// 用户角色关联信息
utls, err2 := dbquery.AuthRoleUser.Where(dbquery.AuthRoleUser.UID.In(uids...)).Find()
if err2 != nil {
panic(dto.ErrorDto{Code: dto.DataOperationError, Message: err2.Error()})
}
for _, ul := range utls {
u, r := userMap[ul.UID], roleMap[ul.Rid]
if u == nil || r == nil {
continue
}
u.Roles = append(u.Roles, &dto.AuthRoleRspDto{Id: r.ID, Name: r.Name})
}
userArr := make([]*dto.UserRspDto, un)
i := 0
for _, u := range userMap {
userArr[i] = u
i++
}
return userArr
}