diff --git a/admin/admin/admin.pb.go b/admin/admin/admin.pb.go index eb55eaa..061fe5f 100644 --- a/admin/admin/admin.pb.go +++ b/admin/admin/admin.pb.go @@ -379,9 +379,9 @@ type AdminItemsRequest struct { Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` Size int32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` Phone string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone,omitempty"` - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - Email string `protobuf:"bytes,6,opt,name=email,proto3" json:"email,omitempty"` - Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Email string `protobuf:"bytes,5,opt,name=email,proto3" json:"email,omitempty"` + Status int32 `protobuf:"varint,6,opt,name=status,proto3" json:"status,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1082,6 +1082,254 @@ func (x *AuthorityEditRequest) GetDataTreeOneself() string { return "" } +type RoleRuleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Rule string `protobuf:"bytes,2,opt,name=rule,proto3" json:"rule,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleRuleRequest) Reset() { + *x = RoleRuleRequest{} + mi := &file_proto_admin_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleRuleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleRuleRequest) ProtoMessage() {} + +func (x *RoleRuleRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoleRuleRequest.ProtoReflect.Descriptor instead. +func (*RoleRuleRequest) Descriptor() ([]byte, []int) { + return file_proto_admin_proto_rawDescGZIP(), []int{17} +} + +func (x *RoleRuleRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RoleRuleRequest) GetRule() string { + if x != nil { + return x.Rule + } + return "" +} + +type RoleNameRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + ServiceId int64 `protobuf:"varint,2,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleNameRequest) Reset() { + *x = RoleNameRequest{} + mi := &file_proto_admin_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleNameRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleNameRequest) ProtoMessage() {} + +func (x *RoleNameRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoleNameRequest.ProtoReflect.Descriptor instead. +func (*RoleNameRequest) Descriptor() ([]byte, []int) { + return file_proto_admin_proto_rawDescGZIP(), []int{18} +} + +func (x *RoleNameRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *RoleNameRequest) GetServiceId() int64 { + if x != nil { + return x.ServiceId + } + return 0 +} + +type RoleEditRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + ServiceId int64 `protobuf:"varint,3,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + Rules []int64 `protobuf:"varint,4,rep,packed,name=rules,proto3" json:"rules,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleEditRequest) Reset() { + *x = RoleEditRequest{} + mi := &file_proto_admin_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleEditRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleEditRequest) ProtoMessage() {} + +func (x *RoleEditRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoleEditRequest.ProtoReflect.Descriptor instead. +func (*RoleEditRequest) Descriptor() ([]byte, []int) { + return file_proto_admin_proto_rawDescGZIP(), []int{19} +} + +func (x *RoleEditRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RoleEditRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *RoleEditRequest) GetServiceId() int64 { + if x != nil { + return x.ServiceId + } + return 0 +} + +func (x *RoleEditRequest) GetRules() []int64 { + if x != nil { + return x.Rules + } + return nil +} + +type RoleItemsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` + Size int32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` + ServiceId int64 `protobuf:"varint,3,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Status int32 `protobuf:"varint,5,opt,name=status,proto3" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleItemsRequest) Reset() { + *x = RoleItemsRequest{} + mi := &file_proto_admin_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleItemsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleItemsRequest) ProtoMessage() {} + +func (x *RoleItemsRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_admin_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RoleItemsRequest.ProtoReflect.Descriptor instead. +func (*RoleItemsRequest) Descriptor() ([]byte, []int) { + return file_proto_admin_proto_rawDescGZIP(), []int{20} +} + +func (x *RoleItemsRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *RoleItemsRequest) GetSize() int32 { + if x != nil { + return x.Size + } + return 0 +} + +func (x *RoleItemsRequest) GetServiceId() int64 { + if x != nil { + return x.ServiceId + } + return 0 +} + +func (x *RoleItemsRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *RoleItemsRequest) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + var File_proto_admin_proto protoreflect.FileDescriptor const file_proto_admin_proto_rawDesc = "" + @@ -1114,9 +1362,9 @@ const file_proto_admin_proto_rawDesc = "" + "\x04page\x18\x01 \x01(\x05R\x04page\x12\x12\n" + "\x04size\x18\x02 \x01(\x05R\x04size\x12\x14\n" + "\x05phone\x18\x03 \x01(\tR\x05phone\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12\x14\n" + - "\x05email\x18\x06 \x01(\tR\x05email\x12\x16\n" + - "\x06status\x18\a \x01(\x05R\x06status\"K\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x14\n" + + "\x05email\x18\x05 \x01(\tR\x05email\x12\x16\n" + + "\x06status\x18\x06 \x01(\x05R\x06status\"K\n" + "\x11AdminLoginRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\"\x13\n" + @@ -1163,7 +1411,27 @@ const file_proto_admin_proto_rawDesc = "" + "\fdata_oneself\x18\x10 \x01(\tR\vdataOneself\x12\"\n" + "\rdata_tree_all\x18\x11 \x01(\tR\vdataTreeAll\x120\n" + "\x14data_tree_department\x18\x12 \x01(\tR\x12dataTreeDepartment\x12*\n" + - "\x11data_tree_oneself\x18\x13 \x01(\tR\x0fdataTreeOneself2\xce\x0e\n" + + "\x11data_tree_oneself\x18\x13 \x01(\tR\x0fdataTreeOneself\"5\n" + + "\x0fRoleRuleRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04rule\x18\x02 \x01(\tR\x04rule\"D\n" + + "\x0fRoleNameRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x1d\n" + + "\n" + + "service_id\x18\x02 \x01(\x03R\tserviceId\"j\n" + + "\x0fRoleEditRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x1d\n" + + "\n" + + "service_id\x18\x03 \x01(\x03R\tserviceId\x12\x14\n" + + "\x05rules\x18\x04 \x03(\x03R\x05rules\"\x85\x01\n" + + "\x10RoleItemsRequest\x12\x12\n" + + "\x04page\x18\x01 \x01(\x05R\x04page\x12\x12\n" + + "\x04size\x18\x02 \x01(\x05R\x04size\x12\x1d\n" + + "\n" + + "service_id\x18\x03 \x01(\x03R\tserviceId\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x16\n" + + "\x06status\x18\x05 \x01(\x05R\x06status2\xa6\x13\n" + "\x05Admin\x12V\n" + "\tAdminEdit\x12\x17.admin.AdminEditRequest\x1a\x0f.admin.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/admin/v3/admin/edit\x12W\n" + "\vAdminStatus\x12\x14.admin.StatusRequest\x1a\x0f.admin.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/admin/v3/admin/status\x12X\n" + @@ -1176,6 +1444,7 @@ const file_proto_admin_proto_rawDesc = "" + "AdminLogin\x12\x18.admin.AdminLoginRequest\x1a\x0f.admin.Response\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\"\x0f/admin/v3/login\x12W\n" + "\fAdminRefresh\x12\x18.admin.AdminEmptyRequest\x1a\x0f.admin.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/admin/v3/refresh\x12Q\n" + "\tLoginInfo\x12\x18.admin.AdminEmptyRequest\x1a\x0f.admin.Response\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/admin/v3/info\x12U\n" + + "\vLoginRoutes\x12\x18.admin.AdminEmptyRequest\x1a\x0f.admin.Response\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/admin/v3/routes\x12U\n" + "\vServiceInfo\x12\x12.admin.InfoRequest\x1a\x0f.admin.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x12\x16/admin/v3/service/info\x12\\\n" + "\vServiceEdit\x12\x19.admin.ServiceEditRequest\x1a\x0f.admin.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/admin/v3/service/edit\x12_\n" + "\fServiceItems\x12\x1a.admin.ServiceItemsRequest\x1a\x0f.admin.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\x12\x17/admin/v3/service/items\x12[\n" + @@ -1184,9 +1453,16 @@ const file_proto_admin_proto_rawDesc = "" + "\rAuthorityInfo\x12\x12.admin.InfoRequest\x1a\x0f.admin.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x12\x18/admin/v3/authority/info\x12b\n" + "\rAuthorityEdit\x12\x1b.admin.AuthorityEditRequest\x1a\x0f.admin.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/admin/v3/authority/edit\x12e\n" + "\x0eAuthorityItems\x12\x1c.admin.AuthorityItemsRequest\x1a\x0f.admin.Response\"$\x82\xd3\xe4\x93\x02\x1e:\x01*\x12\x19/admin/v3/authority/items\x12_\n" + - "\x0fauthorityStatus\x12\x14.admin.StatusRequest\x1a\x0f.admin.Response\"%\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/admin/v3/authority/status\x12d\n" + + "\x0fAuthorityStatus\x12\x14.admin.StatusRequest\x1a\x0f.admin.Response\"%\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/admin/v3/authority/status\x12d\n" + "\x0eAuthorityNames\x12\x1b.admin.AuthorityNameRequest\x1a\x0f.admin.Response\"$\x82\xd3\xe4\x93\x02\x1e:\x01*\x12\x19/admin/v3/authority/names\x12b\n" + - "\rAuthoritySort\x12\x1b.admin.AuthoritySortRequest\x1a\x0f.admin.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/admin/v3/authority/sortB\tZ\a./adminb\x06proto3" + "\rAuthoritySort\x12\x1b.admin.AuthoritySortRequest\x1a\x0f.admin.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/admin/v3/authority/sort\x12U\n" + + "\tRoleNames\x12\x16.admin.RoleNameRequest\x1a\x0f.admin.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/role/names\x12O\n" + + "\bRoleInfo\x12\x12.admin.InfoRequest\x1a\x0f.admin.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x12\x13/admin/v3/role/info\x12S\n" + + "\bRoleEdit\x12\x16.admin.RoleEditRequest\x1a\x0f.admin.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/admin/v3/role/edit\x12V\n" + + "\tRoleItems\x12\x17.admin.RoleItemsRequest\x1a\x0f.admin.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/role/items\x12U\n" + + "\n" + + "RoleStatus\x12\x14.admin.StatusRequest\x1a\x0f.admin.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/admin/v3/role/status\x12S\n" + + "\bRoleRule\x12\x16.admin.RoleRuleRequest\x1a\x0f.admin.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x12\x13/admin/v3/role/ruleB\tZ\a./adminb\x06proto3" var ( file_proto_admin_proto_rawDescOnce sync.Once @@ -1200,7 +1476,7 @@ func file_proto_admin_proto_rawDescGZIP() []byte { return file_proto_admin_proto_rawDescData } -var file_proto_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_proto_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_proto_admin_proto_goTypes = []any{ (*AdminEditRequest)(nil), // 0: admin.AdminEditRequest (*StatusRequest)(nil), // 1: admin.StatusRequest @@ -1219,6 +1495,10 @@ var file_proto_admin_proto_goTypes = []any{ (*AuthorityNameRequest)(nil), // 14: admin.AuthorityNameRequest (*AuthorityItemsRequest)(nil), // 15: admin.AuthorityItemsRequest (*AuthorityEditRequest)(nil), // 16: admin.AuthorityEditRequest + (*RoleRuleRequest)(nil), // 17: admin.RoleRuleRequest + (*RoleNameRequest)(nil), // 18: admin.RoleNameRequest + (*RoleEditRequest)(nil), // 19: admin.RoleEditRequest + (*RoleItemsRequest)(nil), // 20: admin.RoleItemsRequest } var file_proto_admin_proto_depIdxs = []int32{ 0, // 0: admin.Admin.AdminEdit:input_type -> admin.AdminEditRequest @@ -1230,39 +1510,53 @@ var file_proto_admin_proto_depIdxs = []int32{ 7, // 6: admin.Admin.AdminLogin:input_type -> admin.AdminLoginRequest 8, // 7: admin.Admin.AdminRefresh:input_type -> admin.AdminEmptyRequest 8, // 8: admin.Admin.LoginInfo:input_type -> admin.AdminEmptyRequest - 9, // 9: admin.Admin.ServiceInfo:input_type -> admin.InfoRequest - 10, // 10: admin.Admin.ServiceEdit:input_type -> admin.ServiceEditRequest - 11, // 11: admin.Admin.ServiceItems:input_type -> admin.ServiceItemsRequest - 1, // 12: admin.Admin.ServiceStatus:input_type -> admin.StatusRequest - 12, // 13: admin.Admin.ServiceNames:input_type -> admin.ServiceNameRequest - 9, // 14: admin.Admin.AuthorityInfo:input_type -> admin.InfoRequest - 16, // 15: admin.Admin.AuthorityEdit:input_type -> admin.AuthorityEditRequest - 15, // 16: admin.Admin.AuthorityItems:input_type -> admin.AuthorityItemsRequest - 1, // 17: admin.Admin.authorityStatus:input_type -> admin.StatusRequest - 14, // 18: admin.Admin.AuthorityNames:input_type -> admin.AuthorityNameRequest - 13, // 19: admin.Admin.AuthoritySort:input_type -> admin.AuthoritySortRequest - 2, // 20: admin.Admin.AdminEdit:output_type -> admin.Response - 2, // 21: admin.Admin.AdminStatus:output_type -> admin.Response - 2, // 22: admin.Admin.Password:output_type -> admin.Response - 2, // 23: admin.Admin.OwnPassword:output_type -> admin.Response - 2, // 24: admin.Admin.AdminInfo:output_type -> admin.Response - 2, // 25: admin.Admin.AdminItems:output_type -> admin.Response - 2, // 26: admin.Admin.AdminLogin:output_type -> admin.Response - 2, // 27: admin.Admin.AdminRefresh:output_type -> admin.Response - 2, // 28: admin.Admin.LoginInfo:output_type -> admin.Response - 2, // 29: admin.Admin.ServiceInfo:output_type -> admin.Response - 2, // 30: admin.Admin.ServiceEdit:output_type -> admin.Response - 2, // 31: admin.Admin.ServiceItems:output_type -> admin.Response - 2, // 32: admin.Admin.ServiceStatus:output_type -> admin.Response - 2, // 33: admin.Admin.ServiceNames:output_type -> admin.Response - 2, // 34: admin.Admin.AuthorityInfo:output_type -> admin.Response - 2, // 35: admin.Admin.AuthorityEdit:output_type -> admin.Response - 2, // 36: admin.Admin.AuthorityItems:output_type -> admin.Response - 2, // 37: admin.Admin.authorityStatus:output_type -> admin.Response - 2, // 38: admin.Admin.AuthorityNames:output_type -> admin.Response - 2, // 39: admin.Admin.AuthoritySort:output_type -> admin.Response - 20, // [20:40] is the sub-list for method output_type - 0, // [0:20] is the sub-list for method input_type + 8, // 9: admin.Admin.LoginRoutes:input_type -> admin.AdminEmptyRequest + 9, // 10: admin.Admin.ServiceInfo:input_type -> admin.InfoRequest + 10, // 11: admin.Admin.ServiceEdit:input_type -> admin.ServiceEditRequest + 11, // 12: admin.Admin.ServiceItems:input_type -> admin.ServiceItemsRequest + 1, // 13: admin.Admin.ServiceStatus:input_type -> admin.StatusRequest + 12, // 14: admin.Admin.ServiceNames:input_type -> admin.ServiceNameRequest + 9, // 15: admin.Admin.AuthorityInfo:input_type -> admin.InfoRequest + 16, // 16: admin.Admin.AuthorityEdit:input_type -> admin.AuthorityEditRequest + 15, // 17: admin.Admin.AuthorityItems:input_type -> admin.AuthorityItemsRequest + 1, // 18: admin.Admin.AuthorityStatus:input_type -> admin.StatusRequest + 14, // 19: admin.Admin.AuthorityNames:input_type -> admin.AuthorityNameRequest + 13, // 20: admin.Admin.AuthoritySort:input_type -> admin.AuthoritySortRequest + 18, // 21: admin.Admin.RoleNames:input_type -> admin.RoleNameRequest + 9, // 22: admin.Admin.RoleInfo:input_type -> admin.InfoRequest + 19, // 23: admin.Admin.RoleEdit:input_type -> admin.RoleEditRequest + 20, // 24: admin.Admin.RoleItems:input_type -> admin.RoleItemsRequest + 1, // 25: admin.Admin.RoleStatus:input_type -> admin.StatusRequest + 17, // 26: admin.Admin.RoleRule:input_type -> admin.RoleRuleRequest + 2, // 27: admin.Admin.AdminEdit:output_type -> admin.Response + 2, // 28: admin.Admin.AdminStatus:output_type -> admin.Response + 2, // 29: admin.Admin.Password:output_type -> admin.Response + 2, // 30: admin.Admin.OwnPassword:output_type -> admin.Response + 2, // 31: admin.Admin.AdminInfo:output_type -> admin.Response + 2, // 32: admin.Admin.AdminItems:output_type -> admin.Response + 2, // 33: admin.Admin.AdminLogin:output_type -> admin.Response + 2, // 34: admin.Admin.AdminRefresh:output_type -> admin.Response + 2, // 35: admin.Admin.LoginInfo:output_type -> admin.Response + 2, // 36: admin.Admin.LoginRoutes:output_type -> admin.Response + 2, // 37: admin.Admin.ServiceInfo:output_type -> admin.Response + 2, // 38: admin.Admin.ServiceEdit:output_type -> admin.Response + 2, // 39: admin.Admin.ServiceItems:output_type -> admin.Response + 2, // 40: admin.Admin.ServiceStatus:output_type -> admin.Response + 2, // 41: admin.Admin.ServiceNames:output_type -> admin.Response + 2, // 42: admin.Admin.AuthorityInfo:output_type -> admin.Response + 2, // 43: admin.Admin.AuthorityEdit:output_type -> admin.Response + 2, // 44: admin.Admin.AuthorityItems:output_type -> admin.Response + 2, // 45: admin.Admin.AuthorityStatus:output_type -> admin.Response + 2, // 46: admin.Admin.AuthorityNames:output_type -> admin.Response + 2, // 47: admin.Admin.AuthoritySort:output_type -> admin.Response + 2, // 48: admin.Admin.RoleNames:output_type -> admin.Response + 2, // 49: admin.Admin.RoleInfo:output_type -> admin.Response + 2, // 50: admin.Admin.RoleEdit:output_type -> admin.Response + 2, // 51: admin.Admin.RoleItems:output_type -> admin.Response + 2, // 52: admin.Admin.RoleStatus:output_type -> admin.Response + 2, // 53: admin.Admin.RoleRule:output_type -> admin.Response + 27, // [27:54] is the sub-list for method output_type + 0, // [0:27] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -1279,7 +1573,7 @@ func file_proto_admin_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_admin_proto_rawDesc), len(file_proto_admin_proto_rawDesc)), NumEnums: 0, - NumMessages: 17, + NumMessages: 21, NumExtensions: 0, NumServices: 1, }, diff --git a/admin/admin/admin_grpc.pb.go b/admin/admin/admin_grpc.pb.go index 25b2027..7cbe987 100644 --- a/admin/admin/admin_grpc.pb.go +++ b/admin/admin/admin_grpc.pb.go @@ -28,6 +28,7 @@ const ( Admin_AdminLogin_FullMethodName = "/admin.Admin/AdminLogin" Admin_AdminRefresh_FullMethodName = "/admin.Admin/AdminRefresh" Admin_LoginInfo_FullMethodName = "/admin.Admin/LoginInfo" + Admin_LoginRoutes_FullMethodName = "/admin.Admin/LoginRoutes" Admin_ServiceInfo_FullMethodName = "/admin.Admin/ServiceInfo" Admin_ServiceEdit_FullMethodName = "/admin.Admin/ServiceEdit" Admin_ServiceItems_FullMethodName = "/admin.Admin/ServiceItems" @@ -36,9 +37,15 @@ const ( Admin_AuthorityInfo_FullMethodName = "/admin.Admin/AuthorityInfo" Admin_AuthorityEdit_FullMethodName = "/admin.Admin/AuthorityEdit" Admin_AuthorityItems_FullMethodName = "/admin.Admin/AuthorityItems" - Admin_AuthorityStatus_FullMethodName = "/admin.Admin/authorityStatus" + Admin_AuthorityStatus_FullMethodName = "/admin.Admin/AuthorityStatus" Admin_AuthorityNames_FullMethodName = "/admin.Admin/AuthorityNames" Admin_AuthoritySort_FullMethodName = "/admin.Admin/AuthoritySort" + Admin_RoleNames_FullMethodName = "/admin.Admin/RoleNames" + Admin_RoleInfo_FullMethodName = "/admin.Admin/RoleInfo" + Admin_RoleEdit_FullMethodName = "/admin.Admin/RoleEdit" + Admin_RoleItems_FullMethodName = "/admin.Admin/RoleItems" + Admin_RoleStatus_FullMethodName = "/admin.Admin/RoleStatus" + Admin_RoleRule_FullMethodName = "/admin.Admin/RoleRule" ) // AdminClient is the client API for Admin service. @@ -54,6 +61,7 @@ type AdminClient interface { AdminLogin(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*Response, error) AdminRefresh(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) LoginInfo(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) + LoginRoutes(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) ServiceInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) ServiceEdit(ctx context.Context, in *ServiceEditRequest, opts ...grpc.CallOption) (*Response, error) ServiceItems(ctx context.Context, in *ServiceItemsRequest, opts ...grpc.CallOption) (*Response, error) @@ -65,6 +73,12 @@ type AdminClient interface { AuthorityStatus(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*Response, error) AuthorityNames(ctx context.Context, in *AuthorityNameRequest, opts ...grpc.CallOption) (*Response, error) AuthoritySort(ctx context.Context, in *AuthoritySortRequest, opts ...grpc.CallOption) (*Response, error) + RoleNames(ctx context.Context, in *RoleNameRequest, opts ...grpc.CallOption) (*Response, error) + RoleInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) + RoleEdit(ctx context.Context, in *RoleEditRequest, opts ...grpc.CallOption) (*Response, error) + RoleItems(ctx context.Context, in *RoleItemsRequest, opts ...grpc.CallOption) (*Response, error) + RoleStatus(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*Response, error) + RoleRule(ctx context.Context, in *RoleRuleRequest, opts ...grpc.CallOption) (*Response, error) } type adminClient struct { @@ -165,6 +179,16 @@ func (c *adminClient) LoginInfo(ctx context.Context, in *AdminEmptyRequest, opts return out, nil } +func (c *adminClient) LoginRoutes(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Admin_LoginRoutes_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *adminClient) ServiceInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -275,6 +299,66 @@ func (c *adminClient) AuthoritySort(ctx context.Context, in *AuthoritySortReques return out, nil } +func (c *adminClient) RoleNames(ctx context.Context, in *RoleNameRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Admin_RoleNames_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminClient) RoleInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Admin_RoleInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminClient) RoleEdit(ctx context.Context, in *RoleEditRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Admin_RoleEdit_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminClient) RoleItems(ctx context.Context, in *RoleItemsRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Admin_RoleItems_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminClient) RoleStatus(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Admin_RoleStatus_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *adminClient) RoleRule(ctx context.Context, in *RoleRuleRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Admin_RoleRule_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // AdminServer is the server API for Admin service. // All implementations must embed UnimplementedAdminServer // for forward compatibility. @@ -288,6 +372,7 @@ type AdminServer interface { AdminLogin(context.Context, *AdminLoginRequest) (*Response, error) AdminRefresh(context.Context, *AdminEmptyRequest) (*Response, error) LoginInfo(context.Context, *AdminEmptyRequest) (*Response, error) + LoginRoutes(context.Context, *AdminEmptyRequest) (*Response, error) ServiceInfo(context.Context, *InfoRequest) (*Response, error) ServiceEdit(context.Context, *ServiceEditRequest) (*Response, error) ServiceItems(context.Context, *ServiceItemsRequest) (*Response, error) @@ -299,6 +384,12 @@ type AdminServer interface { AuthorityStatus(context.Context, *StatusRequest) (*Response, error) AuthorityNames(context.Context, *AuthorityNameRequest) (*Response, error) AuthoritySort(context.Context, *AuthoritySortRequest) (*Response, error) + RoleNames(context.Context, *RoleNameRequest) (*Response, error) + RoleInfo(context.Context, *InfoRequest) (*Response, error) + RoleEdit(context.Context, *RoleEditRequest) (*Response, error) + RoleItems(context.Context, *RoleItemsRequest) (*Response, error) + RoleStatus(context.Context, *StatusRequest) (*Response, error) + RoleRule(context.Context, *RoleRuleRequest) (*Response, error) mustEmbedUnimplementedAdminServer() } @@ -336,6 +427,9 @@ func (UnimplementedAdminServer) AdminRefresh(context.Context, *AdminEmptyRequest func (UnimplementedAdminServer) LoginInfo(context.Context, *AdminEmptyRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method LoginInfo not implemented") } +func (UnimplementedAdminServer) LoginRoutes(context.Context, *AdminEmptyRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method LoginRoutes not implemented") +} func (UnimplementedAdminServer) ServiceInfo(context.Context, *InfoRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method ServiceInfo not implemented") } @@ -369,6 +463,24 @@ func (UnimplementedAdminServer) AuthorityNames(context.Context, *AuthorityNameRe func (UnimplementedAdminServer) AuthoritySort(context.Context, *AuthoritySortRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method AuthoritySort not implemented") } +func (UnimplementedAdminServer) RoleNames(context.Context, *RoleNameRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method RoleNames not implemented") +} +func (UnimplementedAdminServer) RoleInfo(context.Context, *InfoRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method RoleInfo not implemented") +} +func (UnimplementedAdminServer) RoleEdit(context.Context, *RoleEditRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method RoleEdit not implemented") +} +func (UnimplementedAdminServer) RoleItems(context.Context, *RoleItemsRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method RoleItems not implemented") +} +func (UnimplementedAdminServer) RoleStatus(context.Context, *StatusRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method RoleStatus not implemented") +} +func (UnimplementedAdminServer) RoleRule(context.Context, *RoleRuleRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method RoleRule not implemented") +} func (UnimplementedAdminServer) mustEmbedUnimplementedAdminServer() {} func (UnimplementedAdminServer) testEmbeddedByValue() {} @@ -552,6 +664,24 @@ func _Admin_LoginInfo_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Admin_LoginRoutes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AdminEmptyRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServer).LoginRoutes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Admin_LoginRoutes_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServer).LoginRoutes(ctx, req.(*AdminEmptyRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Admin_ServiceInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(InfoRequest) if err := dec(in); err != nil { @@ -750,6 +880,114 @@ func _Admin_AuthoritySort_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Admin_RoleNames_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RoleNameRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServer).RoleNames(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Admin_RoleNames_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServer).RoleNames(ctx, req.(*RoleNameRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Admin_RoleInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServer).RoleInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Admin_RoleInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServer).RoleInfo(ctx, req.(*InfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Admin_RoleEdit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RoleEditRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServer).RoleEdit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Admin_RoleEdit_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServer).RoleEdit(ctx, req.(*RoleEditRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Admin_RoleItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RoleItemsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServer).RoleItems(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Admin_RoleItems_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServer).RoleItems(ctx, req.(*RoleItemsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Admin_RoleStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServer).RoleStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Admin_RoleStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServer).RoleStatus(ctx, req.(*StatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Admin_RoleRule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RoleRuleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AdminServer).RoleRule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Admin_RoleRule_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AdminServer).RoleRule(ctx, req.(*RoleRuleRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Admin_ServiceDesc is the grpc.ServiceDesc for Admin service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -793,6 +1031,10 @@ var Admin_ServiceDesc = grpc.ServiceDesc{ MethodName: "LoginInfo", Handler: _Admin_LoginInfo_Handler, }, + { + MethodName: "LoginRoutes", + Handler: _Admin_LoginRoutes_Handler, + }, { MethodName: "ServiceInfo", Handler: _Admin_ServiceInfo_Handler, @@ -826,7 +1068,7 @@ var Admin_ServiceDesc = grpc.ServiceDesc{ Handler: _Admin_AuthorityItems_Handler, }, { - MethodName: "authorityStatus", + MethodName: "AuthorityStatus", Handler: _Admin_AuthorityStatus_Handler, }, { @@ -837,6 +1079,30 @@ var Admin_ServiceDesc = grpc.ServiceDesc{ MethodName: "AuthoritySort", Handler: _Admin_AuthoritySort_Handler, }, + { + MethodName: "RoleNames", + Handler: _Admin_RoleNames_Handler, + }, + { + MethodName: "RoleInfo", + Handler: _Admin_RoleInfo_Handler, + }, + { + MethodName: "RoleEdit", + Handler: _Admin_RoleEdit_Handler, + }, + { + MethodName: "RoleItems", + Handler: _Admin_RoleItems_Handler, + }, + { + MethodName: "RoleStatus", + Handler: _Admin_RoleStatus_Handler, + }, + { + MethodName: "RoleRule", + Handler: _Admin_RoleRule_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "proto/admin.proto", diff --git a/admin/adminclient/admin.go b/admin/adminclient/admin.go index e004040..0999f42 100644 --- a/admin/adminclient/admin.go +++ b/admin/adminclient/admin.go @@ -27,6 +27,10 @@ type ( OwnPasswordRequest = admin.OwnPasswordRequest PasswordRequest = admin.PasswordRequest Response = admin.Response + RoleEditRequest = admin.RoleEditRequest + RoleItemsRequest = admin.RoleItemsRequest + RoleNameRequest = admin.RoleNameRequest + RoleRuleRequest = admin.RoleRuleRequest ServiceEditRequest = admin.ServiceEditRequest ServiceItemsRequest = admin.ServiceItemsRequest ServiceNameRequest = admin.ServiceNameRequest @@ -42,6 +46,7 @@ type ( AdminLogin(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*Response, error) AdminRefresh(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) LoginInfo(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) + LoginRoutes(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) ServiceInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) ServiceEdit(ctx context.Context, in *ServiceEditRequest, opts ...grpc.CallOption) (*Response, error) ServiceItems(ctx context.Context, in *ServiceItemsRequest, opts ...grpc.CallOption) (*Response, error) @@ -53,6 +58,12 @@ type ( AuthorityStatus(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*Response, error) AuthorityNames(ctx context.Context, in *AuthorityNameRequest, opts ...grpc.CallOption) (*Response, error) AuthoritySort(ctx context.Context, in *AuthoritySortRequest, opts ...grpc.CallOption) (*Response, error) + RoleNames(ctx context.Context, in *RoleNameRequest, opts ...grpc.CallOption) (*Response, error) + RoleInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) + RoleEdit(ctx context.Context, in *RoleEditRequest, opts ...grpc.CallOption) (*Response, error) + RoleItems(ctx context.Context, in *RoleItemsRequest, opts ...grpc.CallOption) (*Response, error) + RoleStatus(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*Response, error) + RoleRule(ctx context.Context, in *RoleRuleRequest, opts ...grpc.CallOption) (*Response, error) } defaultAdmin struct { @@ -111,6 +122,11 @@ func (m *defaultAdmin) LoginInfo(ctx context.Context, in *AdminEmptyRequest, opt return client.LoginInfo(ctx, in, opts...) } +func (m *defaultAdmin) LoginRoutes(ctx context.Context, in *AdminEmptyRequest, opts ...grpc.CallOption) (*Response, error) { + client := admin.NewAdminClient(m.cli.Conn()) + return client.LoginRoutes(ctx, in, opts...) +} + func (m *defaultAdmin) ServiceInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) { client := admin.NewAdminClient(m.cli.Conn()) return client.ServiceInfo(ctx, in, opts...) @@ -165,3 +181,33 @@ func (m *defaultAdmin) AuthoritySort(ctx context.Context, in *AuthoritySortReque client := admin.NewAdminClient(m.cli.Conn()) return client.AuthoritySort(ctx, in, opts...) } + +func (m *defaultAdmin) RoleNames(ctx context.Context, in *RoleNameRequest, opts ...grpc.CallOption) (*Response, error) { + client := admin.NewAdminClient(m.cli.Conn()) + return client.RoleNames(ctx, in, opts...) +} + +func (m *defaultAdmin) RoleInfo(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*Response, error) { + client := admin.NewAdminClient(m.cli.Conn()) + return client.RoleInfo(ctx, in, opts...) +} + +func (m *defaultAdmin) RoleEdit(ctx context.Context, in *RoleEditRequest, opts ...grpc.CallOption) (*Response, error) { + client := admin.NewAdminClient(m.cli.Conn()) + return client.RoleEdit(ctx, in, opts...) +} + +func (m *defaultAdmin) RoleItems(ctx context.Context, in *RoleItemsRequest, opts ...grpc.CallOption) (*Response, error) { + client := admin.NewAdminClient(m.cli.Conn()) + return client.RoleItems(ctx, in, opts...) +} + +func (m *defaultAdmin) RoleStatus(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*Response, error) { + client := admin.NewAdminClient(m.cli.Conn()) + return client.RoleStatus(ctx, in, opts...) +} + +func (m *defaultAdmin) RoleRule(ctx context.Context, in *RoleRuleRequest, opts ...grpc.CallOption) (*Response, error) { + client := admin.NewAdminClient(m.cli.Conn()) + return client.RoleRule(ctx, in, opts...) +} diff --git a/admin/internal/dao/role.go b/admin/internal/dao/role.go index 19fa01f..444f913 100644 --- a/admin/internal/dao/role.go +++ b/admin/internal/dao/role.go @@ -1,38 +1,32 @@ package dao -import "pkg.local/utils" - // Role 岗位表 type Role struct { - Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT;comment:ID" json:"id"` - Name string `gorm:"column:name;type:varchar(255);comment:名称;NOT NULL" json:"name"` - ServiceId int `gorm:"column:service_id;type:int(11);comment:项目ID;NOT NULL" json:"service_id"` - Status uint8 `gorm:"column:status;type:tinyint(1);default:1;comment:状态,1为正常,2为禁用;NOT NULL" json:"status"` - Rules string `gorm:"column:rules;type:text;comment:权限内容" json:"rules"` - Reason string `gorm:"column:reason;type:varchar(255);comment:原因" json:"reason"` - AdminId int `gorm:"column:admin_id;type:int(11)" json:"admin_id"` - AdminName string `gorm:"column:admin_name;type:varchar(255);comment:操作人员姓名" json:"admin_name"` - CreateTime utils.CustomTime `gorm:"column:create_time;default:NULL;type:datetime" json:"create_time"` - UpdateTime utils.CustomTime `gorm:"column:update_time;default:NULL;type:datetime" json:"update_time"` + Id int64 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT;comment:ID" json:"id"` + Name string `gorm:"column:name;type:varchar(255);comment:名称;NOT NULL" json:"name"` + ServiceId int64 `gorm:"column:service_id;type:int(11);comment:项目ID;NOT NULL" json:"service_id"` + Status uint8 `gorm:"column:status;type:tinyint(1);default:1;comment:状态,1为正常,2为禁用;NOT NULL" json:"status"` + Rules string `gorm:"column:rules;type:text;comment:权限内容" json:"rules"` + Reason string `gorm:"column:reason;type:varchar(255);comment:原因" json:"reason"` + AdminId int64 `gorm:"column:admin_id;type:int(11)" json:"admin_id"` + AdminName string `gorm:"column:admin_name;type:varchar(255);comment:操作人员姓名" json:"admin_name"` } // RoleStatus 修改状态 type RoleStatus struct { - Id int `json:"id"` - Status uint8 `json:"status"` - Reason string `gorm:"column:reason;type:varchar(255);comment:原因" json:"reason"` - AdminId int `json:"admin_id"` - AdminName string `gorm:"column:admin_name;type:varchar(100);comment:操作人姓名" json:"admin_name"` - UpdateTime utils.CustomTime `gorm:"column:update_time;type:datetime;default:NULL;comment:更新时间" json:"update_time"` + Id int64 `json:"id"` + Status uint8 `json:"status"` + Reason string `gorm:"column:reason;type:varchar(255);comment:原因" json:"reason"` + AdminId int64 `json:"admin_id"` + AdminName string `gorm:"column:admin_name;type:varchar(100);comment:操作人姓名" json:"admin_name"` } // RoleRule 修改状态 type RoleRule struct { - Id int `json:"id"` - Rules string `json:"rules"` - AdminId int `json:"admin_id"` - AdminName string `gorm:"column:admin_name;type:varchar(100);comment:操作人姓名" json:"admin_name"` - UpdateTime utils.CustomTime `gorm:"column:update_time;type:datetime;default:NULL;comment:更新时间" json:"update_time"` + Id int64 `json:"id"` + Rules string `json:"rules"` + AdminId int64 `json:"admin_id"` + AdminName string `gorm:"column:admin_name;type:varchar(100);comment:操作人姓名" json:"admin_name"` } type RoleItems struct { @@ -41,27 +35,27 @@ type RoleItems struct { } type RoleNameItems struct { - Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + Id int64 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` Name string `gorm:"column:name;type:varchar(255);comment:项目描述;NOT NULL" json:"name"` - ServiceId int `json:"service_id"` + ServiceId int64 `json:"service_id"` } type RoleServiceNameItems struct { - Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + Id int64 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` Name string `gorm:"column:name;type:varchar(255);comment:项目描述;NOT NULL" json:"name"` Items []RoleNameItems `json:"items"` } type RoleRulesItems struct { - Id int `json:"id"` + Id int64 `json:"id"` Name string `json:"name"` Rules string `json:"rules"` } type RoleInfo struct { - Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT;comment:ID" json:"id"` + Id int64 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT;comment:ID" json:"id"` Name string `gorm:"column:name;type:varchar(255);comment:名称;NOT NULL" json:"name"` - ServiceId int `gorm:"column:service_id;type:int(11);comment:项目ID;NOT NULL" json:"service_id"` + ServiceId int64 `gorm:"column:service_id;type:int(11);comment:项目ID;NOT NULL" json:"service_id"` Status uint8 `gorm:"column:status;type:tinyint(1);default:1;comment:状态,1为正常,2为禁用;NOT NULL" json:"status"` Rules []int `gorm:"column:rules;type:text;comment:权限内容" json:"rules"` Reason string `gorm:"column:reason;type:varchar(255);comment:原因" json:"reason"` diff --git a/admin/internal/logic/adminitemslogic.go b/admin/internal/logic/adminitemslogic.go index ca40982..02d2e24 100644 --- a/admin/internal/logic/adminitemslogic.go +++ b/admin/internal/logic/adminitemslogic.go @@ -113,10 +113,10 @@ func (l *AdminItemsLogic) getRoleInfos(data []dao.AdminInfo) map[string]dao.Role } for i := utils.NumberZero; i < len(items); i++ { serverName := utils.StringEmpty - if _, ok := serverIds[items[i].ServiceId]; ok { - serverName = serverIds[items[i].ServiceId] + utils.DecollatorColon + if _, ok := serverIds[int(items[i].ServiceId)]; ok { + serverName = serverIds[int(items[i].ServiceId)] + utils.DecollatorColon } - retData[strconv.Itoa(items[i].Id)] = dao.RoleNameItems{ + retData[strconv.Itoa(int(items[i].Id))] = dao.RoleNameItems{ Id: items[i].Id, Name: serverName + items[i].Name, } diff --git a/admin/internal/logic/authorityeditlogic.go b/admin/internal/logic/authorityeditlogic.go new file mode 100644 index 0000000..a5903ca --- /dev/null +++ b/admin/internal/logic/authorityeditlogic.go @@ -0,0 +1,325 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "encoding/json" + "strconv" + "strings" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type AuthorityEditLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewAuthorityEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthorityEditLogic { + return &AuthorityEditLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *AuthorityEditLogic) AuthorityEdit(in *admin.AuthorityEditRequest) (*admin.Response, error) { + var v validator.AuthorityEditValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo), nil + } + edit, dErr := l.getData(adminInfo, in) + if dErr != utils.Ok { + return l.fail(dErr), nil + } + modelObj := model.AuthorityModel{}.Init() + var err error + jErr, jsonData := l.getJsonData(in) + if jErr != utils.Ok { + return l.fail(jErr), nil + } + id := in.Id + if id > utils.NumberZero { + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} + info := dao.Authority{} + err = modelObj.GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund), nil + } + + edit.Id = info.Id + edit.Type = info.Type + edit.Sort = info.Sort + edit.ServiceId = info.ServiceId + edit.Status = info.Status + w = modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(info.Id, utils.NumberTen)}} + if edit.Type == dao.TypeData { + edit.DataIds = info.DataIds + ids := strings.Split(info.DataIds, ",") + eId, _ := strconv.Atoi(ids[utils.NumberZero]) + eId1, _ := strconv.Atoi(ids[utils.NumberOne]) + eId2, _ := strconv.Atoi(ids[utils.NumberTwo]) + upW := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(eId)}} + l.setJsonData(&edit, int64(eId), "base", jsonData, in) + _, err = modelObj.Edit(upW, edit) + l.setJsonData(&edit, int64(eId1), "department", jsonData, in) + upW.Eq["id"] = strconv.Itoa(eId1) + _, err = modelObj.Edit(upW, edit) + l.setJsonData(&edit, int64(eId2), "oneself", jsonData, in) + upW.Eq["id"] = strconv.Itoa(eId2) + _, err = modelObj.Edit(upW, edit) + + } else { + _, err = modelObj.Edit(w, edit) + } + } else { + if edit.Type == dao.TypeData { + var ids []string + l.setJsonData(&edit, utils.NumberZero, "base", jsonData, in) + err = modelObj.Create(&edit) + ids = append(ids, strconv.FormatInt(edit.Id, utils.NumberTen)) + l.setJsonData(&edit, utils.NumberZero, "department", jsonData, in) + err = modelObj.Create(&edit) + ids = append(ids, strconv.FormatInt(edit.Id, utils.NumberTen)) + l.setJsonData(&edit, utils.NumberZero, "oneself", jsonData, in) + err = modelObj.Create(&edit) + ids = append(ids, strconv.FormatInt(edit.Id, utils.NumberTen)) + + jsonIds := dao.AuthorityUpJsonIds{ + DataIds: strings.Join(ids, ","), + } + jsonW := modelbase.Params{In: map[string][]string{"id": ids}} + modelObj.Edit(jsonW, &jsonIds) + + } else { + err = modelObj.Create(&edit) + id = edit.Id + } + } + + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + + return l.ok(id), nil +} + +func (l *AuthorityEditLogic) getData(adminInfo utils.UserInfo, in *admin.AuthorityEditRequest) (dao.Authority, utils.Status) { + edit := dao.Authority{ + Name: in.Name, + Type: uint8(in.Type), + Sort: l.getSort(in.ParentId, in.ServiceId), + Description: in.Description, + Icon: in.Icon, + Identification: in.Identification, + ServiceId: in.ServiceId, + ParentId: in.ParentId, + Api: dao.NoData, + ViewPath: in.ViewPath, + Path: in.Path, + IsShow: uint8(in.IsShow), + AdminId: adminInfo.ID, + AdminName: adminInfo.Name, + } + + edit.Path = "/" + strings.TrimLeft(edit.Path, "/") + + if edit.ParentId < utils.NumberOne { + edit.ParentId = utils.NumberZero + } + + check := l.checkName(in.Id, map[string]string{ + "service_id": strconv.FormatInt(edit.ServiceId, utils.NumberTen), + "name": edit.Name, + }) + if !check { + return edit, utils.SetError(utils.ErrorMissingParams, "权限名称已存在") + } + + check = l.check(edit.Id, map[string]string{ + "service_id": strconv.FormatInt(edit.ServiceId, utils.NumberTen), + "identification": edit.Identification, + }) + if !check { + return edit, utils.SetError(utils.ErrorMissingParams, "权限标识已存在") + } + + if edit.Type == dao.TypeWeb { + if len(edit.ViewPath) < utils.NumberOne { + return edit, utils.SetError(utils.ErrorMissingParams, "组件路径不能为空") + } + check := l.check(in.Id, map[string]string{"path": edit.Path, "service_id": strconv.FormatInt(edit.ServiceId, utils.NumberTen)}) + if !check { + return edit, utils.SetError(utils.ErrorMissingParams, "PATH已存在") + } + } else if edit.Type == dao.TypeButton { + edit.Icon = utils.StringEmpty + if len(edit.Api) < utils.NumberOne { + return edit, utils.SetError(utils.ErrorMissingParams, "API不能为空") + } + edit.Api = in.Api + edit.Path = dao.NoData + edit.ViewPath = dao.NoData + } else if edit.Type == dao.TypeDir { + edit.ViewPath = dao.NoData + check := l.check(in.Id, map[string]string{"path": edit.Path, "service_id": strconv.FormatInt(edit.ServiceId, utils.NumberTen)}) + if !check { + return edit, utils.SetError(utils.ErrorMissingParams, "PATH已存在") + } + } else if edit.Type == dao.TypeData { + if len(edit.Api) < utils.NumberOne { + return edit, utils.SetError(utils.ErrorMissingParams, "API不能为空") + } + edit.Icon = utils.StringEmpty + edit.Api = in.Api + edit.Path = dao.NoData + edit.ViewPath = dao.NoData + } + + if edit.ParentId == utils.NumberZero { + edit.ParentIds = utils.StringZero + } else { + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(edit.ParentId, utils.NumberTen)}} + info := dao.Authority{} + err := model.AuthorityModel{}.Init().GetOne(w, &info) + if err != nil { + return edit, utils.Ok + } + if info.Id < utils.NumberOne { + return edit, utils.ErrorNotFund + } + edit.ParentIds = info.ParentIds + "," + strconv.FormatInt(edit.ParentId, utils.NumberTen) + } + + idsArr := strings.SplitAfter(edit.ParentIds, ",") + edit.Level = uint8(len(idsArr)) + + return edit, utils.Ok +} + +func (l *AuthorityEditLogic) check(id int64, check map[string]string) bool { + w := modelbase.Params{Eq: check} + info := dao.AuthorityCheck{} + _ = model.AuthorityModel{}.Init().GetOne(w, &info) + if id > utils.NumberZero && info.Id == id { + return true + } + if info.Id > utils.NumberZero { + return false + } + + return true +} + +func (l *AuthorityEditLogic) checkName(id int64, check map[string]string) bool { + w := modelbase.Params{Eq: check} + info := dao.AuthorityCheck{} + _ = model.AuthorityModel{}.Init().GetOne(w, &info) + if id > utils.NumberZero && info.Id == id { + return true + } + if info.Id > utils.NumberZero { + return false + } + + return true +} + +func (l *AuthorityEditLogic) getSort(pid, serviceId int64) uint8 { + if pid < utils.NumberZero { + pid = utils.NumberZero + } + w := modelbase.Params{ + Eq: map[string]string{ + "parent_id": strconv.FormatInt(pid, utils.NumberTen), + "project_id": strconv.FormatInt(serviceId, utils.NumberTen)}, + Order: "sort DESC", + } + info := dao.Authority{} + err := model.AuthorityModel{}.Init().GetOne(w, &info) + if err != nil || info.Id < utils.NumberOne { + return utils.NumberOne + } + return info.Sort + utils.NumberOne +} + +func (l *AuthorityEditLogic) setJsonData(edit *dao.Authority, id int64, name string, data map[string]string, in *admin.AuthorityEditRequest) { + edit.Id = id + if name == "base" { + edit.Name = in.Name + "-全部" + edit.JsonDataBase = data["base"] + edit.JsonData = data["all"] + edit.JsonTreeData = data["tree_all"] + } else if name == "department" { + edit.JsonData = data["department"] + edit.Name = in.Name + "-部门" + edit.JsonTreeData = data["tree_department"] + edit.Identification = in.Identification + ":department" + } else if name == "oneself" { + edit.JsonData = data["oneself"] + edit.Name = in.Name + "-个人" + edit.JsonTreeData = data["tree_oneself"] + edit.Identification = in.Identification + ":oneself" + } + if id == utils.NumberZero { + edit.Sort += utils.NumberOne + } else { + info := dao.AuthoritySort{} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(id, utils.NumberTen)}} + _ = model.AuthorityModel{}.Init().GetOne(w, &info) + edit.Sort = info.Sort + } +} +func (l *AuthorityEditLogic) getJsonData(in *admin.AuthorityEditRequest) (utils.Status, map[string]string) { + data := map[string]string{} + if in.Type != dao.TypeData { + return utils.Ok, data + } + var check map[string]interface{} + // 解析JSON字符串到map + err := json.Unmarshal([]byte(in.DataBaseStr), &check) + if err != nil { + return utils.ErrorJsonDataError, data + } + // 解析JSON字符串到map + err = json.Unmarshal([]byte(in.DataAll), &check) + if err != nil { + return utils.ErrorJsonDataError, data + } + // 解析JSON字符串到map + err = json.Unmarshal([]byte(in.DataDepartment), &check) + if err != nil { + return utils.ErrorJsonDataError, data + } + // 解析JSON字符串到map + err = json.Unmarshal([]byte(in.DataOneself), &check) + if err != nil { + return utils.ErrorJsonDataError, data + } + data["base"] = in.DataBaseStr + data["all"] = in.DataAll + data["department"] = in.DataDepartment + data["oneself"] = in.DataOneself + data["tree_all"] = in.DataTreeAll + data["tree_department"] = in.DataTreeDepartment + data["tree_oneself"] = in.DataTreeOneself + return utils.Ok, data +} diff --git a/admin/internal/logic/authoritynameslogic.go b/admin/internal/logic/authoritynameslogic.go new file mode 100644 index 0000000..c660644 --- /dev/null +++ b/admin/internal/logic/authoritynameslogic.go @@ -0,0 +1,81 @@ +package logic + +import ( + "admin/admin" + "admin/internal/dao" + "admin/internal/model" + "admin/internal/svc" + "admin/validator" + "context" + "strconv" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type AuthorityNamesLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewAuthorityNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthorityNamesLogic { + return &AuthorityNamesLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *AuthorityNamesLogic) AuthorityNames(in *admin.AuthorityNameRequest) (*admin.Response, error) { + var v validator.AuthorityNameItemsValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + var data []dao.AuthorityNames + modelObj := model.AuthorityModel{}.Init() + w := modelbase.Params{ + Order: "level ASC, parent_id ASC, sort ASC", + Eq: map[string]string{ + "service_id": strconv.FormatInt(in.ServiceId, utils.NumberTen), + "status": utils.StringStatusOk, + }, + } + if in.Type == dao.QuerySortLIstWeb { + w.In = map[string][]string{"type in ?": {strconv.Itoa(dao.TypeDir), strconv.Itoa(dao.TypeWeb)}} + } else if in.Type == dao.QuerySortListNotButton { + w.In = map[string][]string{"type in ?": {strconv.Itoa(dao.TypeDir), strconv.Itoa(dao.TypeWeb)}} + } + + err := modelObj.Items(w, &data) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + + items := l.getNameList(data, utils.NumberZero) + return l.ok(items), nil +} + +// 获取层级的下接数据 列表使用 +func (l *AuthorityNamesLogic) getNameList(data []dao.AuthorityNames, pid int64) []dao.AuthorityNamesItems { + var dataArr []dao.AuthorityNamesItems + for _, v := range data { + if v.ParentId == pid { + // 这里可以理解为每次都从最原始的数据里面找出相对就的ID进行匹配,直到找不到就返回 + children := l.getNameList(data, v.Id) + node := dao.AuthorityNamesItems{ + Id: v.Id, + ParentId: v.ParentId, + Name: v.Name, + Level: v.Level, + Type: v.Type, + Children: children, + } + dataArr = append(dataArr, node) + } + } + return dataArr +} diff --git a/admin/internal/logic/authoritysortlogic.go b/admin/internal/logic/authoritysortlogic.go new file mode 100644 index 0000000..caae1e7 --- /dev/null +++ b/admin/internal/logic/authoritysortlogic.go @@ -0,0 +1,94 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "strconv" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type AuthoritySortLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewAuthoritySortLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthoritySortLogic { + return &AuthoritySortLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *AuthoritySortLogic) AuthoritySort(in *admin.AuthoritySortRequest) (*admin.Response, error) { + var v validator.AuthoritySortValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo), nil + } + info := dao.AuthoritySort{} + modelObj := model.AuthorityModel{}.Init() + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} + err := modelObj.Items(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund), nil + } + + w = modelbase.Params{ + Eq: map[string]string{"parent_id": strconv.FormatInt(info.ParentId, utils.NumberTen)}, + Order: "sort ASC", + } + sortKey := "sort > ?" + if in.Type == dao.SortTypeUp { + sortKey = "sort < ?" + w.Order = "sort DESC" + } + w.Other = map[string]string{sortKey: strconv.Itoa(int(info.Sort))} + other := dao.AuthoritySort{} + err = modelObj.Items(w, &other) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund), nil + } + w = modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(info.Id, utils.NumberTen)}} + infoSort := info.Sort + info.Sort = other.Sort + info.AdminId = adminInfo.ID + info.AdminName = adminInfo.Name + num, err := modelObj.Edit(w, &info) + if err != nil || num < utils.NumberOne { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + w = modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(other.Id, utils.NumberTen)}} + other.Sort = infoSort + other.AdminId = info.AdminId + other.AdminName = info.AdminName + num, err = modelObj.Edit(w, &other) + if err != nil || num < utils.NumberOne { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + + return l.ok(utils.NumberOne), nil +} diff --git a/admin/internal/logic/authoritystatuslogic.go b/admin/internal/logic/authoritystatuslogic.go new file mode 100644 index 0000000..e96d67c --- /dev/null +++ b/admin/internal/logic/authoritystatuslogic.go @@ -0,0 +1,81 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "strconv" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type AuthorityStatusLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewAuthorityStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthorityStatusLogic { + return &AuthorityStatusLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *AuthorityStatusLogic) AuthorityStatus(in *admin.StatusRequest) (*admin.Response, error) { + var v validator.AuthorityStatusValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo), nil + } + info := dao.AuthorityStatus{} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} + modelObj := model.AuthorityModel{}.Init() + err := modelObj.GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund), nil + } + + countW := modelbase.Params{Eq: map[string]string{ + "service_id": strconv.FormatInt(info.ServiceId, utils.NumberTen), + "status": utils.StringStatusOk, + "parent_id": strconv.FormatInt(in.Id, utils.NumberTen), + }} + infos := dao.AuthorityStatus{} + count, err := modelObj.Count(countW, &infos) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + + if count > utils.NumberZero { + return l.fail(utils.ErrorAuthorityChange), nil + } + + info.Status = uint8(in.Status) + info.Reason = in.Reason + info.AdminId = adminInfo.ID + info.AdminName = adminInfo.Name + _, editErr := modelObj.Edit(w, info) + if editErr != nil { + l.Logger.Error(editErr) + return l.fail(utils.Fail), nil + } + + return l.ok(utils.NumberOne), nil +} diff --git a/admin/internal/logic/loginrouteslogic.go b/admin/internal/logic/loginrouteslogic.go new file mode 100644 index 0000000..f8270a6 --- /dev/null +++ b/admin/internal/logic/loginrouteslogic.go @@ -0,0 +1,30 @@ +package logic + +import ( + "context" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +type LoginRoutesLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewLoginRoutesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginRoutesLogic { + return &LoginRoutesLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *LoginRoutesLogic) LoginRoutes(in *admin.AdminEmptyRequest) (*admin.Response, error) { + // todo: add your logic here and delete this line + + return &admin.Response{}, nil +} diff --git a/admin/internal/logic/roleeditlogic.go b/admin/internal/logic/roleeditlogic.go new file mode 100644 index 0000000..6bbd0f9 --- /dev/null +++ b/admin/internal/logic/roleeditlogic.go @@ -0,0 +1,146 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "strconv" + "strings" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type RoleEditLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewRoleEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleEditLogic { + return &RoleEditLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *RoleEditLogic) RoleEdit(in *admin.RoleEditRequest) (*admin.Response, error) { + var v validator.RoleEditValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo), nil + } + + check, err := l.check(in.Name, in.ServiceId) + if err != utils.Ok { + return l.fail(err), nil + } + + edit := dao.Role{ + Name: in.Name, + ServiceId: in.ServiceId, + Rules: l.getIds(in.Rules, in.ServiceId), + AdminId: adminInfo.ID, + AdminName: adminInfo.Name, + } + + modelObj := model.RoleModel{}.Init() + id := in.Id + var editErr error + if id > utils.NumberZero { + if check.Id > utils.NumberZero && check.Id != id { + return l.fail(utils.ErrorExist), nil + } + + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} + info := dao.Role{} + InfoErr := modelObj.GetOne(w, &info) + if InfoErr != nil { + l.Logger.Error(InfoErr) + return l.fail(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund), nil + } + + edit.Id = info.Id + edit.Status = info.Status + + w = modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(info.Id, utils.NumberTen)}} + _, editErr = modelObj.Edit(w, edit) + } else { + if check.Id > utils.NumberZero { + return l.fail(utils.ErrorExist), nil + } + editErr = modelObj.Create(&edit) + id = edit.Id + } + + if editErr != nil { + l.Logger.Error(editErr) + return l.fail(utils.Fail), nil + } + + return l.ok(id), nil +} + +func (l *RoleEditLogic) check(name string, id int64) (dao.Role, utils.Status) { + w := modelbase.Params{Eq: map[string]string{"name": name, "service_id": strconv.FormatInt(id, utils.NumberTen)}} + info := dao.Role{} + err := model.RoleModel{}.Init().GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return info, utils.Fail + } + return info, utils.Ok +} + +func (l *RoleEditLogic) getIds(ids []int64, serviceId int64) string { + var roles []string + if len(ids) > utils.NumberZero { + for _, role := range ids { + roles = append(roles, strconv.Itoa(int(role))) + } + } + + var items []dao.Authority + w := modelbase.Params{ + Eq: map[string]string{"status": utils.StringStatusOk, "service_id": strconv.FormatInt(serviceId, utils.NumberTen)}, + In: map[string][]string{"id in ?": roles}, + } + w.Order = "level ASC, parent_id ASC, sort ASC" + err := model.AuthorityModel{}.Init().Items(w, &items) + if err != nil { + return utils.StringEmpty + } + + var idsArr []string + for _, item := range items { + idsArr = append(idsArr, strconv.Itoa(int(item.Id))) + tmp := strings.Split(item.ParentIds, utils.DecollatorComma) + idsArr = append(idsArr, tmp...) + } + + var retIdsArr []string + keys := make(map[string]bool) + for _, id := range idsArr { + if id != utils.StringZero { + if _, value := keys[id]; !value { + keys[id] = true + retIdsArr = append(retIdsArr, id) + } + } + } + + return strings.Join(retIdsArr, utils.DecollatorComma) +} diff --git a/admin/internal/logic/roleinfologic.go b/admin/internal/logic/roleinfologic.go new file mode 100644 index 0000000..d6ab493 --- /dev/null +++ b/admin/internal/logic/roleinfologic.go @@ -0,0 +1,66 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "strconv" + "strings" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type RoleInfoLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewRoleInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleInfoLogic { + return &RoleInfoLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *RoleInfoLogic) RoleInfo(in *admin.InfoRequest) (*admin.Response, error) { + var v validator.RoleInfoValidator + l.Logger.Error(in.Id) + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + + role := dao.Role{} + modelObj := model.RoleModel{}.Init() + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} + err := modelObj.GetOne(w, &role) + if err != nil { + return l.fail(utils.Fail), nil + } + + var rules []int + ruleArrs := strings.Split(role.Rules, ",") + for _, rule := range ruleArrs { + r, _ := strconv.Atoi(rule) + rules = append(rules, r) + } + + info := dao.RoleInfo{ + Id: role.Id, + Name: role.Name, + Status: role.Status, + ServiceId: role.ServiceId, + Reason: role.Reason, + Rules: rules, + } + + return l.ok(info), nil +} diff --git a/admin/internal/logic/roleitemslogic.go b/admin/internal/logic/roleitemslogic.go new file mode 100644 index 0000000..fc0e7c8 --- /dev/null +++ b/admin/internal/logic/roleitemslogic.go @@ -0,0 +1,103 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "strconv" + "strings" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type RoleItemsLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewRoleItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleItemsLogic { + return &RoleItemsLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *RoleItemsLogic) RoleItems(in *admin.RoleItemsRequest) (*admin.Response, error) { + var v validator.RoleItemsValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + modelObj := model.RoleModel{}.Init() + w := modelbase.Params{ + Page: int(in.Page), + Size: int(in.Size), + Order: "id asc", + Eq: map[string]string{"service_id": strconv.FormatInt(in.ServiceId, 10)}, + } + + w.Like = make(map[string]string) + if in.Status > utils.NumberZero { + w.Eq["status"] = strconv.Itoa(int(in.Status)) + } + if len(in.Name) > utils.NumberZero { + w.Like["name LIKE ? "] = "%%" + in.Name + "%%" + } + + var data []dao.Role + err := modelObj.Items(w, &data) + if err != nil { + l.Logger.Error(err) + return nil, err + } + + var items []dao.RoleItems + rulesInfos := l.getRulesInfo(data) + for i := utils.NumberZero; i < len(data); i++ { + var rules []string + for _, rule := range strings.Split(data[i].Rules, utils.DecollatorComma) { + if _, ok := rulesInfos[rule]; ok { + rules = append(rules, rulesInfos[rule]) + } + } + items = append(items, dao.RoleItems{ + Role: data[i], + RuleItems: rules, + }) + } + + return l.ok(items), nil +} + +func (l *RoleItemsLogic) getRulesInfo(data []dao.Role) map[string]string { + var ids []string + for i := utils.NumberZero; i < len(data); i++ { + ids = append(ids, strings.Split(data[i].Rules, utils.DecollatorComma)...) + } + + w := modelbase.Params{ + In: map[string][]string{"id in ?": ids}, + Other: map[string]string{"type != ?": strconv.Itoa(dao.TypeDir)}, + } + var items []dao.AuthorityNames + retData := make(map[string]string) + + err := model.AuthorityModel{}.Init().Items(w, &items) + if err != nil { + return retData + } + + for i := utils.NumberZero; i < len(items); i++ { + retData[strconv.Itoa(int(items[i].Id))] = items[i].Name + } + + return retData +} diff --git a/admin/internal/logic/rolenameslogic.go b/admin/internal/logic/rolenameslogic.go new file mode 100644 index 0000000..a1e65a3 --- /dev/null +++ b/admin/internal/logic/rolenameslogic.go @@ -0,0 +1,74 @@ +package logic + +import ( + "admin/admin" + "admin/internal/dao" + "admin/internal/model" + "admin/internal/svc" + "context" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type RoleNamesLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewRoleNamesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleNamesLogic { + return &RoleNamesLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *RoleNamesLogic) RoleNames(in *admin.RoleNameRequest) (*admin.Response, error) { + var services []dao.ServicesNames + w := modelbase.Params{ + Eq: map[string]string{"status": utils.StringStatusOk}, + } + err := model.ServicesModel{}.Init().Items(w, &services) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + + var items []dao.RoleServiceNameItems + var roles []dao.Role + modelObj := model.RoleModel{}.Init() + w = modelbase.Params{ + Eq: map[string]string{"status": utils.StringStatusOk}, + } + w.Like = make(map[string]string) + if len(in.Name) > utils.NumberZero { + w.Like["name LIKE ? "] = "%%" + in.Name + "%%" + } + err = modelObj.Items(w, &roles) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + tmp := map[int64][]dao.RoleNameItems{} + for _, item := range roles { + tmp[item.ServiceId] = append(tmp[item.ServiceId], dao.RoleNameItems{ + Name: item.Name, + Id: item.Id, + }) + } + for _, pro := range services { + if _, ok := tmp[pro.Id]; ok { + items = append(items, dao.RoleServiceNameItems{ + Id: pro.Id, + Name: pro.Name, + Items: tmp[pro.Id], + }) + } + } + + return l.ok(items), nil +} diff --git a/admin/internal/logic/rolerulelogic.go b/admin/internal/logic/rolerulelogic.go new file mode 100644 index 0000000..c72e5c2 --- /dev/null +++ b/admin/internal/logic/rolerulelogic.go @@ -0,0 +1,63 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "strconv" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type RoleRuleLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewRoleRuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleRuleLogic { + return &RoleRuleLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *RoleRuleLogic) RoleRule(in *admin.RoleRuleRequest) (*admin.Response, error) { + var v validator.RoleRuleValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo), nil + } + info := dao.RoleRule{} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} + modelObj := model.RoleModel{}.Init() + err := modelObj.GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund), nil + } + info.Rules = in.Rule + info.AdminId = adminInfo.ID + info.AdminName = adminInfo.Name + _, editErr := modelObj.Edit(w, info) + if editErr != nil { + l.Logger.Error(editErr) + return l.fail(utils.Fail), nil + } + + return l.ok(utils.NumberOne), nil +} diff --git a/admin/internal/logic/rolestatuslogic.go b/admin/internal/logic/rolestatuslogic.go new file mode 100644 index 0000000..bc1d3ad --- /dev/null +++ b/admin/internal/logic/rolestatuslogic.go @@ -0,0 +1,65 @@ +package logic + +import ( + "admin/internal/dao" + "admin/internal/model" + "admin/validator" + "context" + "strconv" + + "admin/admin" + "admin/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" + "pkg.local/modelbase" + "pkg.local/utils" +) + +type RoleStatusLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewRoleStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleStatusLogic { + return &RoleStatusLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *RoleStatusLogic) RoleStatus(in *admin.StatusRequest) (*admin.Response, error) { + var v validator.RoleStatusValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo), nil + } + + info := dao.RoleStatus{} + w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}} + modelObj := model.RoleModel{}.Init() + err := modelObj.GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund), nil + } + info.Status = uint8(in.Status) + info.Reason = in.Reason + info.AdminId = adminInfo.ID + info.AdminName = adminInfo.Name + _, editErr := modelObj.Edit(w, info) + if editErr != nil { + l.Logger.Error(editErr) + return l.fail(utils.Fail), nil + } + + return l.ok(utils.NumberOne), nil +} diff --git a/admin/internal/server/adminserver.go b/admin/internal/server/adminserver.go index 112c231..a587a0e 100644 --- a/admin/internal/server/adminserver.go +++ b/admin/internal/server/adminserver.go @@ -68,6 +68,11 @@ func (s *AdminServer) LoginInfo(ctx context.Context, in *admin.AdminEmptyRequest return l.LoginInfo(in) } +func (s *AdminServer) LoginRoutes(ctx context.Context, in *admin.AdminEmptyRequest) (*admin.Response, error) { + l := logic.NewLoginRoutesLogic(ctx, s.svcCtx) + return l.LoginRoutes(in) +} + func (s *AdminServer) ServiceInfo(ctx context.Context, in *admin.InfoRequest) (*admin.Response, error) { l := logic.NewServiceInfoLogic(ctx, s.svcCtx) return l.ServiceInfo(in) @@ -122,3 +127,33 @@ func (s *AdminServer) AuthoritySort(ctx context.Context, in *admin.AuthoritySort l := logic.NewAuthoritySortLogic(ctx, s.svcCtx) return l.AuthoritySort(in) } + +func (s *AdminServer) RoleNames(ctx context.Context, in *admin.RoleNameRequest) (*admin.Response, error) { + l := logic.NewRoleNamesLogic(ctx, s.svcCtx) + return l.RoleNames(in) +} + +func (s *AdminServer) RoleInfo(ctx context.Context, in *admin.InfoRequest) (*admin.Response, error) { + l := logic.NewRoleInfoLogic(ctx, s.svcCtx) + return l.RoleInfo(in) +} + +func (s *AdminServer) RoleEdit(ctx context.Context, in *admin.RoleEditRequest) (*admin.Response, error) { + l := logic.NewRoleEditLogic(ctx, s.svcCtx) + return l.RoleEdit(in) +} + +func (s *AdminServer) RoleItems(ctx context.Context, in *admin.RoleItemsRequest) (*admin.Response, error) { + l := logic.NewRoleItemsLogic(ctx, s.svcCtx) + return l.RoleItems(in) +} + +func (s *AdminServer) RoleStatus(ctx context.Context, in *admin.StatusRequest) (*admin.Response, error) { + l := logic.NewRoleStatusLogic(ctx, s.svcCtx) + return l.RoleStatus(in) +} + +func (s *AdminServer) RoleRule(ctx context.Context, in *admin.RoleRuleRequest) (*admin.Response, error) { + l := logic.NewRoleRuleLogic(ctx, s.svcCtx) + return l.RoleRule(in) +} diff --git a/admin/proto/admin.proto b/admin/proto/admin.proto index b118ff6..e23cb3d 100644 --- a/admin/proto/admin.proto +++ b/admin/proto/admin.proto @@ -45,9 +45,9 @@ message AdminItemsRequest { int32 page = 1; int32 size = 2; string phone = 3; - string name = 5; - string email = 6; - int32 status = 7; + string name = 4; + string email = 5; + int32 status = 6; } message AdminLoginRequest { @@ -112,7 +112,30 @@ message AuthorityEditRequest { string data_tree_department = 18; string data_tree_oneself = 19; } +message RoleRuleRequest { + int64 id = 1; + string rule = 2; +} +message RoleNameRequest { + string name = 1; + int64 service_id = 2; +} +message RoleEditRequest { + int64 id = 1; + string name = 2; + int64 service_id = 3; + repeated int64 rules = 4; + +} + +message RoleItemsRequest { + int32 page = 1; + int32 size = 2; + int64 service_id = 3; + string name = 4; + int32 status = 5; +} service Admin { rpc AdminEdit(AdminEditRequest) returns(Response){ @@ -169,6 +192,12 @@ service Admin { body: "*" }; }; + rpc LoginRoutes(AdminEmptyRequest) returns(Response){ + option (google.api.http) = { + post: "/admin/v3/routes" + body: "*" + }; + }; rpc ServiceInfo(InfoRequest) returns(Response){ option (google.api.http) = { get: "/admin/v3/service/info" @@ -217,7 +246,7 @@ service Admin { body: "*" }; }; - rpc authorityStatus(StatusRequest) returns(Response){ + rpc AuthorityStatus(StatusRequest) returns(Response){ option (google.api.http) = { post: "/admin/v3/authority/status" body: "*" @@ -235,4 +264,40 @@ service Admin { body: "*" }; }; + rpc RoleNames(RoleNameRequest) returns(Response){ + option (google.api.http) = { + get: "/admin/v3/role/names" + body: "*" + }; + }; + rpc RoleInfo(InfoRequest) returns(Response){ + option (google.api.http) = { + get: "/admin/v3/role/info" + body: "*" + }; + }; + rpc RoleEdit(RoleEditRequest) returns(Response){ + option (google.api.http) = { + post: "/admin/v3/role/edit" + body: "*" + }; + }; + rpc RoleItems(RoleItemsRequest) returns(Response){ + option (google.api.http) = { + get: "/admin/v3/role/items" + body: "*" + }; + }; + rpc RoleStatus(StatusRequest) returns(Response){ + option (google.api.http) = { + post: "/admin/v3/role/status" + body: "*" + }; + }; + rpc RoleRule(RoleRuleRequest) returns(Response){ + option (google.api.http) = { + get: "/admin/v3/role/rule" + body: "*" + }; + }; } \ No newline at end of file diff --git a/admin/validator/admin.go b/admin/validator/admin.go index ea3ee33..afc8bd5 100644 --- a/admin/validator/admin.go +++ b/admin/validator/admin.go @@ -109,3 +109,14 @@ func (p LoginValidator) GetMessage() validate.ValidatorMessages { "Password.required": "密码不能为空", } } + +type LoginRoutesValidator struct { + ServiceId int `validate:"required"` +} + +// GetMessage 提示消息 +func (p LoginRoutesValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "ServiceId.required": "服务ID不能为空", + } +} diff --git a/admin/validator/role.go b/admin/validator/role.go new file mode 100644 index 0000000..0726230 --- /dev/null +++ b/admin/validator/role.go @@ -0,0 +1,78 @@ +package validator + +import "pkg.local/validate" + +// RoleEditValidator 创建/编辑 +type RoleEditValidator struct { + Id int64 + Name string `validate:"required"` + ServiceId int64 `validate:"required"` + Rules []int64 +} + +// GetMessage 创建 - 提示消息 +func (p RoleEditValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Name.required": "名称不能为空", + "ServiceId.required": "服务ID不能为空", + } +} + +// RoleInfoValidator 查看信息 +type RoleInfoValidator struct { + Id int64 `validate:"required"` +} + +// GetMessage 查看信息 - 提示消息 +func (p RoleInfoValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID不能为空", + } +} + +// RoleItemsValidator 查看列表 +type RoleItemsValidator struct { + Page int32 + Size int32 + Name string + Status int32 + ServiceId int64 `validate:"required"` +} + +// GetMessage 查看列表 - 提示消息 +func (p RoleItemsValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "ServiceId.required": "服务ID不能为空", + } +} + +// RoleStatusValidator 修改状态 +type RoleStatusValidator struct { + Id int64 `validate:"required"` + Status int32 `validate:"required,oneof=1 2"` + Reason string `validate:"required_if=Status 2"` +} + +// GetMessage 修改状态 - 提示消息 +func (p RoleStatusValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID不能为空", + "Status.required": "状态不能为空", + "Status.oneof": "状态传值不对", + "Reason.required_if": "理由不能为空", + } +} + +// RoleRuleValidator 编辑权限 +type RoleRuleValidator struct { + Id int64 ` validate:"required"` + Rule string `validate:"required"` +} + +// GetMessage 修改状态 - 提示消息 +func (p RoleRuleValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID不能为空", + "Rule.required": "权限不能为空", + } +} diff --git a/bff/etc/admin.pb b/bff/etc/admin.pb index 1998b33..72b9ffb 100644 Binary files a/bff/etc/admin.pb and b/bff/etc/admin.pb differ diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6c35314 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module lone-services + +go 1.26.5