1 Star 0 Fork 0

允许我面无表情却想你好深/easy-chat

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
finduserlogic.go 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
允许我面无表情却想你好深 提交于 2025-05-06 01:56 +08:00 . 修改go.mod
package logic
import (
"context"
"gitee.com/imxxm/easy-chat/apps/user/models"
"gitee.com/imxxm/easy-chat/apps/user/rpc/internal/svc"
"gitee.com/imxxm/easy-chat/apps/user/rpc/user"
"github.com/jinzhu/copier"
"github.com/zeromicro/go-zero/core/logx"
)
type FindUserLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewFindUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindUserLogic {
return &FindUserLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *FindUserLogic) FindUser(in *user.FindUserReq) (*user.FindUserResp, error) {
// todo: add your logic here and delete this line
var (
userEntitys []*models.Users
err error
)
if in.Phone != "" {
userEntity, err := l.svcCtx.UsersModel.FindByPhone(l.ctx, in.Phone)
if err == nil {
userEntitys = append(userEntitys, userEntity)
}
} else if in.Name != "" {
userEntitys, err = l.svcCtx.UsersModel.ListByName(l.ctx, in.Name)
} else if len(in.Ids) > 0 {
userEntitys, err = l.svcCtx.UsersModel.ListByIds(l.ctx, in.Ids)
}
if err != nil {
return nil, err
}
var resp []*user.UserEntity
copier.Copy(&resp, &userEntitys)
return &user.FindUserResp{
User: resp,
}, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/imxxm/easy-chat.git
git@gitee.com:imxxm/easy-chat.git
imxxm
easy-chat
easy-chat
v1.0.4

搜索帮助