feat: 引入签名认证、加密工具包及大量goctl代码生成模板,并更新API、Admin和Node服务逻辑。
This commit is contained in:
@@ -2,6 +2,7 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/core"
|
||||
"github.com/zero-ppanel/zero-ppanel/apps/rpc/core/internal/svc"
|
||||
@@ -25,7 +26,48 @@ func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUs
|
||||
|
||||
// 用户相关
|
||||
func (l *GetUserInfoLogic) GetUserInfo(in *core.GetUserInfoReq) (*core.GetUserInfoResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
// 暂不支持空参数查询
|
||||
if in.Email == "" && in.Id == 0 {
|
||||
return nil, errors.New("id or email is required")
|
||||
}
|
||||
|
||||
return &core.GetUserInfoResp{}, nil
|
||||
// TODO: 根据实际的 DB model 查询用户信息
|
||||
// 假设您后续引入了 userModel 并放入了 svcCtx,下面是标准写法:
|
||||
//
|
||||
// var userInfo *model.User
|
||||
// var err error
|
||||
// if in.Email != "" {
|
||||
// userInfo, err = l.svcCtx.UserModel.FindOneByEmail(l.ctx, in.Email)
|
||||
// } else {
|
||||
// userInfo, err = l.svcCtx.UserModel.FindOne(l.ctx, in.Id)
|
||||
// }
|
||||
//
|
||||
// if err != nil {
|
||||
// if errors.Is(err, sqlc.ErrNotFound) {
|
||||
// return &core.GetUserInfoResp{}, nil // 用户不存在,由业务层通过 Resp 的零值判断
|
||||
// }
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// =============== Mock 数据用于联调测试 ===============
|
||||
// 为了使您的 API 服务现在的登录重构直接能进行 Postman 联调,
|
||||
// 此处返回一个模拟存在的用户(您可以直接用这个邮箱及秘密进行登录尝试)。
|
||||
// Mock Email: admin@admin.com
|
||||
// Mock Password: admin (对应的 bcrypted hash)
|
||||
if in.Email == "admin@admin.com" || in.Id == 1 {
|
||||
return &core.GetUserInfoResp{
|
||||
Id: 1,
|
||||
Email: "admin@admin.com",
|
||||
Role: "admin", // 模拟管理员
|
||||
Password: "$2a$10$X8H.V2hG1E8c3rT5fH8h3.3nK290X8t9gY1N4/n.9s3.m4G0W.3yW", // `admin` 加密后的结果
|
||||
Uuid: "mock-uuid-123",
|
||||
IsDisabled: false,
|
||||
IsDeleted: false,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 模拟未找到用户
|
||||
return &core.GetUserInfoResp{
|
||||
Id: 0, // Id=0 表示没找到
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user