From 5ca04f85caa124a5116860bf37b08f24bcb6149f Mon Sep 17 00:00:00 2001 From: oneao Date: Tue, 27 Jan 2026 22:47:55 +0800 Subject: [PATCH] u --- .../biz/handler/money/money_record_service.go | 159 ++-- .../biz/handler/space/space_service.go | 545 ++++++------ .../biz/handler/user/user_service.go | 35 +- code/allapp/allapp-go/biz/model/api/api.pb.go | 2 +- .../allapp-go/biz/model/space/space.pb.go | 103 ++- .../biz/model/space/space_types.pb.go | 799 ++++++++++++------ .../biz/model/space/space_user_types.pb.go | 669 --------------- .../allapp-go/biz/model/user/user.pb.go | 23 +- .../allapp-go/biz/model/user/user_types.pb.go | 132 +-- .../allapp-go/biz/router/middleware/auth.go | 17 +- .../allapp-go/biz/router/space/middleware.go | 73 +- .../allapp-go/biz/router/space/space.go | 6 +- .../allapp-go/biz/router/user/middleware.go | 5 + code/allapp/allapp-go/biz/router/user/user.go | 2 +- code/allapp/allapp-go/db/queries/space.sql | 6 +- .../allapp-go/db/queries/space_user.sql | 49 +- code/allapp/allapp-go/db/repo/space.sql.go | 25 +- .../allapp-go/db/repo/space_user.sql.go | 147 ++-- code/allapp/allapp-go/idl/space/space.proto | 39 +- .../allapp-go/idl/space/space_types.proto | 72 +- code/allapp/allapp-go/idl/user/user.proto | 4 +- .../allapp-go/idl/user/user_types.proto | 5 +- .../allapp/allapp-go/utils/pgtypex/pgtypex.go | 7 + .../allapp-go/utils/response/response.go | 18 +- .../allapp-rn/src/request/api/space/space.ts | 18 +- .../src/request/api/space/spaceUser.ts | 33 - code/allapp/allapp-rn/src/request/api/user.ts | 8 + code/allapp/allapp-rn/src/request/index.ts | 37 +- code/allapp/allapp-rn/src/types/global.d.ts | 4 +- .../allapp/allapp-rn/src/types/space/space.ts | 20 +- .../allapp-rn/src/types/space/spaceUser.ts | 40 - code/allapp/allapp-rn/src/types/user.ts | 10 + 32 files changed, 1308 insertions(+), 1804 deletions(-) delete mode 100644 code/allapp/allapp-go/biz/model/space/space_user_types.pb.go delete mode 100644 code/allapp/allapp-rn/src/request/api/space/spaceUser.ts create mode 100644 code/allapp/allapp-rn/src/request/api/user.ts delete mode 100644 code/allapp/allapp-rn/src/types/space/spaceUser.ts create mode 100644 code/allapp/allapp-rn/src/types/user.ts diff --git a/code/allapp/allapp-go/biz/handler/money/money_record_service.go b/code/allapp/allapp-go/biz/handler/money/money_record_service.go index bc49a198..e0a30ff3 100644 --- a/code/allapp/allapp-go/biz/handler/money/money_record_service.go +++ b/code/allapp/allapp-go/biz/handler/money/money_record_service.go @@ -12,9 +12,6 @@ import ( "allapp/utils/response" "context" "fmt" - "time" - - "github.com/jackc/pgx/v5/pgtype" money "allapp/biz/model/money" @@ -31,85 +28,85 @@ func QueryMoneyRecord(ctx context.Context, c *app.RequestContext) { return } - // 解析年月 - startTime, err := time.Parse("2006-01", req.RecordTime) - if err != nil { - errorx.AddError(c, fmt.Errorf("invalid record_time format: %v", err)) - return - } - endTime := startTime.AddDate(0, 1, 0).Add(-time.Nanosecond) + //// 解析年月 + //startTime, err := time.Parse("2006-01", req.RecordTime) + //if err != nil { + // errorx.AddError(c, fmt.Errorf("invalid record_time format: %v", err)) + // return + //} + //endTime := startTime.AddDate(0, 1, 0).Add(-time.Nanosecond) + // + //// 获取 userID 和 spaceID + //userID := middleware.GetUserID(ctx) + //spaceIspaceID := middleware.GetSpaceID(ctx) + // + //// 定义统一的 records 切片 + //var dbRecordsUser []repo.MoneyRecord + //var dbRecordsSpace []repo.FindMoneyRecordsBySpaceRow + //var errQuery error + // + //// 最终返回统一类型 + //var records []*money.MoneyRecord + // + //// 有空间ID,查询空间内所有用户 + //if ok { + // params := repo.FindMoneyRecordsBySpaceParams{ + // SpaceID: spaceID, + // RecordTime: pgtype.Date{Time: startTime, Valid: true}, + // RecordTime_2: pgtype.Date{Time: endTime, Valid: true}, + // } + // dbRecordsSpace, errQuery = db.Queries.FindMoneyRecordsBySpace(ctx, params) + // if errQuery != nil { + // errorx.AddError(c, errQuery) + // return + // } + // + // for _, r := range dbRecordsSpace { + // records = append(records, &money.MoneyRecord{ + // Id: r.ID, + // CategoryId: r.CategoryID, + // UserId: r.UserID, + // Username: r.Username.String, + // Amount: pgtypex.NumericToString(r.Amount), + // Remark: r.Remark.String, + // RecordTime: pgtypex.DateToString(r.RecordTime), + // CreateTime: pgtypex.TimestampToMillis(r.CreateTime), + // UpdateTime: pgtypex.TimestampToMillis(r.UpdateTime), + // }) + // } + //} else { + // // 没有空间ID,只查询单用户 + // params := repo.FindUserMoneyRecordsParams{ + // UserID: userID, + // RecordTime: pgtype.Date{Time: startTime, Valid: true}, + // RecordTime_2: pgtype.Date{Time: endTime, Valid: true}, + // } + // dbRecordsUser, errQuery = db.Queries.FindUserMoneyRecords(ctx, params) + // if errQuery != nil { + // errorx.AddError(c, errQuery) + // return + // } + // + // for _, r := range dbRecordsUser { + // records = append(records, &money.MoneyRecord{ + // Id: r.ID, + // CategoryId: r.CategoryID, + // UserId: r.UserID, + // Username: "", + // Amount: pgtypex.NumericToString(r.Amount), + // Remark: r.Remark.String, + // RecordTime: pgtypex.DateToString(r.RecordTime), + // CreateTime: pgtypex.TimestampToMillis(r.CreateTime), + // UpdateTime: pgtypex.TimestampToMillis(r.UpdateTime), + // }) + // } + //} + // + //result := &money.QueryMoneyRecordsResult{ + // Records: records, + //} - // 获取 userID 和 spaceID - userID := middleware.GetUserID(ctx) - spaceID, ok := middleware.GetSpaceID(ctx) - - // 定义统一的 records 切片 - var dbRecordsUser []repo.MoneyRecord - var dbRecordsSpace []repo.FindMoneyRecordsBySpaceRow - var errQuery error - - // 最终返回统一类型 - var records []*money.MoneyRecord - - // 有空间ID,查询空间内所有用户 - if ok { - params := repo.FindMoneyRecordsBySpaceParams{ - SpaceID: spaceID, - RecordTime: pgtype.Date{Time: startTime, Valid: true}, - RecordTime_2: pgtype.Date{Time: endTime, Valid: true}, - } - dbRecordsSpace, errQuery = db.Queries.FindMoneyRecordsBySpace(ctx, params) - if errQuery != nil { - errorx.AddError(c, errQuery) - return - } - - for _, r := range dbRecordsSpace { - records = append(records, &money.MoneyRecord{ - Id: r.ID, - CategoryId: r.CategoryID, - UserId: r.UserID, - Username: r.Username.String, - Amount: pgtypex.NumericToString(r.Amount), - Remark: r.Remark.String, - RecordTime: pgtypex.DateToString(r.RecordTime), - CreateTime: pgtypex.TimestampToMillis(r.CreateTime), - UpdateTime: pgtypex.TimestampToMillis(r.UpdateTime), - }) - } - } else { - // 没有空间ID,只查询单用户 - params := repo.FindUserMoneyRecordsParams{ - UserID: userID, - RecordTime: pgtype.Date{Time: startTime, Valid: true}, - RecordTime_2: pgtype.Date{Time: endTime, Valid: true}, - } - dbRecordsUser, errQuery = db.Queries.FindUserMoneyRecords(ctx, params) - if errQuery != nil { - errorx.AddError(c, errQuery) - return - } - - for _, r := range dbRecordsUser { - records = append(records, &money.MoneyRecord{ - Id: r.ID, - CategoryId: r.CategoryID, - UserId: r.UserID, - Username: "", - Amount: pgtypex.NumericToString(r.Amount), - Remark: r.Remark.String, - RecordTime: pgtypex.DateToString(r.RecordTime), - CreateTime: pgtypex.TimestampToMillis(r.CreateTime), - UpdateTime: pgtypex.TimestampToMillis(r.UpdateTime), - }) - } - } - - result := &money.QueryMoneyRecordsResult{ - Records: records, - } - - response.Success(c).Data(result).Send() + response.Success(c).Send() } // InsertMoneyRecord . diff --git a/code/allapp/allapp-go/biz/handler/space/space_service.go b/code/allapp/allapp-go/biz/handler/space/space_service.go index b56e2178..29870b26 100644 --- a/code/allapp/allapp-go/biz/handler/space/space_service.go +++ b/code/allapp/allapp-go/biz/handler/space/space_service.go @@ -9,7 +9,7 @@ import ( "allapp/utils" "allapp/utils/errorx" "allapp/utils/idgen" - "allapp/utils/redisx" + "allapp/utils/pgtypex" "allapp/utils/response" "context" @@ -19,70 +19,287 @@ import ( "github.com/cloudwego/hertz/pkg/protocol/consts" ) -// KickOutUser 踢出某人 -// @router /space/kick [POST] -func KickOutUser(ctx context.Context, c *app.RequestContext) { - var req space.KickOutUserParams - if err := c.BindAndValidate(&req); err != nil { +// CreateSpace . +// @router /space/create [POST] +func CreateSpace(ctx context.Context, c *app.RequestContext) { + var err error + var req space.CreateSpaceParams + err = c.BindAndValidate(&req) + if err != nil { c.String(consts.StatusBadRequest, err.Error()) return } - userID := middleware.GetUserID(ctx) - spaceID := middleware.GetSpaceID(ctx) - - hasPermission, err := CheckUserPermission(ctx, userID, spaceID) - if err != nil { - errorx.AddError(c, err) - return - } - if !hasPermission { - response.Fail(c).Message("无权限操作").Send() - return - } - - if err := LeaveSpace(ctx, req.UserId, spaceID); err != nil { - errorx.AddError(c, err) - return - } - - response.Success(c).Send() -} - -// QuitSpace . -// @router /space/quit [POST] -func QuitSpace(ctx context.Context, c *app.RequestContext) { - var req space.QuitSpaceParams - if err := c.BindAndValidate(&req); err != nil { - c.String(consts.StatusBadRequest, err.Error()) - return - } + resp := new(space.CreateSpaceResult) userID := middleware.GetUserID(ctx) - spaceID := req.SpaceId - // 检查权限 - role, exists, err := redisx.GetUserSpaceRole(ctx, userID, spaceID) + _, err = db.Queries.GetSpaceUser(ctx, userID) + + var isExist = true if err != nil { - errorx.AddError(c, err) + if errorx.IsNotFound(err) { + isExist = false + } else { + errorx.AddError(c, err) + return + } + } + + if isExist { + response.Fail(c).Message("请先退出所在空间").Send() return } - if !exists { - response.Fail(c).Message("已不在该空间内").Send() - return + // 生成邀请码 + var inviteCode string + + for { + // 生成邀请码 + code := utils.GenerateCode(6) + + // 检查数据库是否存在 + _, err = db.Queries.FindSpaceByInviteCode(ctx, code) + if err != nil { + if errorx.IsNotFound(err) { + // 不存在,唯一,直接使用 + inviteCode = code + break + } else { + // 系统错误 + errorx.AddError(c, err) + return + } + } + + // 如果存在,继续循环重新生成 } + spaceId := idgen.NextId() + + // 创建空间 err = db.WithTx(ctx, func(q *repo.Queries) error { - if role == 0 { + // 创建空间 + params := repo.InsertSpaceParams{ + ID: spaceId, + Name: pgtypex.StringToText(req.Name), + InviteCode: inviteCode, + } + err = q.InsertSpace(ctx, params) + + if err != nil { + return err + } + // 将创建用户默认添加到该空间内 + userParams := repo.InsertSpaceUserParams{ + ID: idgen.NextId(), + SpaceID: spaceId, + UserID: userID, + Role: 0, + } + err := q.InsertSpaceUser(ctx, userParams) + + if err != nil { + return err } return nil }) - response.Success(c).Send() + if err != nil { + errorx.AddError(c, err) + return + } + + resp.Id = spaceId + resp.InviteCode = inviteCode + + response.Success(c).Data(resp).Send() +} + +// DissolveSpace . +// @router /space/dissolve [POST] +func DissolveSpace(ctx context.Context, c *app.RequestContext) { + var err error + var req space.DissolveSpaceParams + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(space.DissolveSpaceResult) + + spaceID := req.GetSpaceId() + userID := middleware.GetUserID(ctx) + + // 检查权限 + hasPermission, err := hasSpacePermission(ctx, userID, spaceID) + + if err != nil { + errorx.AddError(c, err) + return + } + + if !hasPermission { + response.Fail(c).Message("无权限操作该空间").Send() + return + } + + // 解散空间 + err = db.WithTx(ctx, func(q *repo.Queries) error { + err2 := q.DeleteSpace(ctx, spaceID) + if err2 != nil { + return err2 + } + + err2 = q.DeleteSpaceUsersBySpaceID(ctx, spaceID) + if err2 != nil { + return err2 + } + + return nil + }) + + if err != nil { + errorx.AddError(c, err) + return + } + + response.Success(c).Data(resp).Send() +} + +// ExitSpace . +// @router /space/exit [POST] +func ExitSpace(ctx context.Context, c *app.RequestContext) { + var err error + var req space.ExitSpaceParams + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(space.ExitSpaceResult) + + userID := middleware.GetUserID(ctx) + + spaceUser, err := db.Queries.GetSpaceUser(ctx, userID) + + if err != nil { + if errorx.IsNotFound(err) { + response.Success(c).Data(resp).Send() + } else { + errorx.AddError(c, err) + return + } + } + + if spaceUser.Role == 0 { + response.Fail(c).Message("请选择解散空间").Send() + return + } + + err = db.WithTx(ctx, func(q *repo.Queries) error { + err2 := q.DeleteSpaceUserByUserID(ctx, userID) + if err2 != nil { + return err2 + } + return nil + }) + + if err != nil { + errorx.AddError(c, err) + return + } + + response.Success(c).Data(resp).Send() +} + +// ListSpaceUsers . +// @router /space/users [POST] +func ListSpaceUsers(ctx context.Context, c *app.RequestContext) { + var err error + var req space.ListSpaceUsersParams + if err = c.BindAndValidate(&req); err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(space.ListSpaceUsersResult) + + users, err := db.Queries.ListSpaceUsers(ctx, req.SpaceId) + if err != nil { + c.String(consts.StatusInternalServerError, err.Error()) + return + } + + resp.Users = make([]*space.SpaceUser, 0, len(users)) + + for _, u := range users { + resp.Users = append(resp.Users, &space.SpaceUser{ + Id: u.UserID, + Username: u.UserName, + Avatar: u.UserAvatar, + Role: u.Role, + LastLoginTime: pgtypex.TimestamptzToMillis(u.LastLoginTime), + }) + } + + response.Success(c).Data(resp).Send() +} + +// RemoveSpaceUser . +// @router /space/remove [POST] +func RemoveSpaceUser(ctx context.Context, c *app.RequestContext) { + var err error + var req space.RemoveSpaceUserParams + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + resp := new(space.RemoveSpaceUserResult) + + userID := middleware.GetUserID(ctx) + spaceID := req.SpaceId + + // 检查权限 + hasPermission, err := hasSpacePermission(ctx, userID, spaceID) + + if err != nil { + errorx.AddError(c, err) + return + } + + if !hasPermission { + response.Fail(c).Message("无权限操作该空间").Send() + return + } + + // 移除 + err = db.WithTx(ctx, func(q *repo.Queries) error { + err2 := q.DeleteSpaceUserBySpaceIDAndUserID(ctx, repo.DeleteSpaceUserBySpaceIDAndUserIDParams{ + SpaceID: spaceID, + UserID: req.UserId, + }) + + if err2 != nil { + return err2 + } + + return nil + }) + + if err != nil { + errorx.AddError(c, err) + return + } + + response.Success(c).Data(resp).Send() } // JoinSpace . @@ -99,243 +316,73 @@ func JoinSpace(ctx context.Context, c *app.RequestContext) { resp := new(space.JoinSpaceResult) userID := middleware.GetUserID(ctx) - oldSpaceID := middleware.GetSpaceID(ctx) - inviteCode := req.InviteCode - spaceByInviteCode, err := db.Queries.FindSpaceByInviteCode(ctx, inviteCode) + _, err = db.Queries.GetSpaceUser(ctx, userID) + if err != nil { if errorx.IsNotFound(err) { - response.Fail(c).Message("邀请码错误或已过期").Send() + } else { + errorx.AddError(c, err) return } - errorx.AddError(c, err) + } else { + response.Fail(c).Message("请先退出已加入的空间").Send() return } - joinSpaceID := spaceByInviteCode.ID + inviteCode := req.GetInviteCode() + + spaceByInviteCode, err := db.Queries.FindSpaceByInviteCode(ctx, inviteCode) - // 检查权限 - role, exists, err := redisx.GetUserSpaceRole(ctx, userID, oldSpaceID) if err != nil { - errorx.AddError(c, err) - return + if errorx.IsNotFound(err) { + response.Fail(c).Message("邀请码无效或过期").Send() + return + } else { + errorx.AddError(c, err) + return + } } err = db.WithTx(ctx, func(q *repo.Queries) error { - // 判断权限, 如果角色为 0 则解散 - if exists && role == 0 { - users, err2 := q.ListSpaceUsers(ctx, oldSpaceID) + err2 := q.InsertSpaceUser(ctx, repo.InsertSpaceUserParams{ + ID: idgen.NextId(), + UserID: userID, + SpaceID: spaceByInviteCode.ID, + Role: 1, + }) - if err2 != nil { - return err2 - } - - for _, user := range users { - if err2 := LeaveSpace(ctx, user.UserID, oldSpaceID); err2 != nil { - return err2 - } - } - } else { - // 退出就行 - if err2 := q.DeleteSpaceUser(ctx, repo.DeleteSpaceUserParams{ - SpaceID: oldSpaceID, - UserID: userID, - }); err2 != nil { - return err2 - } - - if err2 := redisx.RemoveUserSpace(ctx, userID, oldSpaceID); err2 != nil { - return err2 - } - - // 再加入 - if err2 := q.InsertSpaceUser(ctx, repo.InsertSpaceUserParams{ - ID: idgen.NextId(), - UserID: userID, - SpaceID: joinSpaceID, - Role: 0, - }); err2 != nil { - return err2 - } - - if err2 := redisx.AddOrUpdateUserSpace(ctx, userID, joinSpaceID, 0); err2 != nil { - return err2 - } + if err2 != nil { + return err2 } + return nil }) - c.JSON(consts.StatusOK, resp) -} - -// ListSpaceUsers . -// @router /space/users [POST] -func ListSpaceUsers(ctx context.Context, c *app.RequestContext) { - var err error - var req space.ListSpaceUsersParams - err = c.BindAndValidate(&req) - if err != nil { - c.String(consts.StatusBadRequest, err.Error()) - return - } - - resp := new(space.ListSpaceUsersResult) - - // 查询 - users, err := db.Queries.ListSpaceUsers(ctx, req.SpaceId) if err != nil { errorx.AddError(c, err) return } - spaceUsers := make([]*space.SpaceUser, 0, len(users)) + resp.Id = spaceByInviteCode.ID + resp.Name = spaceByInviteCode.Name.String - for _, user := range users { - spaceUsers = append(spaceUsers, &space.SpaceUser{ - UserId: user.UserID, - UserName: user.UserName, - UserAvatar: user.UserAvatar, - Role: user.Role, - }) - } - - resp.Users = spaceUsers - - response.Success(c).Data(spaceUsers).Send() + response.Success(c).Data(resp).Send() } -// CheckUserPermission 检查是否有权限 -func CheckUserPermission(ctx context.Context, userID int64, spaceID int64) (bool, error) { - inSpace, err := redisx.InSpace(ctx, userID, spaceID) +func hasSpacePermission(ctx context.Context, userID int64, spaceID int64) (bool, error) { + user, err := db.Queries.GetSpaceUser(ctx, userID) if err != nil { - return false, err - } - - if !inSpace { - return false, nil - } - - role, exists, err := redisx.GetUserSpaceRole(ctx, userID, spaceID) - - if err != nil { - return false, err - } - - if !exists { - return false, nil - } - - return role == 0, nil -} - -// LeaveSpace 处理用户离开空间逻辑(包括删除空间用户、清理 Redis、创建新空间) -func LeaveSpace(ctx context.Context, userID, spaceID int64) error { - return db.WithTx(ctx, func(q *repo.Queries) error { - // 1. 删除数据库空间用户 - if err := q.DeleteSpaceUser(ctx, repo.DeleteSpaceUserParams{ - UserID: userID, - SpaceID: spaceID, - }); err != nil { - return err - } - - // 确保该用户加入了缓存 - err := InitUserSpaces(ctx, userID) - - if err != nil { - return err - } - - // 2. 删除 Redis 缓存 - if err := redisx.RemoveUserSpace(ctx, userID, spaceID); err != nil { - return err - } - - // 3. 确保用户至少有一个空间 - if err := EnsureUserHasSpaceWithTx(ctx, q, userID); err != nil { - return err - } - - return nil - }) -} - -// InitUserSpaces 初始化用户空间信息 -func InitUserSpaces(ctx context.Context, userID int64) error { - hasSpace, err := redisx.HasUserSpaces(ctx, userID) - - if err != nil { - return err - } - - if hasSpace { - return nil - } - - spaces, err := db.Queries.ListUserSpaces(ctx, userID) - if err != nil { - return err - } - - spaceRoles := make(map[int64]int32, len(spaces)) - for _, row := range spaces { - spaceRoles[row.ID] = row.Role - } - - return redisx.SetUserSpaces(ctx, userID, spaceRoles) -} - -// EnsureUserHasSpaceWithTx 确保用户至少有一个空间,如果没有则创建新空间 -// 注意:不管理事务,需要在外层传入 q *repo.Queries -func EnsureUserHasSpaceWithTx(ctx context.Context, q *repo.Queries, userID int64) error { - // 1. 查询用户现有空间 - spaces, err := redisx.GetUserSpaces(ctx, userID) - if err != nil { - return err - } - - if len(spaces) > 0 { - // 已经有空间,无需创建 - return nil - } - - // 2. 没有空间则创建 - var inviteCode string - for { - code := utils.GenerateCode(6) - _, err := q.FindSpaceByInviteCode(ctx, code) if errorx.IsNotFound(err) { - inviteCode = code - break - } else if err != nil { - return err + return false, nil } + return false, err } - newSpaceID := idgen.NextId() - - // 插入新空间 - if err := q.InsertSpace(ctx, repo.InsertSpaceParams{ - ID: newSpaceID, - InviteCode: inviteCode, - }); err != nil { - return err + if user.SpaceID != spaceID { + return false, nil } - // 插入空间用户 - if err := q.InsertSpaceUser(ctx, repo.InsertSpaceUserParams{ - ID: idgen.NextId(), - SpaceID: newSpaceID, - UserID: userID, - }); err != nil { - return err - } - - // 同步到 Redis - if err := redisx.AddOrUpdateUserSpace(ctx, userID, newSpaceID, 0); err != nil { - return err - } - - return nil + return user.Role == 0, nil } diff --git a/code/allapp/allapp-go/biz/handler/user/user_service.go b/code/allapp/allapp-go/biz/handler/user/user_service.go index ba71f701..36f5d3a9 100644 --- a/code/allapp/allapp-go/biz/handler/user/user_service.go +++ b/code/allapp/allapp-go/biz/handler/user/user_service.go @@ -15,40 +15,37 @@ import ( "github.com/cloudwego/hertz/pkg/protocol/consts" ) -// ListUserSpaces . -// @router /user/spaces [GET] -func ListUserSpaces(ctx context.Context, c *app.RequestContext) { +// GetUserSpace . +// @router /user/space [GET] +func GetUserSpace(ctx context.Context, c *app.RequestContext) { var err error - var req user.ListUserSpacesParams + var req user.GetUserSpaceParams err = c.BindAndValidate(&req) if err != nil { c.String(consts.StatusBadRequest, err.Error()) return } - resp := new(user.ListUserSpacesResult) + resp := new(user.UserSpace) userID := middleware.GetUserID(ctx) - // 查询 - spaces, err := db.Queries.ListUserSpaces(ctx, userID) + space, err := db.Queries.GetSpaceByUserId(ctx, userID) + if err != nil { + if errorx.IsNotFound(err) { + response.Success(c).Data(resp).Send() + return + } + errorx.AddError(c, err) return } - userSpaces := make([]*user.UserSpace, 0, len(spaces)) - - for _, space := range spaces { - userSpaces = append(userSpaces, &user.UserSpace{ - Id: space.ID, - Name: space.Name.String, - InviteCode: space.InviteCode, - Role: space.Role, - }) - } - - resp.Spaces = userSpaces + resp.Id = space.ID + resp.Name = space.Name.String + resp.InviteCode = space.InviteCode + resp.Role = space.Role response.Success(c).Data(resp).Send() } diff --git a/code/allapp/allapp-go/biz/model/api/api.pb.go b/code/allapp/allapp-go/biz/model/api/api.pb.go index d82e6a07..ff03c0ce 100644 --- a/code/allapp/allapp-go/biz/model/api/api.pb.go +++ b/code/allapp/allapp-go/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/allapp/allapp-go/biz/model/space/space.pb.go b/code/allapp/allapp-go/biz/model/space/space.pb.go index 1005e6c5..b7cbacd4 100644 --- a/code/allapp/allapp-go/biz/model/space/space.pb.go +++ b/code/allapp/allapp-go/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 @@ -26,57 +26,76 @@ var file_space_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x73, 0x70, 0x61, 0x63, 0x65, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xdc, 0x02, 0x0a, 0x0c, 0x53, 0x70, 0x61, - 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x0b, 0x4b, 0x69, 0x63, - 0x6b, 0x4f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x2e, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x1a, 0x18, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x4b, 0x69, 0x63, 0x6b, 0x4f, - 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x0f, 0xd2, 0xc1, - 0x18, 0x0b, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x6b, 0x69, 0x63, 0x6b, 0x12, 0x4c, 0x0a, - 0x09, 0x51, 0x75, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x16, 0x2e, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x2e, 0x51, 0x75, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x1a, 0x16, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x51, 0x75, 0x69, 0x74, 0x53, + 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x9e, 0x04, 0x0a, 0x0c, 0x53, 0x70, 0x61, + 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x54, 0x0a, 0x0b, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x1a, 0x18, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x11, 0xd2, 0xc1, + 0x18, 0x0d, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, + 0x5c, 0x0a, 0x0d, 0x44, 0x69, 0x73, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, + 0x12, 0x1a, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x44, 0x69, 0x73, 0x73, 0x6f, 0x6c, 0x76, + 0x65, 0x53, 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, 0x12, 0x4c, 0x0a, + 0x09, 0x45, 0x78, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x12, 0x16, 0x2e, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x2e, 0x45, 0x78, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x1a, 0x16, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x45, 0x78, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x0f, 0xd2, 0xc1, 0x18, 0x0b, - 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x71, 0x75, 0x69, 0x74, 0x12, 0x4c, 0x0a, 0x09, 0x4a, + 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x65, 0x78, 0x69, 0x74, 0x12, 0x5c, 0x0a, 0x0e, 0x4c, + 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x1b, 0x2e, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1b, 0x2e, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x10, 0xd2, 0xc1, 0x18, 0x0c, 0x2f, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x60, 0x0a, 0x0f, 0x52, 0x65, 0x6d, + 0x6f, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1c, 0x2e, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 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, 0x11, 0xd2, 0xc1, 0x18, 0x0d, 0x2f, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x12, 0x4c, 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, 0x0f, 0xd2, 0xc1, 0x18, 0x0b, 0x2f, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x2f, 0x6a, 0x6f, 0x69, 0x6e, 0x12, 0x5c, 0x0a, 0x0e, 0x4c, 0x69, 0x73, - 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x1b, 0x2e, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1b, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x10, 0xd2, 0xc1, 0x18, 0x0c, 0x2f, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x42, 0x18, 0x5a, 0x16, 0x61, 0x6c, 0x6c, 0x61, 0x70, - 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x61, 0x63, 0x65, 0x2f, 0x6a, 0x6f, 0x69, 0x6e, 0x42, 0x18, 0x5a, 0x16, 0x61, 0x6c, 0x6c, + 0x61, 0x70, 0x70, 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{}{ - (*KickOutUserParams)(nil), // 0: space.KickOutUserParams - (*QuitSpaceParams)(nil), // 1: space.QuitSpaceParams - (*JoinSpaceParams)(nil), // 2: space.JoinSpaceParams - (*ListSpaceUsersParams)(nil), // 3: space.ListSpaceUsersParams - (*KickOutUserResult)(nil), // 4: space.KickOutUserResult - (*QuitSpaceResult)(nil), // 5: space.QuitSpaceResult - (*JoinSpaceResult)(nil), // 6: space.JoinSpaceResult - (*ListSpaceUsersResult)(nil), // 7: space.ListSpaceUsersResult + (*CreateSpaceParams)(nil), // 0: space.CreateSpaceParams + (*DissolveSpaceParams)(nil), // 1: space.DissolveSpaceParams + (*ExitSpaceParams)(nil), // 2: space.ExitSpaceParams + (*ListSpaceUsersParams)(nil), // 3: space.ListSpaceUsersParams + (*RemoveSpaceUserParams)(nil), // 4: space.RemoveSpaceUserParams + (*JoinSpaceParams)(nil), // 5: space.JoinSpaceParams + (*DissolveSpaceResult)(nil), // 6: space.DissolveSpaceResult + (*ExitSpaceResult)(nil), // 7: space.ExitSpaceResult + (*ListSpaceUsersResult)(nil), // 8: space.ListSpaceUsersResult + (*RemoveSpaceUserResult)(nil), // 9: space.RemoveSpaceUserResult + (*JoinSpaceResult)(nil), // 10: space.JoinSpaceResult } var file_space_proto_depIdxs = []int32{ - 0, // 0: space.SpaceService.KickOutUser:input_type -> space.KickOutUserParams - 1, // 1: space.SpaceService.QuitSpace:input_type -> space.QuitSpaceParams - 2, // 2: space.SpaceService.JoinSpace:input_type -> space.JoinSpaceParams - 3, // 3: space.SpaceService.ListSpaceUsers:input_type -> space.ListSpaceUsersParams - 4, // 4: space.SpaceService.KickOutUser:output_type -> space.KickOutUserResult - 5, // 5: space.SpaceService.QuitSpace:output_type -> space.QuitSpaceResult - 6, // 6: space.SpaceService.JoinSpace:output_type -> space.JoinSpaceResult - 7, // 7: space.SpaceService.ListSpaceUsers:output_type -> space.ListSpaceUsersResult - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] 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 + 0, // 0: space.SpaceService.CreateSpace:input_type -> space.CreateSpaceParams + 1, // 1: space.SpaceService.DissolveSpace:input_type -> space.DissolveSpaceParams + 2, // 2: space.SpaceService.ExitSpace:input_type -> space.ExitSpaceParams + 3, // 3: space.SpaceService.ListSpaceUsers:input_type -> space.ListSpaceUsersParams + 4, // 4: space.SpaceService.RemoveSpaceUser:input_type -> space.RemoveSpaceUserParams + 5, // 5: space.SpaceService.JoinSpace:input_type -> space.JoinSpaceParams + 0, // 6: space.SpaceService.CreateSpace:output_type -> space.CreateSpaceParams + 6, // 7: space.SpaceService.DissolveSpace:output_type -> space.DissolveSpaceResult + 7, // 8: space.SpaceService.ExitSpace:output_type -> space.ExitSpaceResult + 8, // 9: space.SpaceService.ListSpaceUsers:output_type -> space.ListSpaceUsersResult + 9, // 10: space.SpaceService.RemoveSpaceUser:output_type -> space.RemoveSpaceUserResult + 10, // 11: space.SpaceService.JoinSpace:output_type -> space.JoinSpaceResult + 6, // [6:12] is the sub-list for method output_type + 0, // [0:6] 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 } func init() { file_space_proto_init() } diff --git a/code/allapp/allapp-go/biz/model/space/space_types.pb.go b/code/allapp/allapp-go/biz/model/space/space_types.pb.go index 339bf673..b960772e 100644 --- a/code/allapp/allapp-go/biz/model/space/space_types.pb.go +++ b/code/allapp/allapp-go/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 @@ -21,19 +21,208 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// --- 空间用户列表 --- +// 创建空间 +type CreateSpaceParams struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=Name,proto3" form:"name" json:"name"` +} + +func (x *CreateSpaceParams) Reset() { + *x = CreateSpaceParams{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateSpaceParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateSpaceParams) ProtoMessage() {} + +func (x *CreateSpaceParams) ProtoReflect() protoreflect.Message { + mi := &file_space_space_types_proto_msgTypes[0] + 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 CreateSpaceParams.ProtoReflect.Descriptor instead. +func (*CreateSpaceParams) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateSpaceParams) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type CreateSpaceResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=Id,proto3" form:"id" json:"id"` + InviteCode string `protobuf:"bytes,2,opt,name=InviteCode,proto3" form:"invite_code" json:"invite_code"` +} + +func (x *CreateSpaceResult) Reset() { + *x = CreateSpaceResult{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateSpaceResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateSpaceResult) ProtoMessage() {} + +func (x *CreateSpaceResult) ProtoReflect() protoreflect.Message { + mi := &file_space_space_types_proto_msgTypes[1] + 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 CreateSpaceResult.ProtoReflect.Descriptor instead. +func (*CreateSpaceResult) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateSpaceResult) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *CreateSpaceResult) GetInviteCode() string { + if x != nil { + return x.InviteCode + } + return "" +} + +// 解散空间 +type DissolveSpaceParams 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"` +} + +func (x *DissolveSpaceParams) Reset() { + *x = DissolveSpaceParams{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DissolveSpaceParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DissolveSpaceParams) ProtoMessage() {} + +func (x *DissolveSpaceParams) ProtoReflect() protoreflect.Message { + mi := &file_space_space_types_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DissolveSpaceParams.ProtoReflect.Descriptor instead. +func (*DissolveSpaceParams) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{2} +} + +func (x *DissolveSpaceParams) GetSpaceId() int64 { + if x != nil { + return x.SpaceId + } + return 0 +} + +type DissolveSpaceResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DissolveSpaceResult) Reset() { + *x = DissolveSpaceResult{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DissolveSpaceResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DissolveSpaceResult) ProtoMessage() {} + +func (x *DissolveSpaceResult) ProtoReflect() protoreflect.Message { + mi := &file_space_space_types_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DissolveSpaceResult.ProtoReflect.Descriptor instead. +func (*DissolveSpaceResult) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{3} +} + +// 获取空间下的成员 type ListSpaceUsersParams struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SpaceId int64 `protobuf:"varint,1,opt,name=SpaceId,proto3" json:"SpaceId" query:"space_id"` + SpaceId int64 `protobuf:"varint,1,opt,name=SpaceId,proto3" form:"space_id" json:"space_id"` } func (x *ListSpaceUsersParams) Reset() { *x = ListSpaceUsersParams{} if protoimpl.UnsafeEnabled { - mi := &file_space_space_types_proto_msgTypes[0] + mi := &file_space_space_types_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -46,7 +235,7 @@ func (x *ListSpaceUsersParams) String() string { func (*ListSpaceUsersParams) ProtoMessage() {} func (x *ListSpaceUsersParams) ProtoReflect() protoreflect.Message { - mi := &file_space_space_types_proto_msgTypes[0] + mi := &file_space_space_types_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -59,7 +248,7 @@ func (x *ListSpaceUsersParams) ProtoReflect() protoreflect.Message { // Deprecated: Use ListSpaceUsersParams.ProtoReflect.Descriptor instead. func (*ListSpaceUsersParams) Descriptor() ([]byte, []int) { - return file_space_space_types_proto_rawDescGZIP(), []int{0} + return file_space_space_types_proto_rawDescGZIP(), []int{4} } func (x *ListSpaceUsersParams) GetSpaceId() int64 { @@ -74,16 +263,17 @@ type SpaceUser struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId int64 `protobuf:"varint,1,opt,name=UserId,proto3" json:"UserId" query:"user_id"` - UserName string `protobuf:"bytes,2,opt,name=UserName,proto3" json:"UserName" query:"user_name"` - UserAvatar string `protobuf:"bytes,3,opt,name=UserAvatar,proto3" json:"UserAvatar" query:"user_avatar"` - Role int32 `protobuf:"varint,4,opt,name=Role,proto3" json:"Role" query:"role"` + Id int64 `protobuf:"varint,1,opt,name=Id,proto3" form:"id" json:"id"` + Username string `protobuf:"bytes,2,opt,name=Username,proto3" form:"username" json:"username"` + Avatar string `protobuf:"bytes,3,opt,name=Avatar,proto3" form:"avatar" json:"avatar"` + Role int32 `protobuf:"varint,4,opt,name=Role,proto3" form:"role" json:"role"` + LastLoginTime int64 `protobuf:"varint,5,opt,name=LastLoginTime,proto3" form:"last_login_time" json:"last_login_time"` } func (x *SpaceUser) Reset() { *x = SpaceUser{} if protoimpl.UnsafeEnabled { - mi := &file_space_space_types_proto_msgTypes[1] + mi := &file_space_space_types_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -96,7 +286,7 @@ func (x *SpaceUser) String() string { func (*SpaceUser) ProtoMessage() {} func (x *SpaceUser) ProtoReflect() protoreflect.Message { - mi := &file_space_space_types_proto_msgTypes[1] + mi := &file_space_space_types_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -109,26 +299,26 @@ func (x *SpaceUser) ProtoReflect() protoreflect.Message { // Deprecated: Use SpaceUser.ProtoReflect.Descriptor instead. func (*SpaceUser) Descriptor() ([]byte, []int) { - return file_space_space_types_proto_rawDescGZIP(), []int{1} + return file_space_space_types_proto_rawDescGZIP(), []int{5} } -func (x *SpaceUser) GetUserId() int64 { +func (x *SpaceUser) GetId() int64 { if x != nil { - return x.UserId + return x.Id } return 0 } -func (x *SpaceUser) GetUserName() string { +func (x *SpaceUser) GetUsername() string { if x != nil { - return x.UserName + return x.Username } return "" } -func (x *SpaceUser) GetUserAvatar() string { +func (x *SpaceUser) GetAvatar() string { if x != nil { - return x.UserAvatar + return x.Avatar } return "" } @@ -140,6 +330,13 @@ func (x *SpaceUser) GetRole() int32 { return 0 } +func (x *SpaceUser) GetLastLoginTime() int64 { + if x != nil { + return x.LastLoginTime + } + return 0 +} + type ListSpaceUsersResult struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -151,7 +348,7 @@ type ListSpaceUsersResult struct { func (x *ListSpaceUsersResult) Reset() { *x = ListSpaceUsersResult{} if protoimpl.UnsafeEnabled { - mi := &file_space_space_types_proto_msgTypes[2] + mi := &file_space_space_types_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -164,7 +361,7 @@ func (x *ListSpaceUsersResult) String() string { func (*ListSpaceUsersResult) ProtoMessage() {} func (x *ListSpaceUsersResult) ProtoReflect() protoreflect.Message { - mi := &file_space_space_types_proto_msgTypes[2] + mi := &file_space_space_types_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -177,7 +374,7 @@ func (x *ListSpaceUsersResult) ProtoReflect() protoreflect.Message { // Deprecated: Use ListSpaceUsersResult.ProtoReflect.Descriptor instead. func (*ListSpaceUsersResult) Descriptor() ([]byte, []int) { - return file_space_space_types_proto_rawDescGZIP(), []int{2} + return file_space_space_types_proto_rawDescGZIP(), []int{6} } func (x *ListSpaceUsersResult) GetUsers() []*SpaceUser { @@ -187,193 +384,13 @@ func (x *ListSpaceUsersResult) GetUsers() []*SpaceUser { return nil } -// 踢出用户 -type KickOutUserParams 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"` - UserId int64 `protobuf:"varint,2,opt,name=UserId,proto3" form:"user_id" json:"user_id"` -} - -func (x *KickOutUserParams) Reset() { - *x = KickOutUserParams{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_types_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KickOutUserParams) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KickOutUserParams) ProtoMessage() {} - -func (x *KickOutUserParams) ProtoReflect() protoreflect.Message { - mi := &file_space_space_types_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KickOutUserParams.ProtoReflect.Descriptor instead. -func (*KickOutUserParams) Descriptor() ([]byte, []int) { - return file_space_space_types_proto_rawDescGZIP(), []int{3} -} - -func (x *KickOutUserParams) GetSpaceId() int64 { - if x != nil { - return x.SpaceId - } - return 0 -} - -func (x *KickOutUserParams) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type KickOutUserResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *KickOutUserResult) Reset() { - *x = KickOutUserResult{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_types_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KickOutUserResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KickOutUserResult) ProtoMessage() {} - -func (x *KickOutUserResult) ProtoReflect() protoreflect.Message { - mi := &file_space_space_types_proto_msgTypes[4] - 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 KickOutUserResult.ProtoReflect.Descriptor instead. -func (*KickOutUserResult) Descriptor() ([]byte, []int) { - return file_space_space_types_proto_rawDescGZIP(), []int{4} -} - -// 退出空间 -type QuitSpaceParams 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"` -} - -func (x *QuitSpaceParams) Reset() { - *x = QuitSpaceParams{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_types_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QuitSpaceParams) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QuitSpaceParams) ProtoMessage() {} - -func (x *QuitSpaceParams) ProtoReflect() protoreflect.Message { - mi := &file_space_space_types_proto_msgTypes[5] - 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 QuitSpaceParams.ProtoReflect.Descriptor instead. -func (*QuitSpaceParams) Descriptor() ([]byte, []int) { - return file_space_space_types_proto_rawDescGZIP(), []int{5} -} - -func (x *QuitSpaceParams) GetSpaceId() int64 { - if x != nil { - return x.SpaceId - } - return 0 -} - -type QuitSpaceResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *QuitSpaceResult) Reset() { - *x = QuitSpaceResult{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_types_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QuitSpaceResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QuitSpaceResult) ProtoMessage() {} - -func (x *QuitSpaceResult) ProtoReflect() protoreflect.Message { - mi := &file_space_space_types_proto_msgTypes[6] - 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 QuitSpaceResult.ProtoReflect.Descriptor instead. -func (*QuitSpaceResult) Descriptor() ([]byte, []int) { - return file_space_space_types_proto_rawDescGZIP(), []int{6} -} - // 加入空间 type JoinSpaceParams struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - InviteCode string `protobuf:"bytes,1,opt,name=InviteCode,proto3" form:"invite_code" json:"invite_code"` + InviteCode string `protobuf:"bytes,1,opt,name=InviteCode,proto3" form:"invite_code" json:"invite_code" vd:"$ != ''"` // 邀请码 } func (x *JoinSpaceParams) Reset() { @@ -419,6 +436,9 @@ type JoinSpaceResult struct { state protoimpl.MessageState 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"` } func (x *JoinSpaceResult) Reset() { @@ -453,51 +473,256 @@ func (*JoinSpaceResult) Descriptor() ([]byte, []int) { return file_space_space_types_proto_rawDescGZIP(), []int{8} } +func (x *JoinSpaceResult) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *JoinSpaceResult) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// 退出空间 +type ExitSpaceParams struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ExitSpaceParams) Reset() { + *x = ExitSpaceParams{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExitSpaceParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExitSpaceParams) ProtoMessage() {} + +func (x *ExitSpaceParams) ProtoReflect() protoreflect.Message { + mi := &file_space_space_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 ExitSpaceParams.ProtoReflect.Descriptor instead. +func (*ExitSpaceParams) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{9} +} + +type ExitSpaceResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ExitSpaceResult) Reset() { + *x = ExitSpaceResult{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExitSpaceResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExitSpaceResult) ProtoMessage() {} + +func (x *ExitSpaceResult) ProtoReflect() protoreflect.Message { + mi := &file_space_space_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 ExitSpaceResult.ProtoReflect.Descriptor instead. +func (*ExitSpaceResult) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{10} +} + +// 踢出成员 +type RemoveSpaceUserParams 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"` +} + +func (x *RemoveSpaceUserParams) Reset() { + *x = RemoveSpaceUserParams{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveSpaceUserParams) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveSpaceUserParams) ProtoMessage() {} + +func (x *RemoveSpaceUserParams) ProtoReflect() protoreflect.Message { + mi := &file_space_space_types_proto_msgTypes[11] + 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 RemoveSpaceUserParams.ProtoReflect.Descriptor instead. +func (*RemoveSpaceUserParams) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{11} +} + +func (x *RemoveSpaceUserParams) GetSpaceId() int64 { + if x != nil { + return x.SpaceId + } + return 0 +} + +func (x *RemoveSpaceUserParams) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type RemoveSpaceUserResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RemoveSpaceUserResult) Reset() { + *x = RemoveSpaceUserResult{} + if protoimpl.UnsafeEnabled { + mi := &file_space_space_types_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveSpaceUserResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveSpaceUserResult) ProtoMessage() {} + +func (x *RemoveSpaceUserResult) ProtoReflect() protoreflect.Message { + mi := &file_space_space_types_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveSpaceUserResult.ProtoReflect.Descriptor instead. +func (*RemoveSpaceUserResult) Descriptor() ([]byte, []int) { + return file_space_space_types_proto_rawDescGZIP(), []int{12} +} + var File_space_space_types_proto protoreflect.FileDescriptor var file_space_space_types_proto_rawDesc = []byte{ 0x0a, 0x17, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e, 0x0a, 0x14, 0x4c, - 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x50, 0x61, 0x72, + 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x31, 0x0a, 0x11, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, + 0x12, 0x1c, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, + 0xca, 0xbb, 0x18, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x5c, + 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 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, 0x2f, 0x0a, 0x0a, 0x49, + 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 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, 0x22, 0x3d, 0x0a, 0x13, + 0x44, 0x69, 0x73, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x26, 0x0a, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, 0xb2, 0xbb, 0x18, 0x08, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, - 0x69, 0x64, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x22, 0xaa, 0x01, 0x0a, 0x09, - 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x06, 0x55, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0b, 0xb2, 0xbb, 0x18, 0x07, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x29, - 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x0d, 0xb2, 0xbb, 0x18, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x52, - 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2f, 0x0a, 0x0a, 0x55, 0x73, 0x65, - 0x72, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0f, 0xb2, - 0xbb, 0x18, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x52, 0x0a, - 0x55, 0x73, 0x65, 0x72, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x1c, 0x0a, 0x04, 0x52, 0x6f, - 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x42, 0x08, 0xb2, 0xbb, 0x18, 0x04, 0x72, 0x6f, - 0x6c, 0x65, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x3e, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, - 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x12, 0x26, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x10, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x60, 0x0a, 0x11, 0x4b, 0x69, 0x63, 0x6b, - 0x4f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 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, 0x23, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x69, 0x64, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x13, 0x0a, 0x11, 0x4b, 0x69, - 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, - 0x39, 0x0a, 0x0f, 0x51, 0x75, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 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, 0x22, 0x11, 0x0a, 0x0f, 0x51, 0x75, - 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x42, 0x0a, - 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x12, 0x2f, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, - 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, 0x22, 0x11, 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x42, 0x18, 0x5a, 0x16, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x2f, 0x62, - 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 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, 0x22, 0x15, 0x0a, 0x13, 0x44, + 0x69, 0x73, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x22, 0x3e, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 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, 0x22, 0xca, 0x01, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, + 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, 0x28, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xca, 0xbb, 0x18, 0x08, + 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x06, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x0a, 0xca, 0xbb, 0x18, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x52, 0x06, + 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 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, 0x12, 0x39, 0x0a, 0x0d, 0x4c, 0x61, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x69, + 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x42, 0x13, 0xca, 0xbb, 0x18, + 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x52, 0x0d, 0x4c, 0x61, 0x73, 0x74, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x22, + 0x3e, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x53, + 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, + 0x4d, 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1a, 0xca, 0xbb, 0x18, 0x0b, 0x69, 0x6e, 0x76, 0x69, + 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0xda, 0xbb, 0x18, 0x07, 0x24, 0x20, 0x21, 0x3d, 0x20, + 0x27, 0x27, 0x52, 0x0a, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x47, + 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 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, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x69, 0x74, 0x53, + 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, + 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x78, 0x0a, + 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, + 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, 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, + 0x42, 0x18, 0x5a, 0x16, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 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 ( @@ -512,20 +737,24 @@ func file_space_space_types_proto_rawDescGZIP() []byte { return file_space_space_types_proto_rawDescData } -var file_space_space_types_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_space_space_types_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_space_space_types_proto_goTypes = []interface{}{ - (*ListSpaceUsersParams)(nil), // 0: space.ListSpaceUsersParams - (*SpaceUser)(nil), // 1: space.SpaceUser - (*ListSpaceUsersResult)(nil), // 2: space.ListSpaceUsersResult - (*KickOutUserParams)(nil), // 3: space.KickOutUserParams - (*KickOutUserResult)(nil), // 4: space.KickOutUserResult - (*QuitSpaceParams)(nil), // 5: space.QuitSpaceParams - (*QuitSpaceResult)(nil), // 6: space.QuitSpaceResult - (*JoinSpaceParams)(nil), // 7: space.JoinSpaceParams - (*JoinSpaceResult)(nil), // 8: space.JoinSpaceResult + (*CreateSpaceParams)(nil), // 0: space.CreateSpaceParams + (*CreateSpaceResult)(nil), // 1: space.CreateSpaceResult + (*DissolveSpaceParams)(nil), // 2: space.DissolveSpaceParams + (*DissolveSpaceResult)(nil), // 3: space.DissolveSpaceResult + (*ListSpaceUsersParams)(nil), // 4: space.ListSpaceUsersParams + (*SpaceUser)(nil), // 5: space.SpaceUser + (*ListSpaceUsersResult)(nil), // 6: space.ListSpaceUsersResult + (*JoinSpaceParams)(nil), // 7: space.JoinSpaceParams + (*JoinSpaceResult)(nil), // 8: space.JoinSpaceResult + (*ExitSpaceParams)(nil), // 9: space.ExitSpaceParams + (*ExitSpaceResult)(nil), // 10: space.ExitSpaceResult + (*RemoveSpaceUserParams)(nil), // 11: space.RemoveSpaceUserParams + (*RemoveSpaceUserResult)(nil), // 12: space.RemoveSpaceUserResult } var file_space_space_types_proto_depIdxs = []int32{ - 1, // 0: space.ListSpaceUsersResult.users:type_name -> space.SpaceUser + 5, // 0: space.ListSpaceUsersResult.users:type_name -> space.SpaceUser 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -540,7 +769,7 @@ func file_space_space_types_proto_init() { } if !protoimpl.UnsafeEnabled { file_space_space_types_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListSpaceUsersParams); i { + switch v := v.(*CreateSpaceParams); i { case 0: return &v.state case 1: @@ -552,7 +781,7 @@ func file_space_space_types_proto_init() { } } file_space_space_types_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SpaceUser); i { + switch v := v.(*CreateSpaceResult); i { case 0: return &v.state case 1: @@ -564,7 +793,7 @@ func file_space_space_types_proto_init() { } } file_space_space_types_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListSpaceUsersResult); i { + switch v := v.(*DissolveSpaceParams); i { case 0: return &v.state case 1: @@ -576,7 +805,7 @@ func file_space_space_types_proto_init() { } } file_space_space_types_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*KickOutUserParams); i { + switch v := v.(*DissolveSpaceResult); i { case 0: return &v.state case 1: @@ -588,7 +817,7 @@ func file_space_space_types_proto_init() { } } file_space_space_types_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*KickOutUserResult); i { + switch v := v.(*ListSpaceUsersParams); i { case 0: return &v.state case 1: @@ -600,7 +829,7 @@ func file_space_space_types_proto_init() { } } file_space_space_types_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QuitSpaceParams); i { + switch v := v.(*SpaceUser); i { case 0: return &v.state case 1: @@ -612,7 +841,7 @@ func file_space_space_types_proto_init() { } } file_space_space_types_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QuitSpaceResult); i { + switch v := v.(*ListSpaceUsersResult); i { case 0: return &v.state case 1: @@ -647,6 +876,54 @@ func file_space_space_types_proto_init() { return nil } } + file_space_space_types_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExitSpaceParams); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_space_space_types_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExitSpaceResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_space_space_types_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveSpaceUserParams); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_space_space_types_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveSpaceUserResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -654,7 +931,7 @@ func file_space_space_types_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_space_space_types_proto_rawDesc, NumEnums: 0, - NumMessages: 9, + NumMessages: 13, NumExtensions: 0, NumServices: 0, }, diff --git a/code/allapp/allapp-go/biz/model/space/space_user_types.pb.go b/code/allapp/allapp-go/biz/model/space/space_user_types.pb.go deleted file mode 100644 index 490b9af7..00000000 --- a/code/allapp/allapp-go/biz/model/space/space_user_types.pb.go +++ /dev/null @@ -1,669 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.0 -// protoc v4.25.3 -// source: space/space_user_types.proto - -package space - -import ( - _ "allapp/biz/model/api" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// --- 空间用户列表 --- -type ListSpaceUsersParams struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SpaceId int64 `protobuf:"varint,1,opt,name=SpaceId,proto3" json:"SpaceId" query:"space_id"` -} - -func (x *ListSpaceUsersParams) Reset() { - *x = ListSpaceUsersParams{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListSpaceUsersParams) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListSpaceUsersParams) ProtoMessage() {} - -func (x *ListSpaceUsersParams) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[0] - 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 ListSpaceUsersParams.ProtoReflect.Descriptor instead. -func (*ListSpaceUsersParams) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{0} -} - -func (x *ListSpaceUsersParams) GetSpaceId() int64 { - if x != nil { - return x.SpaceId - } - return 0 -} - -type SpaceUser struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=UserId,proto3" json:"UserId" query:"user_id"` - UserName string `protobuf:"bytes,2,opt,name=UserName,proto3" json:"UserName" query:"user_name"` - UserAvatar string `protobuf:"bytes,3,opt,name=UserAvatar,proto3" json:"UserAvatar" query:"user_avatar"` - Role int32 `protobuf:"varint,4,opt,name=Role,proto3" json:"Role" query:"role"` -} - -func (x *SpaceUser) Reset() { - *x = SpaceUser{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SpaceUser) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SpaceUser) ProtoMessage() {} - -func (x *SpaceUser) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[1] - 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 SpaceUser.ProtoReflect.Descriptor instead. -func (*SpaceUser) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{1} -} - -func (x *SpaceUser) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *SpaceUser) GetUserName() string { - if x != nil { - return x.UserName - } - return "" -} - -func (x *SpaceUser) GetUserAvatar() string { - if x != nil { - return x.UserAvatar - } - return "" -} - -func (x *SpaceUser) GetRole() int32 { - if x != nil { - return x.Role - } - return 0 -} - -type ListSpaceUsersResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Users []*SpaceUser `protobuf:"bytes,1,rep,name=users,proto3" form:"users" json:"users" query:"users"` -} - -func (x *ListSpaceUsersResult) Reset() { - *x = ListSpaceUsersResult{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListSpaceUsersResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListSpaceUsersResult) ProtoMessage() {} - -func (x *ListSpaceUsersResult) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListSpaceUsersResult.ProtoReflect.Descriptor instead. -func (*ListSpaceUsersResult) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{2} -} - -func (x *ListSpaceUsersResult) GetUsers() []*SpaceUser { - if x != nil { - return x.Users - } - return nil -} - -// 踢出用户 -type KickOutUserParams 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"` - UserId int64 `protobuf:"varint,2,opt,name=UserId,proto3" form:"user_id" json:"user_id"` -} - -func (x *KickOutUserParams) Reset() { - *x = KickOutUserParams{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KickOutUserParams) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KickOutUserParams) ProtoMessage() {} - -func (x *KickOutUserParams) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use KickOutUserParams.ProtoReflect.Descriptor instead. -func (*KickOutUserParams) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{3} -} - -func (x *KickOutUserParams) GetSpaceId() int64 { - if x != nil { - return x.SpaceId - } - return 0 -} - -func (x *KickOutUserParams) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type KickOutUserResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *KickOutUserResult) Reset() { - *x = KickOutUserResult{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *KickOutUserResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*KickOutUserResult) ProtoMessage() {} - -func (x *KickOutUserResult) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[4] - 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 KickOutUserResult.ProtoReflect.Descriptor instead. -func (*KickOutUserResult) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{4} -} - -// 退出空间 -type QuitSpaceParams 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"` -} - -func (x *QuitSpaceParams) Reset() { - *x = QuitSpaceParams{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QuitSpaceParams) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QuitSpaceParams) ProtoMessage() {} - -func (x *QuitSpaceParams) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[5] - 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 QuitSpaceParams.ProtoReflect.Descriptor instead. -func (*QuitSpaceParams) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{5} -} - -func (x *QuitSpaceParams) GetSpaceId() int64 { - if x != nil { - return x.SpaceId - } - return 0 -} - -type QuitSpaceResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *QuitSpaceResult) Reset() { - *x = QuitSpaceResult{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QuitSpaceResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QuitSpaceResult) ProtoMessage() {} - -func (x *QuitSpaceResult) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[6] - 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 QuitSpaceResult.ProtoReflect.Descriptor instead. -func (*QuitSpaceResult) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{6} -} - -// 加入空间 -type JoinSpaceParams 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"` -} - -func (x *JoinSpaceParams) Reset() { - *x = JoinSpaceParams{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *JoinSpaceParams) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*JoinSpaceParams) ProtoMessage() {} - -func (x *JoinSpaceParams) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[7] - 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 JoinSpaceParams.ProtoReflect.Descriptor instead. -func (*JoinSpaceParams) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{7} -} - -func (x *JoinSpaceParams) GetSpaceId() int64 { - if x != nil { - return x.SpaceId - } - return 0 -} - -type JoinSpaceResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *JoinSpaceResult) Reset() { - *x = JoinSpaceResult{} - if protoimpl.UnsafeEnabled { - mi := &file_space_space_user_types_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *JoinSpaceResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*JoinSpaceResult) ProtoMessage() {} - -func (x *JoinSpaceResult) ProtoReflect() protoreflect.Message { - mi := &file_space_space_user_types_proto_msgTypes[8] - 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 JoinSpaceResult.ProtoReflect.Descriptor instead. -func (*JoinSpaceResult) Descriptor() ([]byte, []int) { - return file_space_space_user_types_proto_rawDescGZIP(), []int{8} -} - -var File_space_space_user_types_proto protoreflect.FileDescriptor - -var file_space_space_user_types_proto_rawDesc = []byte{ - 0x0a, 0x1c, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x3e, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x26, 0x0a, 0x07, 0x53, 0x70, 0x61, 0x63, - 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0c, 0xb2, 0xbb, 0x18, 0x08, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x52, 0x07, 0x53, 0x70, 0x61, 0x63, 0x65, 0x49, 0x64, - 0x22, 0xaa, 0x01, 0x0a, 0x09, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, - 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0b, - 0xb2, 0xbb, 0x18, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x52, 0x06, 0x55, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x29, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0d, 0xb2, 0xbb, 0x18, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2f, - 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x0f, 0xb2, 0xbb, 0x18, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x61, 0x76, 0x61, - 0x74, 0x61, 0x72, 0x52, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, - 0x1c, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x42, 0x08, 0xb2, - 0xbb, 0x18, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x22, 0x3e, 0x0a, - 0x14, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x26, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x53, 0x70, 0x61, - 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x60, 0x0a, - 0x11, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 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, 0x23, 0x0a, 0x06, 0x55, 0x73, - 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0b, 0xca, 0xbb, 0x18, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, - 0x13, 0x0a, 0x11, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x22, 0x39, 0x0a, 0x0f, 0x51, 0x75, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, - 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 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, 0x22, - 0x11, 0x0a, 0x0f, 0x51, 0x75, 0x69, 0x74, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x22, 0x39, 0x0a, 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, - 0x61, 0x72, 0x61, 0x6d, 0x73, 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, 0x22, 0x11, 0x0a, - 0x0f, 0x4a, 0x6f, 0x69, 0x6e, 0x53, 0x70, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x42, 0x18, 0x5a, 0x16, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 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_space_user_types_proto_rawDescOnce sync.Once - file_space_space_user_types_proto_rawDescData = file_space_space_user_types_proto_rawDesc -) - -func file_space_space_user_types_proto_rawDescGZIP() []byte { - file_space_space_user_types_proto_rawDescOnce.Do(func() { - file_space_space_user_types_proto_rawDescData = protoimpl.X.CompressGZIP(file_space_space_user_types_proto_rawDescData) - }) - return file_space_space_user_types_proto_rawDescData -} - -var file_space_space_user_types_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_space_space_user_types_proto_goTypes = []interface{}{ - (*ListSpaceUsersParams)(nil), // 0: space.ListSpaceUsersParams - (*SpaceUser)(nil), // 1: space.SpaceUser - (*ListSpaceUsersResult)(nil), // 2: space.ListSpaceUsersResult - (*KickOutUserParams)(nil), // 3: space.KickOutUserParams - (*KickOutUserResult)(nil), // 4: space.KickOutUserResult - (*QuitSpaceParams)(nil), // 5: space.QuitSpaceParams - (*QuitSpaceResult)(nil), // 6: space.QuitSpaceResult - (*JoinSpaceParams)(nil), // 7: space.JoinSpaceParams - (*JoinSpaceResult)(nil), // 8: space.JoinSpaceResult -} -var file_space_space_user_types_proto_depIdxs = []int32{ - 1, // 0: space.ListSpaceUsersResult.users:type_name -> space.SpaceUser - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_space_space_user_types_proto_init() } -func file_space_space_user_types_proto_init() { - if File_space_space_user_types_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_space_space_user_types_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListSpaceUsersParams); 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[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SpaceUser); 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[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListSpaceUsersResult); 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[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*KickOutUserParams); 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[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*KickOutUserResult); 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[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QuitSpaceParams); 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[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QuitSpaceResult); 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[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JoinSpaceParams); 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[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*JoinSpaceResult); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_space_space_user_types_proto_rawDesc, - NumEnums: 0, - NumMessages: 9, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_space_space_user_types_proto_goTypes, - DependencyIndexes: file_space_space_user_types_proto_depIdxs, - MessageInfos: file_space_space_user_types_proto_msgTypes, - }.Build() - File_space_space_user_types_proto = out.File - file_space_space_user_types_proto_rawDesc = nil - file_space_space_user_types_proto_goTypes = nil - file_space_space_user_types_proto_depIdxs = nil -} diff --git a/code/allapp/allapp-go/biz/model/user/user.pb.go b/code/allapp/allapp-go/biz/model/user/user.pb.go index ed4ec004..a0c8ae4a 100644 --- a/code/allapp/allapp-go/biz/model/user/user.pb.go +++ b/code/allapp/allapp-go/biz/model/user/user.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: user.proto package user @@ -26,24 +26,23 @@ var file_user_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x69, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x5a, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, - 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x1a, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x10, 0xca, - 0xc1, 0x18, 0x0c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x42, + 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x59, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, + 0x61, 0x63, 0x65, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x0f, 0x2e, + 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x22, 0x0f, + 0xca, 0xc1, 0x18, 0x0b, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x42, 0x17, 0x5a, 0x15, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_user_proto_goTypes = []interface{}{ - (*ListUserSpacesParams)(nil), // 0: user.ListUserSpacesParams - (*ListUserSpacesResult)(nil), // 1: user.ListUserSpacesResult + (*GetUserSpaceParams)(nil), // 0: user.GetUserSpaceParams + (*UserSpace)(nil), // 1: user.UserSpace } var file_user_proto_depIdxs = []int32{ - 0, // 0: user.UserService.ListUserSpaces:input_type -> user.ListUserSpacesParams - 1, // 1: user.UserService.ListUserSpaces:output_type -> user.ListUserSpacesResult + 0, // 0: user.UserService.GetUserSpace:input_type -> user.GetUserSpaceParams + 1, // 1: user.UserService.GetUserSpace:output_type -> user.UserSpace 1, // [1:2] is the sub-list for method output_type 0, // [0:1] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/code/allapp/allapp-go/biz/model/user/user_types.pb.go b/code/allapp/allapp-go/biz/model/user/user_types.pb.go index 45d42cba..959f6c2b 100644 --- a/code/allapp/allapp-go/biz/model/user/user_types.pb.go +++ b/code/allapp/allapp-go/biz/model/user/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: user/user_types.proto package user @@ -22,14 +22,14 @@ const ( ) // --- 用户下的空间列表 --- -type ListUserSpacesParams struct { +type GetUserSpaceParams struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *ListUserSpacesParams) Reset() { - *x = ListUserSpacesParams{} +func (x *GetUserSpaceParams) Reset() { + *x = GetUserSpaceParams{} if protoimpl.UnsafeEnabled { mi := &file_user_user_types_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -37,13 +37,13 @@ func (x *ListUserSpacesParams) Reset() { } } -func (x *ListUserSpacesParams) String() string { +func (x *GetUserSpaceParams) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListUserSpacesParams) ProtoMessage() {} +func (*GetUserSpaceParams) ProtoMessage() {} -func (x *ListUserSpacesParams) ProtoReflect() protoreflect.Message { +func (x *GetUserSpaceParams) ProtoReflect() protoreflect.Message { mi := &file_user_user_types_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -55,8 +55,8 @@ func (x *ListUserSpacesParams) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListUserSpacesParams.ProtoReflect.Descriptor instead. -func (*ListUserSpacesParams) Descriptor() ([]byte, []int) { +// Deprecated: Use GetUserSpaceParams.ProtoReflect.Descriptor instead. +func (*GetUserSpaceParams) Descriptor() ([]byte, []int) { return file_user_user_types_proto_rawDescGZIP(), []int{0} } @@ -131,77 +131,25 @@ func (x *UserSpace) GetRole() int32 { return 0 } -type ListUserSpacesResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Spaces []*UserSpace `protobuf:"bytes,1,rep,name=Spaces,proto3" form:"spaces" json:"spaces"` -} - -func (x *ListUserSpacesResult) Reset() { - *x = ListUserSpacesResult{} - if protoimpl.UnsafeEnabled { - mi := &file_user_user_types_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListUserSpacesResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUserSpacesResult) ProtoMessage() {} - -func (x *ListUserSpacesResult) ProtoReflect() protoreflect.Message { - mi := &file_user_user_types_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListUserSpacesResult.ProtoReflect.Descriptor instead. -func (*ListUserSpacesResult) Descriptor() ([]byte, []int) { - return file_user_user_types_proto_rawDescGZIP(), []int{2} -} - -func (x *ListUserSpacesResult) GetSpaces() []*UserSpace { - if x != nil { - return x.Spaces - } - return nil -} - var File_user_user_types_proto protoreflect.FileDescriptor var file_user_user_types_proto_rawDesc = []byte{ 0x0a, 0x15, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x1a, 0x09, 0x61, - 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x16, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, - 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x22, 0x90, 0x01, 0x0a, 0x09, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 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, 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, 0x22, 0x4b, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x53, - 0x70, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x33, 0x0a, 0x06, 0x53, - 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x75, 0x73, - 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x42, 0x0a, 0xca, 0xbb, - 0x18, 0x06, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x52, 0x06, 0x53, 0x70, 0x61, 0x63, 0x65, 0x73, - 0x42, 0x17, 0x5a, 0x15, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, - 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x55, + 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x90, + 0x01, 0x0a, 0x09, 0x55, 0x73, 0x65, 0x72, 0x53, 0x70, 0x61, 0x63, 0x65, 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, 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, 0x17, 0x5a, 0x15, 0x61, 0x6c, 0x6c, 0x61, 0x70, 0x70, 0x2f, 0x62, 0x69, 0x7a, 0x2f, + 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -216,19 +164,17 @@ func file_user_user_types_proto_rawDescGZIP() []byte { return file_user_user_types_proto_rawDescData } -var file_user_user_types_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_user_user_types_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_user_user_types_proto_goTypes = []interface{}{ - (*ListUserSpacesParams)(nil), // 0: user.ListUserSpacesParams - (*UserSpace)(nil), // 1: user.UserSpace - (*ListUserSpacesResult)(nil), // 2: user.ListUserSpacesResult + (*GetUserSpaceParams)(nil), // 0: user.GetUserSpaceParams + (*UserSpace)(nil), // 1: user.UserSpace } var file_user_user_types_proto_depIdxs = []int32{ - 1, // 0: user.ListUserSpacesResult.Spaces:type_name -> user.UserSpace - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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 } func init() { file_user_user_types_proto_init() } @@ -238,7 +184,7 @@ func file_user_user_types_proto_init() { } if !protoimpl.UnsafeEnabled { file_user_user_types_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListUserSpacesParams); i { + switch v := v.(*GetUserSpaceParams); i { case 0: return &v.state case 1: @@ -261,18 +207,6 @@ func file_user_user_types_proto_init() { return nil } } - file_user_user_types_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListUserSpacesResult); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -280,7 +214,7 @@ func file_user_user_types_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_user_user_types_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/code/allapp/allapp-go/biz/router/middleware/auth.go b/code/allapp/allapp-go/biz/router/middleware/auth.go index b65f5e1a..10ae5244 100644 --- a/code/allapp/allapp-go/biz/router/middleware/auth.go +++ b/code/allapp/allapp-go/biz/router/middleware/auth.go @@ -39,16 +39,11 @@ func Auth() app.HandlerFunc { } // 校验 token - token := strings.TrimSpace(string(c.GetHeader("token"))) - if token == "" { - response.Fail(c).Code(response.HttpCode.Unauthorized).Send() - c.Abort() - return - } + token := strings.TrimSpace(string(c.GetHeader("Token"))) verifyToken, flag := jwtx.VerifyToken(token) if !flag { - response.Fail(c).Code(response.HttpCode.RefreshToken).Send() + response.Fail(c).Code(response.HttpCode.Unauthorized).Send() c.Abort() return } @@ -56,18 +51,18 @@ func Auth() app.HandlerFunc { userID := verifyToken.UserID // 获取 header 中的 spaceid - spaceIDStr := strings.TrimSpace(string(c.GetHeader("spaceid"))) + spaceIDStr := strings.TrimSpace(string(c.GetHeader("X-Space-Id"))) spaceID, err := strconv.ParseInt(spaceIDStr, 10, 64) if err != nil || spaceID == 0 { - response.Fail(c).Message("缺少有效 spaceid").Send() + response.Fail(c).Code(response.HttpCode.ErrSpaceRequired).Message("请先选择空间").Send() c.Abort() return } // 判断用户是否在该空间 - inSpace, err := redisx.HasUserSpace(ctx, userID, spaceID) + inSpace, err := redisx.InSpace(ctx, userID, spaceID) if err != nil || !inSpace { - response.Fail(c).Message("无权限访问该空间").Send() + response.Fail(c).Code(response.HttpCode.ErrSpaceRequired).Message("无权限访问该空间").Send() c.Abort() return } diff --git a/code/allapp/allapp-go/biz/router/space/middleware.go b/code/allapp/allapp-go/biz/router/space/middleware.go index 948d7afc..37c7c3b3 100644 --- a/code/allapp/allapp-go/biz/router/space/middleware.go +++ b/code/allapp/allapp-go/biz/router/space/middleware.go @@ -16,51 +16,6 @@ func _spaceMw() []app.HandlerFunc { return nil } -func _insertspaceMw() []app.HandlerFunc { - // your code... - return nil -} - -func _deletespaceMw() []app.HandlerFunc { - // your code... - return nil -} - -func _space_userMw() []app.HandlerFunc { - // your code... - return nil -} - -func _exitspaceMw() []app.HandlerFunc { - // your code... - return nil -} - -func _queryspaceusersMw() []app.HandlerFunc { - // your code... - return nil -} - -func _listspaceusersMw() []app.HandlerFunc { - // your code... - return nil -} - -func _removespaceuserMw() []app.HandlerFunc { - // your code... - return nil -} - -func _updatespaceuserroleMw() []app.HandlerFunc { - // your code... - return nil -} - -func _joinspaceMw() []app.HandlerFunc { - // your code... - return nil -} - func _createspaceMw() []app.HandlerFunc { // your code... return nil @@ -71,42 +26,22 @@ func _dissolvespaceMw() []app.HandlerFunc { return nil } -func _userMw() []app.HandlerFunc { +func _exitspaceMw() []app.HandlerFunc { // your code... return nil } -func _getuserspaceMw() []app.HandlerFunc { +func _joinspaceMw() []app.HandlerFunc { // your code... return nil } -func _enterspaceMw() []app.HandlerFunc { +func _removespaceuserMw() []app.HandlerFunc { // your code... return nil } -func _user0Mw() []app.HandlerFunc { - // your code... - return nil -} - -func _listuserspacesMw() []app.HandlerFunc { - // your code... - return nil -} - -func __7bspaceid_7dMw() []app.HandlerFunc { - // your code... - return nil -} - -func _kickoutuserMw() []app.HandlerFunc { - // your code... - return nil -} - -func _quitspaceMw() []app.HandlerFunc { +func _listspaceusersMw() []app.HandlerFunc { // your code... return nil } diff --git a/code/allapp/allapp-go/biz/router/space/space.go b/code/allapp/allapp-go/biz/router/space/space.go index e757c735..ca600f66 100644 --- a/code/allapp/allapp-go/biz/router/space/space.go +++ b/code/allapp/allapp-go/biz/router/space/space.go @@ -19,9 +19,11 @@ func Register(r *server.Hertz) { root := r.Group("/", rootMw()...) { _space := root.Group("/space", _spaceMw()...) + _space.POST("/create", append(_createspaceMw(), space.CreateSpace)...) + _space.POST("/dissolve", append(_dissolvespaceMw(), space.DissolveSpace)...) + _space.POST("/exit", append(_exitspaceMw(), space.ExitSpace)...) _space.POST("/join", append(_joinspaceMw(), space.JoinSpace)...) - _space.POST("/kick", append(_kickoutuserMw(), space.KickOutUser)...) - _space.POST("/quit", append(_quitspaceMw(), space.QuitSpace)...) + _space.POST("/remove", append(_removespaceuserMw(), space.RemoveSpaceUser)...) _space.POST("/users", append(_listspaceusersMw(), space.ListSpaceUsers)...) } } diff --git a/code/allapp/allapp-go/biz/router/user/middleware.go b/code/allapp/allapp-go/biz/router/user/middleware.go index 90fee803..f6342218 100644 --- a/code/allapp/allapp-go/biz/router/user/middleware.go +++ b/code/allapp/allapp-go/biz/router/user/middleware.go @@ -20,3 +20,8 @@ func _listuserspacesMw() []app.HandlerFunc { // your code... return nil } + +func _getuserspaceMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/code/allapp/allapp-go/biz/router/user/user.go b/code/allapp/allapp-go/biz/router/user/user.go index 242b7578..b5bc8695 100644 --- a/code/allapp/allapp-go/biz/router/user/user.go +++ b/code/allapp/allapp-go/biz/router/user/user.go @@ -19,6 +19,6 @@ func Register(r *server.Hertz) { root := r.Group("/", rootMw()...) { _user := root.Group("/user", _userMw()...) - _user.GET("/spaces", append(_listuserspacesMw(), user.ListUserSpaces)...) + _user.GET("/space", append(_getuserspaceMw(), user.GetUserSpace)...) } } diff --git a/code/allapp/allapp-go/db/queries/space.sql b/code/allapp/allapp-go/db/queries/space.sql index 4ee14f7b..fe1541b9 100644 --- a/code/allapp/allapp-go/db/queries/space.sql +++ b/code/allapp/allapp-go/db/queries/space.sql @@ -1,8 +1,8 @@ -- 新增分享空间 -- name: InsertSpace :exec INSERT INTO space ( - id,invite_code,create_time,update_time -) VALUES ($1,$2,NOW(),NOW()); + id,name,invite_code,create_time,update_time +) VALUES ($1,$2,$3,NOW(),NOW()); -- 删除分享空间 -- name: DeleteSpace :exec @@ -14,7 +14,7 @@ SELECT * FROM space WHERE id = $1; -- 查询用户所在的空间信息 -- name: GetSpaceByUserId :one -SELECT s.* +SELECT s.*, m.role FROM space s JOIN space_user m ON s.id = m.space_id diff --git a/code/allapp/allapp-go/db/queries/space_user.sql b/code/allapp/allapp-go/db/queries/space_user.sql index 4e3c9957..3be74c1f 100644 --- a/code/allapp/allapp-go/db/queries/space_user.sql +++ b/code/allapp/allapp-go/db/queries/space_user.sql @@ -1,51 +1,44 @@ --- name: ListUserSpaces :many -SELECT s.id, s.name, s.invite_code, su.role -FROM space s - JOIN space_user su ON s.id = su.space_id -WHERE su.user_id = $1; +-- 插入空间用户 +-- name: InsertSpaceUser :exec +INSERT INTO space_user(id,space_id,user_id,role,join_time) +VALUES ($1,$2,$3,$4,NOW()); -- name: ListSpaceUsers :many SELECT u.id AS user_id, u.username AS user_name, u.avatar AS user_avatar, + u.last_login_time AS last_login_time, su.role FROM space_user su INNER JOIN "user" u ON su.user_id = u.id WHERE su.space_id = $1 ORDER BY su.role DESC, u.username ASC; --- name: HasUserInSpace :one -SELECT EXISTS ( - SELECT 1 - FROM space_user - WHERE user_id = $1 AND space_id = $2 -); - -- 获取空间用户 -- name: GetSpaceUser :one SELECT * FROM space_user -WHERE user_id = $1 AND space_id = $2; +WHERE user_id = $1; --- 插入空间用户 --- name: InsertSpaceUser :exec -INSERT INTO space_user(id,space_id,user_id,role,join_time) -VALUES ($1,$2,$3,$4,NOW()); - --- 修改空间用户 --- name: DeleteSpaceUser :exec +-- 删除某个用户在所有空间的关系 +-- name: DeleteSpaceUserByUserID :exec DELETE FROM space_user -WHERE user_id = $1 AND space_id = $2; +WHERE user_id = $1; + +-- 删除某个用户在指定空间中的关系 +-- name: DeleteSpaceUserBySpaceIDAndUserID :exec +DELETE FROM space_user +WHERE space_id = $1 + AND user_id = $2; + +-- 删除某个空间下的所有用户 +-- name: DeleteSpaceUsersBySpaceID :exec +DELETE FROM space_user +WHERE space_id = $1; -- 修改角色 -- name: UpdateSpaceUserRole :exec UPDATE space_user SET role = $1 -WHERE user_id = $2 AND space_id = $3; - --- 获取空间下的人数 --- name: CountUsersInSpace :one -SELECT COUNT(id) -FROM space_user -WHERE space_id = $1; +WHERE user_id = $2; \ No newline at end of file diff --git a/code/allapp/allapp-go/db/repo/space.sql.go b/code/allapp/allapp-go/db/repo/space.sql.go index cb622e54..1b3d1b30 100644 --- a/code/allapp/allapp-go/db/repo/space.sql.go +++ b/code/allapp/allapp-go/db/repo/space.sql.go @@ -7,6 +7,8 @@ package repo import ( "context" + + "github.com/jackc/pgx/v5/pgtype" ) const deleteSpace = `-- name: DeleteSpace :exec @@ -56,40 +58,51 @@ func (q *Queries) GetSpaceById(ctx context.Context, id int64) (Space, error) { } const getSpaceByUserId = `-- name: GetSpaceByUserId :one -SELECT s.id, s.name, s.invite_code, s.create_time, s.update_time +SELECT s.id, s.name, s.invite_code, s.create_time, s.update_time, m.role FROM space s JOIN space_user m ON s.id = m.space_id WHERE m.user_id = $1 ` +type GetSpaceByUserIdRow struct { + ID int64 + Name pgtype.Text + InviteCode string + CreateTime pgtype.Timestamp + UpdateTime pgtype.Timestamp + Role int32 +} + // 查询用户所在的空间信息 -func (q *Queries) GetSpaceByUserId(ctx context.Context, userID int64) (Space, error) { +func (q *Queries) GetSpaceByUserId(ctx context.Context, userID int64) (GetSpaceByUserIdRow, error) { row := q.db.QueryRow(ctx, getSpaceByUserId, userID) - var i Space + var i GetSpaceByUserIdRow err := row.Scan( &i.ID, &i.Name, &i.InviteCode, &i.CreateTime, &i.UpdateTime, + &i.Role, ) return i, err } const insertSpace = `-- name: InsertSpace :exec INSERT INTO space ( - id,invite_code,create_time,update_time -) VALUES ($1,$2,NOW(),NOW()) + id,name,invite_code,create_time,update_time +) VALUES ($1,$2,$3,NOW(),NOW()) ` type InsertSpaceParams struct { ID int64 + Name pgtype.Text InviteCode string } // 新增分享空间 func (q *Queries) InsertSpace(ctx context.Context, arg InsertSpaceParams) error { - _, err := q.db.Exec(ctx, insertSpace, arg.ID, arg.InviteCode) + _, err := q.db.Exec(ctx, insertSpace, arg.ID, arg.Name, arg.InviteCode) return err } diff --git a/code/allapp/allapp-go/db/repo/space_user.sql.go b/code/allapp/allapp-go/db/repo/space_user.sql.go index 2588c62d..c6486c28 100644 --- a/code/allapp/allapp-go/db/repo/space_user.sql.go +++ b/code/allapp/allapp-go/db/repo/space_user.sql.go @@ -11,50 +11,54 @@ import ( "github.com/jackc/pgx/v5/pgtype" ) -const countUsersInSpace = `-- name: CountUsersInSpace :one -SELECT COUNT(id) -FROM space_user +const deleteSpaceUserBySpaceIDAndUserID = `-- name: DeleteSpaceUserBySpaceIDAndUserID :exec +DELETE FROM space_user +WHERE space_id = $1 + AND user_id = $2 +` + +type DeleteSpaceUserBySpaceIDAndUserIDParams struct { + SpaceID int64 + UserID int64 +} + +// 删除某个用户在指定空间中的关系 +func (q *Queries) DeleteSpaceUserBySpaceIDAndUserID(ctx context.Context, arg DeleteSpaceUserBySpaceIDAndUserIDParams) error { + _, err := q.db.Exec(ctx, deleteSpaceUserBySpaceIDAndUserID, arg.SpaceID, arg.UserID) + return err +} + +const deleteSpaceUserByUserID = `-- name: DeleteSpaceUserByUserID :exec +DELETE FROM space_user +WHERE user_id = $1 +` + +// 删除某个用户在所有空间的关系 +func (q *Queries) DeleteSpaceUserByUserID(ctx context.Context, userID int64) error { + _, err := q.db.Exec(ctx, deleteSpaceUserByUserID, userID) + return err +} + +const deleteSpaceUsersBySpaceID = `-- name: DeleteSpaceUsersBySpaceID :exec +DELETE FROM space_user WHERE space_id = $1 ` -// 获取空间下的人数 -func (q *Queries) CountUsersInSpace(ctx context.Context, spaceID int64) (int64, error) { - row := q.db.QueryRow(ctx, countUsersInSpace, spaceID) - var count int64 - err := row.Scan(&count) - return count, err -} - -const deleteSpaceUser = `-- name: DeleteSpaceUser :exec -DELETE FROM space_user -WHERE user_id = $1 AND space_id = $2 -` - -type DeleteSpaceUserParams struct { - UserID int64 - SpaceID int64 -} - -// 修改空间用户 -func (q *Queries) DeleteSpaceUser(ctx context.Context, arg DeleteSpaceUserParams) error { - _, err := q.db.Exec(ctx, deleteSpaceUser, arg.UserID, arg.SpaceID) +// 删除某个空间下的所有用户 +func (q *Queries) DeleteSpaceUsersBySpaceID(ctx context.Context, spaceID int64) error { + _, err := q.db.Exec(ctx, deleteSpaceUsersBySpaceID, spaceID) return err } const getSpaceUser = `-- name: GetSpaceUser :one SELECT id, space_id, user_id, role, join_time FROM space_user -WHERE user_id = $1 AND space_id = $2 +WHERE user_id = $1 ` -type GetSpaceUserParams struct { - UserID int64 - SpaceID int64 -} - // 获取空间用户 -func (q *Queries) GetSpaceUser(ctx context.Context, arg GetSpaceUserParams) (SpaceUser, error) { - row := q.db.QueryRow(ctx, getSpaceUser, arg.UserID, arg.SpaceID) +func (q *Queries) GetSpaceUser(ctx context.Context, userID int64) (SpaceUser, error) { + row := q.db.QueryRow(ctx, getSpaceUser, userID) var i SpaceUser err := row.Scan( &i.ID, @@ -66,26 +70,6 @@ func (q *Queries) GetSpaceUser(ctx context.Context, arg GetSpaceUserParams) (Spa return i, err } -const hasUserInSpace = `-- name: HasUserInSpace :one -SELECT EXISTS ( - SELECT 1 - FROM space_user - WHERE user_id = $1 AND space_id = $2 -) -` - -type HasUserInSpaceParams struct { - UserID int64 - SpaceID int64 -} - -func (q *Queries) HasUserInSpace(ctx context.Context, arg HasUserInSpaceParams) (bool, error) { - row := q.db.QueryRow(ctx, hasUserInSpace, arg.UserID, arg.SpaceID) - var exists bool - err := row.Scan(&exists) - return exists, err -} - const insertSpaceUser = `-- name: InsertSpaceUser :exec INSERT INTO space_user(id,space_id,user_id,role,join_time) VALUES ($1,$2,$3,$4,NOW()) @@ -114,6 +98,7 @@ SELECT u.id AS user_id, u.username AS user_name, u.avatar AS user_avatar, + u.last_login_time AS last_login_time, su.role FROM space_user su INNER JOIN "user" u ON su.user_id = u.id @@ -122,10 +107,11 @@ ORDER BY su.role DESC, u.username ASC ` type ListSpaceUsersRow struct { - UserID int64 - UserName string - UserAvatar string - Role int32 + UserID int64 + UserName string + UserAvatar string + LastLoginTime pgtype.Timestamptz + Role int32 } func (q *Queries) ListSpaceUsers(ctx context.Context, spaceID int64) ([]ListSpaceUsersRow, error) { @@ -141,45 +127,7 @@ func (q *Queries) ListSpaceUsers(ctx context.Context, spaceID int64) ([]ListSpac &i.UserID, &i.UserName, &i.UserAvatar, - &i.Role, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} - -const listUserSpaces = `-- name: ListUserSpaces :many -SELECT s.id, s.name, s.invite_code, su.role -FROM space s - JOIN space_user su ON s.id = su.space_id -WHERE su.user_id = $1 -` - -type ListUserSpacesRow struct { - ID int64 - Name pgtype.Text - InviteCode string - Role int32 -} - -func (q *Queries) ListUserSpaces(ctx context.Context, userID int64) ([]ListUserSpacesRow, error) { - rows, err := q.db.Query(ctx, listUserSpaces, userID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []ListUserSpacesRow - for rows.Next() { - var i ListUserSpacesRow - if err := rows.Scan( - &i.ID, - &i.Name, - &i.InviteCode, + &i.LastLoginTime, &i.Role, ); err != nil { return nil, err @@ -195,17 +143,16 @@ func (q *Queries) ListUserSpaces(ctx context.Context, userID int64) ([]ListUserS const updateSpaceUserRole = `-- name: UpdateSpaceUserRole :exec UPDATE space_user SET role = $1 -WHERE user_id = $2 AND space_id = $3 +WHERE user_id = $2 ` type UpdateSpaceUserRoleParams struct { - Role int32 - UserID int64 - SpaceID int64 + Role int32 + UserID int64 } // 修改角色 func (q *Queries) UpdateSpaceUserRole(ctx context.Context, arg UpdateSpaceUserRoleParams) error { - _, err := q.db.Exec(ctx, updateSpaceUserRole, arg.Role, arg.UserID, arg.SpaceID) + _, err := q.db.Exec(ctx, updateSpaceUserRole, arg.Role, arg.UserID) return err } diff --git a/code/allapp/allapp-go/idl/space/space.proto b/code/allapp/allapp-go/idl/space/space.proto index bbc265cb..9bbca582 100644 --- a/code/allapp/allapp-go/idl/space/space.proto +++ b/code/allapp/allapp-go/idl/space/space.proto @@ -9,20 +9,33 @@ import "api.proto"; import "space/space_types.proto"; service SpaceService { - // 踢出用户 - rpc KickOutUser(KickOutUserParams) returns (KickOutUserResult) { - option (api.post) = "/space/kick"; - } - // 用户退出当前空间 - rpc QuitSpace(QuitSpaceParams) returns (QuitSpaceResult) { - option (api.post) = "/space/quit"; - } - // 用户加入其他空间 + // 创建空间 + rpc CreateSpace(CreateSpaceParams) returns (CreateSpaceParams){ + option (api.post) = '/space/create'; + }; + + // 解散空间 + rpc DissolveSpace(DissolveSpaceParams) returns (DissolveSpaceResult){ + option (api.post) = '/space/dissolve'; + }; + + // 退出空间 + rpc ExitSpace(ExitSpaceParams) returns (ExitSpaceResult){ + option (api.post) = '/space/exit'; + }; + + // 获取空间用户列表 + rpc ListSpaceUsers(ListSpaceUsersParams) returns (ListSpaceUsersResult){ + option (api.post) = '/space/users'; + }; + + // 踢出某人 + rpc RemoveSpaceUser(RemoveSpaceUserParams) returns (RemoveSpaceUserResult){ + option (api.post) = '/space/remove'; + }; + + // 加入空间 rpc JoinSpace(JoinSpaceParams) returns (JoinSpaceResult) { option (api.post) = "/space/join"; - } - // 获取某个空间下的用户列表 - rpc ListSpaceUsers(ListSpaceUsersParams) returns (ListSpaceUsersResult) { - option (api.post) = "/space/users"; }; } diff --git a/code/allapp/allapp-go/idl/space/space_types.proto b/code/allapp/allapp-go/idl/space/space_types.proto index 7528d916..9fa2dc95 100644 --- a/code/allapp/allapp-go/idl/space/space_types.proto +++ b/code/allapp/allapp-go/idl/space/space_types.proto @@ -6,39 +6,69 @@ option go_package = "space"; import "api.proto"; -// --- 空间用户列表 --- +// 创建空间 +message CreateSpaceParams { + string Name = 1 [(api.body)="name"]; +} + +message CreateSpaceResult { + int64 Id = 1 [(api.body)="id"]; + string InviteCode = 2 [(api.body)="invite_code"]; +} + +// 解散空间 +message DissolveSpaceParams { + int64 SpaceId = 1 [(api.body) = "space_id"]; +} + +message DissolveSpaceResult { + +} + +// 获取空间下的成员 message ListSpaceUsersParams { - int64 SpaceId = 1 [(api.query) = "space_id"]; + int64 SpaceId = 1 [(api.body)="space_id"]; } message SpaceUser { - int64 UserId = 1 [(api.query) = "user_id"]; - string UserName = 2 [(api.query) = "user_name"]; - string UserAvatar= 3 [(api.query) = "user_avatar"]; - int32 Role = 4 [(api.query) = "role"]; + int64 Id = 1 [(api.body)="id"]; + string Username = 2 [(api.body)="username"]; + string Avatar = 3 [(api.body)="avatar"]; + int32 Role = 4 [(api.body)="role"]; + int64 LastLoginTime = 5 [(api.body)="last_login_time"]; } message ListSpaceUsersResult { repeated SpaceUser users = 1; } -// 踢出用户 -message KickOutUserParams { - int64 SpaceId = 1 [(api.body) = "space_id"]; - int64 UserId = 2 [(api.body) = "user_id"]; -} -message KickOutUserResult {} - -// 退出空间 -message QuitSpaceParams { - int64 SpaceId = 1 [(api.body) = "space_id"]; -} -message QuitSpaceResult {} - // 加入空间 message JoinSpaceParams { - string InviteCode = 1 [(api.body) = "invite_code"]; + string InviteCode = 1 [(api.body)="invite_code",(api.vd)="$ != ''"]; // 邀请码 +} + +message JoinSpaceResult { + int64 Id = 1 [(api.body)="id"]; + string Name = 2 [(api.body)="name"]; +} + +// 退出空间 +message ExitSpaceParams { + +} + +message ExitSpaceResult { + +} + +// 踢出成员 +message RemoveSpaceUserParams { + int64 SpaceId = 1 [(api.body) = "space_id",(api.vd)="$ != 0"]; + int64 UserId = 2 [(api.body) = "user_id",(api.vd)="$ != 0"]; +} + +message RemoveSpaceUserResult { + } -message JoinSpaceResult {} diff --git a/code/allapp/allapp-go/idl/user/user.proto b/code/allapp/allapp-go/idl/user/user.proto index c5ea84e9..431db753 100644 --- a/code/allapp/allapp-go/idl/user/user.proto +++ b/code/allapp/allapp-go/idl/user/user.proto @@ -10,7 +10,7 @@ import "user/user_types.proto"; service UserService { // 获取当前用户所属的所有空间 - rpc ListUserSpaces(ListUserSpacesParams) returns (ListUserSpacesResult) { - option (api.get) = "/user/spaces"; + rpc GetUserSpace(GetUserSpaceParams) returns (UserSpace) { + option (api.get) = "/user/space"; }; } diff --git a/code/allapp/allapp-go/idl/user/user_types.proto b/code/allapp/allapp-go/idl/user/user_types.proto index 6e4e76bc..27cbd251 100644 --- a/code/allapp/allapp-go/idl/user/user_types.proto +++ b/code/allapp/allapp-go/idl/user/user_types.proto @@ -7,7 +7,7 @@ option go_package = "user"; import "api.proto"; // --- 用户下的空间列表 --- -message ListUserSpacesParams {} +message GetUserSpaceParams {} message UserSpace { int64 Id = 1 [(api.body)="id"]; @@ -16,6 +16,3 @@ message UserSpace { int32 Role = 4 [(api.body)="role"]; } -message ListUserSpacesResult { - repeated UserSpace Spaces = 1 [(api.body)="spaces"]; -} \ No newline at end of file diff --git a/code/allapp/allapp-go/utils/pgtypex/pgtypex.go b/code/allapp/allapp-go/utils/pgtypex/pgtypex.go index 2c04b123..9d45b3b3 100644 --- a/code/allapp/allapp-go/utils/pgtypex/pgtypex.go +++ b/code/allapp/allapp-go/utils/pgtypex/pgtypex.go @@ -129,6 +129,13 @@ func TimestampToMillis(ts pgtype.Timestamp) int64 { return ts.Time.UnixMilli() } +func TimestamptzToMillis(ts pgtype.Timestamptz) int64 { + if !ts.Valid { + return 0 + } + return ts.Time.UnixMilli() +} + func DateToString(d pgtype.Date) string { if !d.Valid { return "" diff --git a/code/allapp/allapp-go/utils/response/response.go b/code/allapp/allapp-go/utils/response/response.go index 01c4d841..ac5c14ad 100644 --- a/code/allapp/allapp-go/utils/response/response.go +++ b/code/allapp/allapp-go/utils/response/response.go @@ -17,15 +17,17 @@ type Result struct { // HttpCode 响应状态码 var HttpCode = struct { - Success int - Unauthorized int - Fail int - RefreshToken int + Success int + Unauthorized int + Fail int + ErrSpaceRequired int + ErrSpaceNoPermission int }{ - Success: 200, - Unauthorized: 401, - Fail: 500, - RefreshToken: 402, + Success: 200, + Unauthorized: 401, + Fail: 500, + ErrSpaceRequired: 501, + ErrSpaceNoPermission: 502, } // Builder 响应构建器 diff --git a/code/allapp/allapp-rn/src/request/api/space/space.ts b/code/allapp/allapp-rn/src/request/api/space/space.ts index 66f46b60..db53e6c0 100644 --- a/code/allapp/allapp-rn/src/request/api/space/space.ts +++ b/code/allapp/allapp-rn/src/request/api/space/space.ts @@ -1,12 +1,20 @@ -import type { CreateSpaceParams, CreateSpaceResult, DissolveSpaceParams, DissolveSpaceResult } from '@/types/space/space' +import type { JoinSpaceParams, KickOutUserParams, ListSpaceUsersResult } from '@/types/space/space' import alovaInstance from '../../index' const API_PREFIX = '/space' -export function createSpaceApi(params: CreateSpaceParams) { - return alovaInstance.Post>(`${API_PREFIX}/create`, params) +export function joinSpaceApi(params: JoinSpaceParams) { + return alovaInstance.Post>(`${API_PREFIX}/join`, params) } -export function dissolveSpaceApi(params: DissolveSpaceParams) { - return alovaInstance.Post>(`${API_PREFIX}/dissolve`, params) +export function kickOutUserApi(params: KickOutUserParams) { + return alovaInstance.Post>(`${API_PREFIX}/kick`, params) +} + +export function quitSpaceApi() { + return alovaInstance.Post>(`${API_PREFIX}/quit`) +} + +export function listSpaceUsersApi() { + return alovaInstance.Post>(`${API_PREFIX}/users`) } diff --git a/code/allapp/allapp-rn/src/request/api/space/spaceUser.ts b/code/allapp/allapp-rn/src/request/api/space/spaceUser.ts deleted file mode 100644 index cee36e52..00000000 --- a/code/allapp/allapp-rn/src/request/api/space/spaceUser.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { - ExitSpaceParams, - ExitSpaceResult, - JoinSpaceParams, - JoinSpaceResult, - ListSpaceUsersParams, - ListSpaceUsersResult, - RemoveSpaceUserParams, - RemoveSpaceUserResult, -} from '@/types/space/spaceUser' -import alovaInstance from '../../index' - -const API_PREFIX = '/space/user' - -export function getUserSpaceApi() { - return alovaInstance.Get>(`${API_PREFIX}/get`) -} - -export function exitSpaceApi(params: ExitSpaceParams) { - return alovaInstance.Post>(`${API_PREFIX}/exit`, params) -} - -export function joinSpaceApi(params: JoinSpaceParams) { - return alovaInstance.Post>(`${API_PREFIX}/join`, params) -} - -export function listSpaceUsersApi(params: ListSpaceUsersParams) { - return alovaInstance.Post>(`${API_PREFIX}/list`, params) -} - -export function removeSpaceUserApi(params: RemoveSpaceUserParams) { - return alovaInstance.Post>(`${API_PREFIX}/remove`, params) -} diff --git a/code/allapp/allapp-rn/src/request/api/user.ts b/code/allapp/allapp-rn/src/request/api/user.ts new file mode 100644 index 00000000..9bd364b5 --- /dev/null +++ b/code/allapp/allapp-rn/src/request/api/user.ts @@ -0,0 +1,8 @@ +import type { ListUserSpacesResult } from '@/types/user' +import alovaInstance from '../index' + +const API_PREFIX = '/user' + +export function listUserSpacesApi() { + return alovaInstance.Post>(`${API_PREFIX}/spaces`) +} diff --git a/code/allapp/allapp-rn/src/request/index.ts b/code/allapp/allapp-rn/src/request/index.ts index e1c32c43..e88b956b 100644 --- a/code/allapp/allapp-rn/src/request/index.ts +++ b/code/allapp/allapp-rn/src/request/index.ts @@ -1,5 +1,6 @@ import type { Method } from 'alova' import type { AxiosError } from 'axios' +import type { ListUserSpacesResult } from '@/types/user' import { axiosRequestAdapter } from '@alova/adapter-axios' import { createAlova } from 'alova' import { useNavStore } from '@/store/navigation' @@ -11,12 +12,13 @@ enum HttpCode { Success = 200, Unauthorized = 401, Fail = 500, + ErrSpaceRequired = 501, + ErrSpaceNoPermission = 502, } // 仅保留「无需登录」接口 const WhiteList = [ '/auth/login/**', - '/auth/register/**', ] function isWhiteListed(url: string) { @@ -30,14 +32,14 @@ function isWhiteListed(url: string) { } const alovaInstance = createAlova({ - // baseURL: 'http://192.168.5.6:8086/app', - baseURL: 'http://192.168.1.137:8086/app', + baseURL: 'http://192.168.5.6:8086/app', + // baseURL: 'http://192.168.1.137:8086/app', requestAdapter: axiosRequestAdapter(), timeout: 5000, cacheFor: null, responded: { - onSuccess: async (response, _method: Method) => { + onSuccess: async (response, method: Method) => { const resData = response.data as ResponseData const result = { @@ -45,17 +47,28 @@ const alovaInstance = createAlova({ isSuccess: resData.code === HttpCode.Success, } - /** - * 登录态失效: - * - 清空本地状态 - * - 跳转登录页 - * - 不做 token 刷新、不重试请求 - */ if (resData.code === HttpCode.Unauthorized) { useUserStore.getState().clear() useNavStore.getState().navigateToAuth() return Promise.reject(new Error('登录已失效')) } + else if (resData.code === HttpCode.ErrSpaceRequired || resData.code === HttpCode.ErrSpaceNoPermission) { + if (method.meta?.spaceRetried) + return Promise.reject(new Error('space retry failed')) + + method.meta = { ...method.meta, spaceRetried: true } + + const res = await alovaInstance.Post>('/user/spaces').send() + if (!res.isSuccess || res.data.spaces.length === 0) + return Promise.reject(new Error('没有可用空间,请刷新后再试')) + + const defaultSpace = res.data.spaces[0] + + useSpaceStore.getState().setUserSpace(defaultSpace) + + method.config.headers['X-Space-Id'] = defaultSpace.id + return method.send() + } return result }, @@ -111,12 +124,12 @@ const alovaInstance = createAlova({ } // 注入 JWT - method.config.headers.token = userStore.userInfo!.token + method.config.headers.Token = userStore.userInfo!.token // 注入 space 信息(如果存在) const userSpace = useSpaceStore.getState().userSpace if (userSpace) { - method.config.headers['x-space-id'] = userSpace.space_id + method.config.headers['X-Space-Id'] = userSpace.id } }, }) diff --git a/code/allapp/allapp-rn/src/types/global.d.ts b/code/allapp/allapp-rn/src/types/global.d.ts index b038a71f..c8cf6723 100644 --- a/code/allapp/allapp-rn/src/types/global.d.ts +++ b/code/allapp/allapp-rn/src/types/global.d.ts @@ -17,8 +17,8 @@ declare global { } interface UserSpace { - space_id: number - space_name: string + id: number + name: string invite_code: string role: number } diff --git a/code/allapp/allapp-rn/src/types/space/space.ts b/code/allapp/allapp-rn/src/types/space/space.ts index 564340df..ae88593c 100644 --- a/code/allapp/allapp-rn/src/types/space/space.ts +++ b/code/allapp/allapp-rn/src/types/space/space.ts @@ -3,22 +3,20 @@ export interface JoinSpaceParams { invite_code: string } -export interface JoinSpaceResult { - -} - // 踢出用户 export interface KickOutUserParams { - space_id: number user_id: number } -export interface KickOutUserResult {} - -// 退出空间 -export interface QuitSpaceParams { - space_id: number +// 空间用户列表 +export interface SpaceUser { + user_id: number + user_name: number + user_avatar: string + role: number } -export interface QuitSpaceResult {} +export interface ListSpaceUsersResult { + users: SpaceUser[] +} diff --git a/code/allapp/allapp-rn/src/types/space/spaceUser.ts b/code/allapp/allapp-rn/src/types/space/spaceUser.ts deleted file mode 100644 index f0e009bf..00000000 --- a/code/allapp/allapp-rn/src/types/space/spaceUser.ts +++ /dev/null @@ -1,40 +0,0 @@ -// 退出空间 -export interface ExitSpaceParams { - -} -export interface ExitSpaceResult { - -} - -// 获取空间列表用户 -export interface SpaceUser { - user_id: number - username: string - space_role: number - active_time: string -} - -export interface ListSpaceUsersParams { -} - -export interface ListSpaceUsersResult { - users: SpaceUser[] -} - -// 踢出空间 -export interface RemoveSpaceUserParams { - user_id: number -} - -export interface RemoveSpaceUserResult { - -} - -// 加入空间 -export interface JoinSpaceParams { - invite_code: string -} - -export interface JoinSpaceResult { - -} diff --git a/code/allapp/allapp-rn/src/types/user.ts b/code/allapp/allapp-rn/src/types/user.ts new file mode 100644 index 00000000..75a18c9e --- /dev/null +++ b/code/allapp/allapp-rn/src/types/user.ts @@ -0,0 +1,10 @@ +export interface UserSpace { + id: number + name: string + invite_code: string + role: number +} + +export interface ListUserSpacesResult { + spaces: UserSpace[] +}