diff --git a/code/base-project/base-app/src/app/_layout.tsx b/code/base-project/base-app/src/app/_layout.tsx index 1a25f016..ad3c49ed 100644 --- a/code/base-project/base-app/src/app/_layout.tsx +++ b/code/base-project/base-app/src/app/_layout.tsx @@ -74,7 +74,7 @@ export default function RootLayout() { // 隐藏 splash SplashScreen.hideAsync() - }, [fontsLoaded, userStore, moneyCategoryStore, router]) + }, [fontsLoaded]) return ( diff --git a/code/base-project/base-app/src/app/system/share/components/SpaceInviteAndMembers.tsx b/code/base-project/base-app/src/app/system/share/components/SpaceInviteAndMembers.tsx index 466c2737..3d54ec88 100644 --- a/code/base-project/base-app/src/app/system/share/components/SpaceInviteAndMembers.tsx +++ b/code/base-project/base-app/src/app/system/share/components/SpaceInviteAndMembers.tsx @@ -69,7 +69,7 @@ export default function SpaceInviteAndMembers() { return ( <> - 我的邀请码 + 邀请码 {isExpanded ? ( diff --git a/code/base-project/base-app/src/app/system/share/index.tsx b/code/base-project/base-app/src/app/system/share/index.tsx index d9434306..491adf21 100644 --- a/code/base-project/base-app/src/app/system/share/index.tsx +++ b/code/base-project/base-app/src/app/system/share/index.tsx @@ -2,7 +2,6 @@ import { useEffect, useState } from 'react' import { View } from 'react-native' import CustomHeader from '@/components/custom/Header' -import { useSpaceStore } from '@/store/space' import JoinSpace from './components/JoinSpace' import SpaceHome from './components/SpaceHome' import SpaceInviteAndMembers from './components/SpaceInviteAndMembers' @@ -10,12 +9,11 @@ import SpaceInviteAndMembers from './components/SpaceInviteAndMembers' import StepFade from './components/StepFade' export default function PagerWithTab() { - const spaceStore = useSpaceStore() const [step, setStep] = useState<'join' | 'invite' | 'home'>('home') - useEffect(() => { - spaceStore.init() - }, []) + function createSpace() { + + } return ( diff --git a/code/base-project/base-app/src/components/custom/Header.tsx b/code/base-project/base-app/src/components/custom/Header.tsx index 20aa3e04..dc83c0e2 100644 --- a/code/base-project/base-app/src/components/custom/Header.tsx +++ b/code/base-project/base-app/src/components/custom/Header.tsx @@ -2,7 +2,7 @@ import type { ViewStyle } from 'react-native' import { Stack, useRouter } from 'expo-router' import React from 'react' import { Image, Text, TouchableOpacity, View } from 'react-native' -import { useSafeAreaInsets } from 'react-native-safe-area-context' +import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context' import { LucideIcon } from '../common/ao' export type StackScreenProps = React.ComponentProps @@ -63,41 +63,48 @@ export default function CustomHeader(props: CustomHeaderProps) { ...screenProps?.options, headerShown: true, header: () => ( - - { - left || ( - - router.back()}> - - - - ) - } - {/* 左侧 */} + + { + left || ( + + router.back()}> + + + + ) + } + {/* 左侧 */} - {/* 标题 */} - - {typeof title === 'string' - ? {title} - : title} - - - {right || ( - - + {/* 标题 */} + + {typeof title === 'string' + ? {title} + : title} - )} - + {right || ( + + + + )} + + + + ), }} /> diff --git a/code/base-project/base-app/src/request/index.ts b/code/base-project/base-app/src/request/index.ts index f2dcc79d..6c363d85 100644 --- a/code/base-project/base-app/src/request/index.ts +++ b/code/base-project/base-app/src/request/index.ts @@ -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, diff --git a/code/base-project/base-app/src/store/moneyCategory.ts b/code/base-project/base-app/src/store/moneyCategory.ts index 987c8f58..407e09df 100644 --- a/code/base-project/base-app/src/store/moneyCategory.ts +++ b/code/base-project/base-app/src/store/moneyCategory.ts @@ -35,6 +35,7 @@ export const useMoneyCategoryStore = create()( set({ categories: get().categories.filter(c => c.id !== id) }), init: async () => { + try { await queryMoneyCategoryApi().then((res) => { if (res.isSuccess) { diff --git a/code/base-project/base-app/src/types/global.d.ts b/code/base-project/base-app/src/types/global.d.ts index e47c8cb9..6b4e5962 100644 --- a/code/base-project/base-app/src/types/global.d.ts +++ b/code/base-project/base-app/src/types/global.d.ts @@ -21,8 +21,9 @@ declare global { } interface UserSpace { - id: number - name: string + space_id: number + space_name: string invite_code: string + role: number } } diff --git a/code/base-project/base-app/src/types/space/spaceUser.ts b/code/base-project/base-app/src/types/space/spaceUser.ts index 6c4df681..d0043e83 100644 --- a/code/base-project/base-app/src/types/space/spaceUser.ts +++ b/code/base-project/base-app/src/types/space/spaceUser.ts @@ -3,8 +3,9 @@ export interface GetUserSpaceParams { } export interface GetUserSpaceResult { - id: number - name: string + space_id: number + space_name: string + role: number invite_code: string } diff --git a/code/base-project/base-go-v3/biz/handler/space/space_user_service.go b/code/base-project/base-go-v3/biz/handler/space/space_user_service.go index d432a7fb..4319b725 100644 --- a/code/base-project/base-go-v3/biz/handler/space/space_user_service.go +++ b/code/base-project/base-go-v3/biz/handler/space/space_user_service.go @@ -301,7 +301,7 @@ func GetUserSpace(ctx context.Context, c *app.RequestContext) { userID := middleware.GetUserID(ctx) - spaceByUserId, err := db.Queries.GetSpaceByUserId(ctx, userID) + spaceByUserId, err := db.Queries.GetUserSpaceDetail(ctx, userID) if err != nil { if errorx.IsNotFound(err) { @@ -313,9 +313,10 @@ func GetUserSpace(ctx context.Context, c *app.RequestContext) { } } - resp.Id = spaceByUserId.ID - resp.Name = spaceByUserId.Name.String - resp.InviteCode = spaceByUserId.InviteCode + resp.SpaceId = spaceByUserId.SpaceID + resp.SpaceName = spaceByUserId.SpaceName.String + resp.InviteCode = spaceByUserId.SpaceInviteCode + resp.Role = spaceByUserId.Role response.Success(c).Data(resp).Send() } diff --git a/code/base-project/base-go-v3/biz/model/api/api.pb.go b/code/base-project/base-go-v3/biz/model/api/api.pb.go index 09470162..37434df6 100644 --- a/code/base-project/base-go-v3/biz/model/api/api.pb.go +++ b/code/base-project/base-go-v3/biz/model/api/api.pb.go @@ -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 diff --git a/code/base-project/base-go-v3/biz/model/space/space.pb.go b/code/base-project/base-go-v3/biz/model/space/space.pb.go index 7e5a9978..fd5f68c9 100644 --- a/code/base-project/base-go-v3/biz/model/space/space.pb.go +++ b/code/base-project/base-go-v3/biz/model/space/space.pb.go @@ -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 diff --git a/code/base-project/base-go-v3/biz/model/space/space_types.pb.go b/code/base-project/base-go-v3/biz/model/space/space_types.pb.go index 70ab913b..b0506d37 100644 --- a/code/base-project/base-go-v3/biz/model/space/space_types.pb.go +++ b/code/base-project/base-go-v3/biz/model/space/space_types.pb.go @@ -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 diff --git a/code/base-project/base-go-v3/biz/model/space/space_user_types.pb.go b/code/base-project/base-go-v3/biz/model/space/space_user_types.pb.go index 3af9cdbb..2c6b7f0f 100644 --- a/code/base-project/base-go-v3/biz/model/space/space_user_types.pb.go +++ b/code/base-project/base-go-v3/biz/model/space/space_user_types.pb.go @@ -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 @@ -573,9 +573,10 @@ type GetUserSpaceResult struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id int64 `protobuf:"varint,1,opt,name=Id,proto3" form:"id" json:"id"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" form:"name" json:"name"` + SpaceId int64 `protobuf:"varint,1,opt,name=SpaceId,proto3" form:"space_id" json:"space_id"` + SpaceName string `protobuf:"bytes,2,opt,name=SpaceName,proto3" form:"space_name" json:"space_name"` InviteCode string `protobuf:"bytes,3,opt,name=InviteCode,proto3" form:"invite_code" json:"invite_code"` + Role int32 `protobuf:"varint,4,opt,name=Role,proto3" form:"role" json:"role"` } func (x *GetUserSpaceResult) Reset() { @@ -610,16 +611,16 @@ func (*GetUserSpaceResult) Descriptor() ([]byte, []int) { return file_space_space_user_types_proto_rawDescGZIP(), []int{12} } -func (x *GetUserSpaceResult) GetId() int64 { +func (x *GetUserSpaceResult) GetSpaceId() int64 { if x != nil { - return x.Id + return x.SpaceId } return 0 } -func (x *GetUserSpaceResult) GetName() string { +func (x *GetUserSpaceResult) GetSpaceName() string { if x != nil { - return x.Name + return x.SpaceName } return "" } @@ -631,6 +632,13 @@ func (x *GetUserSpaceResult) GetInviteCode() string { return "" } +func (x *GetUserSpaceResult) GetRole() int32 { + if x != nil { + return x.Role + } + return 0 +} + var File_space_space_user_types_proto protoreflect.FileDescriptor var file_space_space_user_types_proto_rawDesc = []byte{ @@ -683,17 +691,21 @@ var file_space_space_user_types_proto_rawDesc = []byte{ 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, 0x7b, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, - 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x16, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x42, 0x06, 0xca, 0xbb, 0x18, 0x02, 0x69, 0x64, 0x52, 0x02, 0x49, 0x64, - 0x12, 0x1c, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, - 0xca, 0xbb, 0x18, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 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, 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, + 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 ( diff --git a/code/base-project/base-go-v3/db/queries/space_user.sql b/code/base-project/base-go-v3/db/queries/space_user.sql index cb75a0ea..c27964e5 100644 --- a/code/base-project/base-go-v3/db/queries/space_user.sql +++ b/code/base-project/base-go-v3/db/queries/space_user.sql @@ -35,3 +35,15 @@ ORDER BY su.join_time ASC; -- name: GetSpaceUserByUserId :one SELECT * FROM space_user WHERE user_id = $1; +-- name: GetUserSpaceDetail :one +SELECT + s.id AS space_id, + s.name AS space_name, + s.invite_code AS space_invite_code, + su.id AS space_user_id, + su.user_id, + su.role +FROM space_user su + JOIN space s ON su.space_id = s.id +WHERE su.user_id = $1; + diff --git a/code/base-project/base-go-v3/db/repo/space_user.sql.go b/code/base-project/base-go-v3/db/repo/space_user.sql.go index 9b68524b..f72c756c 100644 --- a/code/base-project/base-go-v3/db/repo/space_user.sql.go +++ b/code/base-project/base-go-v3/db/repo/space_user.sql.go @@ -48,6 +48,42 @@ func (q *Queries) GetSpaceUserByUserId(ctx context.Context, userID int64) (Space return i, err } +const getUserSpaceDetail = `-- name: GetUserSpaceDetail :one +SELECT + s.id AS space_id, + s.name AS space_name, + s.invite_code AS space_invite_code, + su.id AS space_user_id, + su.user_id, + su.role +FROM space_user su + JOIN space s ON su.space_id = s.id +WHERE su.user_id = $1 +` + +type GetUserSpaceDetailRow struct { + SpaceID int64 + SpaceName pgtype.Text + SpaceInviteCode string + SpaceUserID int64 + UserID int64 + Role int32 +} + +func (q *Queries) GetUserSpaceDetail(ctx context.Context, userID int64) (GetUserSpaceDetailRow, error) { + row := q.db.QueryRow(ctx, getUserSpaceDetail, userID) + var i GetUserSpaceDetailRow + err := row.Scan( + &i.SpaceID, + &i.SpaceName, + &i.SpaceInviteCode, + &i.SpaceUserID, + &i.UserID, + &i.Role, + ) + return i, err +} + const insertSpaceUser = `-- name: InsertSpaceUser :exec INSERT INTO space_user(id,space_id,user_id,role) VALUES ($1,$2,$3,$4) diff --git a/code/base-project/base-go-v3/idl/space/space_user_types.proto b/code/base-project/base-go-v3/idl/space/space_user_types.proto index b227d571..8aa247b1 100644 --- a/code/base-project/base-go-v3/idl/space/space_user_types.proto +++ b/code/base-project/base-go-v3/idl/space/space_user_types.proto @@ -63,7 +63,8 @@ message GetUserSpaceParams{ } message GetUserSpaceResult{ - int64 Id = 1[(api.body)="id"]; - string Name = 2[(api.body)="name"]; + int64 SpaceId = 1[(api.body)="space_id"]; + string SpaceName = 2[(api.body)="space_name"]; string InviteCode = 3[(api.body)="invite_code"]; + int32 Role = 4[(api.body)="role"]; }