This commit is contained in:
oneao committed 2025-12-04 21:48:22 +08:00
1 parent 59d3be2299
commit 33ab76f73e
13 files changed
+172 -374

No files matched your search

@@ -39,13 +39,6 @@ export default function Share() {
</TouchableOpacity>
</View>
<AModal
title="确认退出当前账号?"
isOpen={showExitModal}
onCancel={() => setShowExitModal(false)}
onClose={() => setShowExitModal(false)}
onConfirm={exitLogin}
/>
</View>
</View>
)
}
@@ -1,10 +1,17 @@
import type { SpaceUser, UserSpace } from '@/types/space/spaceUser'
import * as Clipboard from 'expo-clipboard'
import { useState } from 'react'
import { FlatList, Pressable, TouchableOpacity, View } from 'react-native'
import { FlatList, TouchableHighlight, TouchableOpacity, View } from 'react-native'
import {
Menu,
MenuOption,
MenuOptions,
MenuTrigger,
renderers,
} from 'react-native-popup-menu'
import QRCode from 'react-native-qrcode-svg'
import { AButton, ADivider, LucideIcon } from '@/components/common/ao'
import { AModal } from '@/components/common/ao/index'
import {
Accordion,
AccordionContent,
@@ -23,9 +30,9 @@ import { Badge, BadgeText } from '@/components/ui/badge'
import { Heading } from '@/components/ui/heading'
import { HStack } from '@/components/ui/hstack'
import { ChevronDownIcon, ChevronUpIcon } from '@/components/ui/icon'
import { Menu, MenuItem, MenuItemLabel } from '@/components/ui/menu'
import { Text } from '@/components/ui/text'
import { VStack } from '@/components/ui/vstack'
import { exitSpaceApi } from '@/request/api/space/spaceUser'
import { useUserStore } from '@/store/user'
import { formatRelativeTime } from '@/utils/time'
import { toast } from '@/utils/toast'
@@ -41,6 +48,17 @@ export default function SpaceInvite({
}: SpaceInviteProps) {
const userStore = useUserStore()
// 踢出 退出 解散
const [modal, setModal] = useState<{
open: boolean
title: string
type: 'exit' | 'remove' | 'dissolve'
}>({
open: false,
title: '',
type: 'dissolve',
})
,
const [accordion, setAccordion] = useState(['a'])
async function copyInviteCode() {
@@ -51,6 +69,10 @@ export default function SpaceInvite({
})
}
function exitSpace() {
}
return (
<View className="px-4 flex-1">
<Accordion
@@ -143,53 +165,83 @@ export default function SpaceInvite({
<VStack>
<HStack space="sm">
<Heading size="sm">{item.username}</Heading>
{[0, 1].includes(item.space_role) && (
{item.space_role === 0 && (
<Badge size="sm" variant="solid" action="muted">
<BadgeText>
{item.space_role === 0 ? '创建者' : '管理员'}
</BadgeText>
<BadgeText>创建者</BadgeText>
</Badge>
)}
{
(userStore.userInfo?.id === item.user_id) && (
<Badge size="sm" variant="solid" action='info'>
userStore.userInfo?.id === item.user_id && (
<Badge size="sm" variant="solid" action="info">
<BadgeText>
我
</BadgeText>
</Badge>
)
}
</HStack>
<Text size="sm" className="mt-1">{formatRelativeTime(item.active_time)}</Text>
</VStack>
<View className="ml-auto">
<Menu
placement="top"
offset={5}
trigger={triggerProps => (
<Pressable
{...triggerProps}
style={{
padding: 8,
justifyContent: 'center',
alignItems: 'center',
{userSpace?.role === 0 && (
<View className="ml-auto">
<Menu
renderer={renderers.Popover}
rendererProps={{
placement: 'bottom',
preferredPlacement: 'bottom',
anchorStyle: { backgroundColor: 'transparent' },
closeAnimationDuration: 0,
}}
>
<MenuTrigger>
<View className="w-12 items-center justify-center h-10">
<LucideIcon icon="Menu" size={20} clickable={false} />
</View>
</MenuTrigger>
<MenuOptions
customStyles={{
optionsContainer: {
backgroundColor: 'white',
minWidth: 160,
},
}}
>
<LucideIcon icon="EllipsisVertical" size={20} clickable={false} />
</Pressable>
)}
>
<MenuItem key="Add account" textValue="Add account">
<MenuItemLabel size="sm">添加为管理员</MenuItemLabel>
</MenuItem>
<MenuItem key="Community" textValue="Community">
<MenuItemLabel size="sm">移出空间</MenuItemLabel>
</MenuItem>
</Menu>
</View>
<MenuOption
customStyles={{
OptionTouchableComponent: TouchableHighlight,
optionTouchable: {
underlayColor: '#f0f0f0',
activeOpacity: 0.7,
},
}}
onSelect={() => {
}}
>
<View className="flex flex-row items-center h-10 px-2">
<Text className="text-lg">授予管理员</Text>
</View>
</MenuOption>
<MenuOption
customStyles={{
OptionTouchableComponent: TouchableHighlight,
optionTouchable: {
underlayColor: '#f0f0f0',
activeOpacity: 0.7,
},
}}
onSelect={() => {
}}
>
<View className="flex flex-row items-center h-10 px-2">
<Text className="text-lg">踢出空间</Text>
</View>
</MenuOption>
</MenuOptions>
</Menu>
</View>
)}
</HStack>
</TouchableOpacity>
)}
@@ -197,6 +249,14 @@ export default function SpaceInvite({
</View>
<AButton size="sm" className="mb-8 mt-4">退出该空间</AButton>
</View>
<AModal
title="确认退出当前账号?"
isOpen={showExitModal}
onCancel={() => setShowExitModal(false)}
onClose={() => setShowExitModal(false)}
onConfirm={exitLogin}
/>
</View>
)
}
@@ -61,7 +61,7 @@ export default function CustomHeader(props: CustomHeaderProps) {
{...screenProps}
options={{
...screenProps?.options,
headerShown: false,
headerShown: true,
header: () => (
<SafeAreaView
className={`${className}`}
@@ -31,8 +31,8 @@ function isWhiteListed(url: string) {
}
const alovaInstance = createAlova({
// baseURL: 'http://192.168.5.6:8086/app',
baseURL: 'http://192.168.1.136:8086/app',
baseURL: 'http://192.168.5.6:8086/app',
// baseURL: 'http://192.168.1.136:8086/app',
requestAdapter: axiosRequestAdapter(),
timeout: 5000,
cacheFor: null,
@@ -49,17 +49,6 @@ export interface RemoveSpaceUserResult {
}
// 更新用户权限
export interface UpdateSpaceUserRoleParams {
space_id: number
user_id: number
role: number
}
export interface UpdateSpaceUserRoleResult {
}
// 加入空间
export interface JoinSpaceParams {
invite_code: string
@@ -155,82 +155,6 @@ func RemoveSpaceUser(ctx context.Context, c *app.RequestContext) {
response.Success(c).Message("移除成功").Send()
}
// UpdateSpaceUserRole .
// @router /space/user/updateRole [POST]
func UpdateSpaceUserRole(ctx context.Context, c *app.RequestContext) {
var req space.UpdateSpaceUserRoleParams
if err := c.BindAndValidate(&req); err != nil {
c.String(consts.StatusBadRequest, err.Error())
return
}
// 1. 获取当前操作者信息
userID := middleware.GetUserID(ctx)
operator, err := db.Queries.GetSpaceUserByUserId(ctx, userID)
if err != nil {
if errorx.IsNotFound(err) {
response.Fail(c).Message("权限不足").Send()
return
}
errorx.AddError(c, err)
return
}
// 2. 检查操作者是否属于该空间
if operator.SpaceID != req.SpaceId {
response.Fail(c).Message("权限不足").Send()
return
}
// 3. 权限检查:只有创建者可以修改他人角色
// 假设 Role: 0=创建者, 1=管理员, 2=普通成员
if operator.Role != 0 {
response.Fail(c).Message("权限不足").Send()
return
}
// 3.1 不允许修改自己的角色
if operator.UserID == req.UserId {
response.Fail(c).Message("不能修改自己的角色").Send()
return
}
// 4. 校验目标 Role 是否合法
if req.Role != 1 && req.Role != 2 {
response.Fail(c).Message("角色修改错误").Send()
return
}
// 5. 获取被修改的用户
targetUser, err := db.Queries.GetSpaceUserByUserId(ctx, req.UserId)
if err != nil {
if errorx.IsNotFound(err) {
response.Fail(c).Message("目标用户不存在").Send()
return
}
errorx.AddError(c, err)
return
}
if targetUser.SpaceID != req.SpaceId {
response.Fail(c).Message("目标用户不在该空间").Send()
return
}
// 6. 执行更新
err = db.Queries.UpdateSpaceUserRole(ctx, repo.UpdateSpaceUserRoleParams{
SpaceID: req.SpaceId,
UserID: req.UserId,
Role: req.Role,
})
if err != nil {
errorx.AddError(c, err)
return
}
response.Success(c).Send()
}
// JoinSpace .
// @router /space/user/join [POST]
func JoinSpace(ctx context.Context, c *app.RequestContext) {
@@ -275,7 +199,7 @@ func JoinSpace(ctx context.Context, c *app.RequestContext) {
ID: idgen.NextId(),
SpaceID: spaceByCode.ID,
UserID: userID,
Role: 2,
Role: 1,
}
err = db.Queries.InsertSpaceUser(ctx, params)
@@ -3,7 +3,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v4.25.3
// protoc v6.33.1
// source: api.proto
package api
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v4.25.3
// protoc v6.33.1
// source: space.proto
package space
@@ -40,7 +40,7 @@ var file_space_proto_rawDesc = []byte{
0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1a, 0x2e, 0x73, 0x70, 0x61,
0x63, 0x65, 0x2e, 0x44, 0x69, 0x73, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65,
0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x13, 0xd2, 0xc1, 0x18, 0x0f, 0x2f, 0x73, 0x70, 0x61,
0x63, 0x65, 0x2f, 0x64, 0x69, 0x73, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x32, 0xd3, 0x04, 0x0a, 0x10,
0x63, 0x65, 0x2f, 0x64, 0x69, 0x73, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x32, 0xdc, 0x03, 0x0a, 0x10,
0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x12, 0x59, 0x0a, 0x0c, 0x67, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65,
0x12, 0x19, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72,
@@ -65,40 +65,31 @@ var file_space_proto_rawDesc = []byte{
0x73, 0x1a, 0x1c, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22,
0x16, 0xd2, 0xc1, 0x18, 0x12, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x75, 0x73, 0x65, 0x72,
0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x75, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x20,
0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61,
0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x1a, 0x20, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53,
0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x75,
0x6c, 0x74, 0x22, 0x1a, 0xd2, 0xc1, 0x18, 0x16, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x75,
0x73, 0x65, 0x72, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x51,
0x0a, 0x09, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x16, 0x2e, 0x73, 0x70,
0x61, 0x63, 0x65, 0x2e, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72,
0x61, 0x6d, 0x73, 0x1a, 0x16, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x4a, 0x6f, 0x69, 0x6e,
0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x14, 0xd2, 0xc1, 0x18,
0x10, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x6a, 0x6f, 0x69,
0x6e, 0x42, 0x22, 0x5a, 0x20, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61,
0x73, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f,
0x73, 0x70, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x51, 0x0a, 0x09, 0x4a, 0x6f, 0x69, 0x6e, 0x53,
0x70, 0x61, 0x63, 0x65, 0x12, 0x16, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x4a, 0x6f, 0x69,
0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x16, 0x2e, 0x73,
0x70, 0x61, 0x63, 0x65, 0x2e, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65,
0x73, 0x75, 0x6c, 0x74, 0x22, 0x14, 0xd2, 0xc1, 0x18, 0x10, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65,
0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x6a, 0x6f, 0x69, 0x6e, 0x42, 0x22, 0x5a, 0x20, 0x63, 0x6e,
0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x62,
0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_space_proto_goTypes = []interface{}{
(*CreateSpaceParams)(nil), // 0: space.CreateSpaceParams
(*DissolveSpaceParams)(nil), // 1: space.DissolveSpaceParams
(*GetUserSpaceParams)(nil), // 2: space.GetUserSpaceParams
(*ExitSpaceParams)(nil), // 3: space.ExitSpaceParams
(*ListSpaceUsersParams)(nil), // 4: space.ListSpaceUsersParams
(*RemoveSpaceUserParams)(nil), // 5: space.RemoveSpaceUserParams
(*UpdateSpaceUserRoleParams)(nil), // 6: space.UpdateSpaceUserRoleParams
(*JoinSpaceParams)(nil), // 7: space.JoinSpaceParams
(*DissolveSpaceResult)(nil), // 8: space.DissolveSpaceResult
(*GetUserSpaceResult)(nil), // 9: space.GetUserSpaceResult
(*ExitSpaceResult)(nil), // 10: space.ExitSpaceResult
(*ListSpaceUsersResult)(nil), // 11: space.ListSpaceUsersResult
(*RemoveSpaceUserResult)(nil), // 12: space.RemoveSpaceUserResult
(*UpdateSpaceUserRoleResult)(nil), // 13: space.UpdateSpaceUserRoleResult
(*JoinSpaceResult)(nil), // 14: space.JoinSpaceResult
(*CreateSpaceParams)(nil), // 0: space.CreateSpaceParams
(*DissolveSpaceParams)(nil), // 1: space.DissolveSpaceParams
(*GetUserSpaceParams)(nil), // 2: space.GetUserSpaceParams
(*ExitSpaceParams)(nil), // 3: space.ExitSpaceParams
(*ListSpaceUsersParams)(nil), // 4: space.ListSpaceUsersParams
(*RemoveSpaceUserParams)(nil), // 5: space.RemoveSpaceUserParams
(*JoinSpaceParams)(nil), // 6: space.JoinSpaceParams
(*DissolveSpaceResult)(nil), // 7: space.DissolveSpaceResult
(*GetUserSpaceResult)(nil), // 8: space.GetUserSpaceResult
(*ExitSpaceResult)(nil), // 9: space.ExitSpaceResult
(*ListSpaceUsersResult)(nil), // 10: space.ListSpaceUsersResult
(*RemoveSpaceUserResult)(nil), // 11: space.RemoveSpaceUserResult
(*JoinSpaceResult)(nil), // 12: space.JoinSpaceResult
}
var file_space_proto_depIdxs = []int32{
0, // 0: space.SpaceService.CreateSpace:input_type -> space.CreateSpaceParams
@@ -107,18 +98,16 @@ var file_space_proto_depIdxs = []int32{
3, // 3: space.SpaceUserService.ExitSpace:input_type -> space.ExitSpaceParams
4, // 4: space.SpaceUserService.ListSpaceUsers:input_type -> space.ListSpaceUsersParams
5, // 5: space.SpaceUserService.RemoveSpaceUser:input_type -> space.RemoveSpaceUserParams
6, // 6: space.SpaceUserService.UpdateSpaceUserRole:input_type -> space.UpdateSpaceUserRoleParams
7, // 7: space.SpaceUserService.JoinSpace:input_type -> space.JoinSpaceParams
0, // 8: space.SpaceService.CreateSpace:output_type -> space.CreateSpaceParams
8, // 9: space.SpaceService.DissolveSpace:output_type -> space.DissolveSpaceResult
9, // 10: space.SpaceUserService.getUserSpace:output_type -> space.GetUserSpaceResult
10, // 11: space.SpaceUserService.ExitSpace:output_type -> space.ExitSpaceResult
11, // 12: space.SpaceUserService.ListSpaceUsers:output_type -> space.ListSpaceUsersResult
12, // 13: space.SpaceUserService.RemoveSpaceUser:output_type -> space.RemoveSpaceUserResult
13, // 14: space.SpaceUserService.UpdateSpaceUserRole:output_type -> space.UpdateSpaceUserRoleResult
14, // 15: space.SpaceUserService.JoinSpace:output_type -> space.JoinSpaceResult
8, // [8:16] is the sub-list for method output_type
0, // [0:8] is the sub-list for method input_type
6, // 6: space.SpaceUserService.JoinSpace:input_type -> space.JoinSpaceParams
0, // 7: space.SpaceService.CreateSpace:output_type -> space.CreateSpaceParams
7, // 8: space.SpaceService.DissolveSpace:output_type -> space.DissolveSpaceResult
8, // 9: space.SpaceUserService.getUserSpace:output_type -> space.GetUserSpaceResult
9, // 10: space.SpaceUserService.ExitSpace:output_type -> space.ExitSpaceResult
10, // 11: space.SpaceUserService.ListSpaceUsers:output_type -> space.ListSpaceUsersResult
11, // 12: space.SpaceUserService.RemoveSpaceUser:output_type -> space.RemoveSpaceUserResult
12, // 13: space.SpaceUserService.JoinSpace:output_type -> space.JoinSpaceResult
7, // [7:14] is the sub-list for method output_type
0, // [0:7] 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
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v4.25.3
// protoc v6.33.1
// source: space/space_types.proto
package space
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v4.25.3
// protoc v6.33.1
// source: space/space_user_types.proto
package space
@@ -435,108 +435,6 @@ func (*RemoveSpaceUserResult) Descriptor() ([]byte, []int) {
return file_space_space_user_types_proto_rawDescGZIP(), []int{8}
}
// 更新用户权限
type UpdateSpaceUserRoleParams struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
SpaceId int64 `protobuf:"varint,1,opt,name=SpaceId,proto3" form:"space_id" json:"space_id" vd:"$ != 0"`
UserId int64 `protobuf:"varint,2,opt,name=UserId,proto3" form:"user_id" json:"user_id" vd:"$ != 0"`
Role int32 `protobuf:"varint,3,opt,name=Role,proto3" form:"role" json:"role" vd:"$ == 1 || $ == 2"`
}
func (x *UpdateSpaceUserRoleParams) Reset() {
*x = UpdateSpaceUserRoleParams{}
if protoimpl.UnsafeEnabled {
mi := &file_space_space_user_types_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateSpaceUserRoleParams) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateSpaceUserRoleParams) ProtoMessage() {}
func (x *UpdateSpaceUserRoleParams) ProtoReflect() protoreflect.Message {
mi := &file_space_space_user_types_proto_msgTypes[9]
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 UpdateSpaceUserRoleParams.ProtoReflect.Descriptor instead.
func (*UpdateSpaceUserRoleParams) Descriptor() ([]byte, []int) {
return file_space_space_user_types_proto_rawDescGZIP(), []int{9}
}
func (x *UpdateSpaceUserRoleParams) GetSpaceId() int64 {
if x != nil {
return x.SpaceId
}
return 0
}
func (x *UpdateSpaceUserRoleParams) GetUserId() int64 {
if x != nil {
return x.UserId
}
return 0
}
func (x *UpdateSpaceUserRoleParams) GetRole() int32 {
if x != nil {
return x.Role
}
return 0
}
type UpdateSpaceUserRoleResult struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *UpdateSpaceUserRoleResult) Reset() {
*x = UpdateSpaceUserRoleResult{}
if protoimpl.UnsafeEnabled {
mi := &file_space_space_user_types_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UpdateSpaceUserRoleResult) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UpdateSpaceUserRoleResult) ProtoMessage() {}
func (x *UpdateSpaceUserRoleResult) ProtoReflect() protoreflect.Message {
mi := &file_space_space_user_types_proto_msgTypes[10]
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 UpdateSpaceUserRoleResult.ProtoReflect.Descriptor instead.
func (*UpdateSpaceUserRoleResult) Descriptor() ([]byte, []int) {
return file_space_space_user_types_proto_rawDescGZIP(), []int{10}
}
// 获取当前用户的空间信息
type GetUserSpaceParams struct {
state protoimpl.MessageState
@@ -547,7 +445,7 @@ type GetUserSpaceParams struct {
func (x *GetUserSpaceParams) Reset() {
*x = GetUserSpaceParams{}
if protoimpl.UnsafeEnabled {
mi := &file_space_space_user_types_proto_msgTypes[11]
mi := &file_space_space_user_types_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -560,7 +458,7 @@ func (x *GetUserSpaceParams) String() string {
func (*GetUserSpaceParams) ProtoMessage() {}
func (x *GetUserSpaceParams) ProtoReflect() protoreflect.Message {
mi := &file_space_space_user_types_proto_msgTypes[11]
mi := &file_space_space_user_types_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -573,7 +471,7 @@ func (x *GetUserSpaceParams) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetUserSpaceParams.ProtoReflect.Descriptor instead.
func (*GetUserSpaceParams) Descriptor() ([]byte, []int) {
return file_space_space_user_types_proto_rawDescGZIP(), []int{11}
return file_space_space_user_types_proto_rawDescGZIP(), []int{9}
}
type GetUserSpaceResult struct {
@@ -590,7 +488,7 @@ type GetUserSpaceResult struct {
func (x *GetUserSpaceResult) Reset() {
*x = GetUserSpaceResult{}
if protoimpl.UnsafeEnabled {
mi := &file_space_space_user_types_proto_msgTypes[12]
mi := &file_space_space_user_types_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -603,7 +501,7 @@ func (x *GetUserSpaceResult) String() string {
func (*GetUserSpaceResult) ProtoMessage() {}
func (x *GetUserSpaceResult) ProtoReflect() protoreflect.Message {
mi := &file_space_space_user_types_proto_msgTypes[12]
mi := &file_space_space_user_types_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -616,7 +514,7 @@ func (x *GetUserSpaceResult) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetUserSpaceResult.ProtoReflect.Descriptor instead.
func (*GetUserSpaceResult) Descriptor() ([]byte, []int) {
return file_space_space_user_types_proto_rawDescGZIP(), []int{12}
return file_space_space_user_types_proto_rawDescGZIP(), []int{10}
}
func (x *GetUserSpaceResult) GetSpaceId() int64 {
@@ -688,35 +586,22 @@ var file_space_space_user_types_proto_rawDesc = []byte{
0x72, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06, 0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x06,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x17, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65,
0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22,
0xae, 0x01, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55,
0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x30, 0x0a,
0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x16,
0xca, 0xbb, 0x18, 0x08, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06,
0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x12,
0x2d, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42,
0x15, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x06,
0x24, 0x20, 0x21, 0x3d, 0x20, 0x30, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x30,
0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x1c, 0xca, 0xbb,
0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0xda, 0xbb, 0x18, 0x10, 0x24, 0x20, 0x3d, 0x3d, 0x20, 0x31,
0x20, 0x7c, 0x7c, 0x20, 0x24, 0x20, 0x3d, 0x3d, 0x20, 0x32, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65,
0x22, 0x1b, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55,
0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x14, 0x0a,
0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72,
0x61, 0x6d, 0x73, 0x22, 0xb9, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53,
0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x53, 0x70,
0x61, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, 0xca, 0xbb, 0x18,
0x08, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65,
0x49, 0x64, 0x12, 0x2c, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x0a, 0x73, 0x70, 0x61, 0x63, 0x65,
0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65,
0x12, 0x2f, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x69, 0x6e, 0x76, 0x69, 0x74, 0x65,
0x5f, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64,
0x65, 0x12, 0x1c, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x42,
0x08, 0xca, 0xbb, 0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x42,
0x22, 0x5a, 0x20, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65,
0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70,
0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x14, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50,
0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0xb9, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65,
0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x07,
0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, 0xca,
0xbb, 0x18, 0x08, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x52, 0x07, 0x53, 0x70, 0x61,
0x63, 0x65, 0x49, 0x64, 0x12, 0x2c, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xca, 0xbb, 0x18, 0x0a, 0x73, 0x70, 0x61,
0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61,
0x6d, 0x65, 0x12, 0x2f, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xca, 0xbb, 0x18, 0x0b, 0x69, 0x6e, 0x76, 0x69,
0x74, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43,
0x6f, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
0x05, 0x42, 0x08, 0xca, 0xbb, 0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x52, 0x6f, 0x6c,
0x65, 0x42, 0x22, 0x5a, 0x20, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61,
0x73, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f,
0x73, 0x70, 0x61, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -731,21 +616,19 @@ func file_space_space_user_types_proto_rawDescGZIP() []byte {
return file_space_space_user_types_proto_rawDescData
}
var file_space_space_user_types_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_space_space_user_types_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_space_space_user_types_proto_goTypes = []interface{}{
(*ListSpaceUsersParams)(nil), // 0: space.ListSpaceUsersParams
(*SpaceUser)(nil), // 1: space.SpaceUser
(*ListSpaceUsersResult)(nil), // 2: space.ListSpaceUsersResult
(*JoinSpaceParams)(nil), // 3: space.JoinSpaceParams
(*JoinSpaceResult)(nil), // 4: space.JoinSpaceResult
(*ExitSpaceParams)(nil), // 5: space.ExitSpaceParams
(*ExitSpaceResult)(nil), // 6: space.ExitSpaceResult
(*RemoveSpaceUserParams)(nil), // 7: space.RemoveSpaceUserParams
(*RemoveSpaceUserResult)(nil), // 8: space.RemoveSpaceUserResult
(*UpdateSpaceUserRoleParams)(nil), // 9: space.UpdateSpaceUserRoleParams
(*UpdateSpaceUserRoleResult)(nil), // 10: space.UpdateSpaceUserRoleResult
(*GetUserSpaceParams)(nil), // 11: space.GetUserSpaceParams
(*GetUserSpaceResult)(nil), // 12: space.GetUserSpaceResult
(*ListSpaceUsersParams)(nil), // 0: space.ListSpaceUsersParams
(*SpaceUser)(nil), // 1: space.SpaceUser
(*ListSpaceUsersResult)(nil), // 2: space.ListSpaceUsersResult
(*JoinSpaceParams)(nil), // 3: space.JoinSpaceParams
(*JoinSpaceResult)(nil), // 4: space.JoinSpaceResult
(*ExitSpaceParams)(nil), // 5: space.ExitSpaceParams
(*ExitSpaceResult)(nil), // 6: space.ExitSpaceResult
(*RemoveSpaceUserParams)(nil), // 7: space.RemoveSpaceUserParams
(*RemoveSpaceUserResult)(nil), // 8: space.RemoveSpaceUserResult
(*GetUserSpaceParams)(nil), // 9: space.GetUserSpaceParams
(*GetUserSpaceResult)(nil), // 10: space.GetUserSpaceResult
}
var file_space_space_user_types_proto_depIdxs = []int32{
1, // 0: space.ListSpaceUsersResult.users:type_name -> space.SpaceUser
@@ -871,30 +754,6 @@ func file_space_space_user_types_proto_init() {
}
}
file_space_space_user_types_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateSpaceUserRoleParams); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_space_space_user_types_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateSpaceUserRoleResult); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_space_space_user_types_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserSpaceParams); i {
case 0:
return &v.state
@@ -906,7 +765,7 @@ func file_space_space_user_types_proto_init() {
return nil
}
}
file_space_space_user_types_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
file_space_space_user_types_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetUserSpaceResult); i {
case 0:
return &v.state
@@ -925,7 +784,7 @@ func file_space_space_user_types_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_space_space_user_types_proto_rawDesc,
NumEnums: 0,
NumMessages: 13,
NumMessages: 11,
NumExtensions: 0,
NumServices: 0,
},
@@ -28,7 +28,6 @@ func Register(r *server.Hertz) {
_user.POST("/join", append(_joinspaceMw(), space.JoinSpace)...)
_user.POST("/list", append(_listspaceusersMw(), space.ListSpaceUsers)...)
_user.POST("/remove", append(_removespaceuserMw(), space.RemoveSpaceUser)...)
_user.POST("/updateRole", append(_updatespaceuserroleMw(), space.UpdateSpaceUserRole)...)
}
}
}
@@ -36,10 +36,6 @@ service SpaceUserService{
rpc RemoveSpaceUser(RemoveSpaceUserParams) returns (RemoveSpaceUserResult){
option (api.post) = '/space/user/remove';
};
// 更新用户权限
rpc UpdateSpaceUserRole(UpdateSpaceUserRoleParams) returns (UpdateSpaceUserRoleResult){
option (api.post) = '/space/user/updateRole';
};
// 加入空间
rpc JoinSpace(JoinSpaceParams) returns (JoinSpaceResult) {
option (api.post) = "/space/user/join";
@@ -48,17 +48,6 @@ message RemoveSpaceUserResult {
}
// 更新用户权限
message UpdateSpaceUserRoleParams {
int64 SpaceId = 1[(api.body) = "space_id",(api.vd)="$ != 0"];
int64 UserId = 2[(api.body) = "user_id",(api.vd)="$ != 0"];
int32 Role = 3 [(api.body) = "role", (api.vd) = "$ == 1 || $ == 2"];
}
message UpdateSpaceUserRoleResult{
}
// 获取当前用户的空间信息
message GetUserSpaceParams{