feat(user): 初始化用户服务
- 新增用户登录和注册功能 - 实现基本的用户信息验证 - 集成数据库连接和查询
This commit is contained in:
parent
2024d1793c
commit
a53f8f8a5a
@ -16,5 +16,6 @@ func NewLoginService(ctx context.Context) *LoginService {
|
||||
func (s *LoginService) Run(req *user.LoginReq) (resp *user.LoginResp, err error) {
|
||||
// Finish your business logic.
|
||||
|
||||
resp = &user.LoginResp{UserId: 111}
|
||||
return
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/suyiiyii/hertz101/app/user/biz/dal/query"
|
||||
user "github.com/suyiiyii/hertz101/rpc_gen/kitex_gen/user"
|
||||
)
|
||||
|
||||
@ -15,6 +17,10 @@ func NewRegisterService(ctx context.Context) *RegisterService {
|
||||
// Run create note info
|
||||
func (s *RegisterService) Run(req *user.RegisterReq) (resp *user.RegisterResp, err error) {
|
||||
// Finish your business logic.
|
||||
if req.Password == "" || req.Email == "" {
|
||||
return nil, errors.New("password or email is empty")
|
||||
}
|
||||
query.Q.User
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/suyiiyii/hertz101/app/user/biz/dal"
|
||||
"github.com/suyiiyii/hertz101/app/user/biz/dal/mysql"
|
||||
"github.com/suyiiyii/hertz101/app/user/biz/dal/query"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
@ -21,6 +24,8 @@ func main() {
|
||||
if err != nil {
|
||||
klog.Error(err.Error())
|
||||
}
|
||||
dal.Init()
|
||||
query.Use(mysql.DB)
|
||||
opts := kitexInit()
|
||||
|
||||
svr := userservice.NewServer(new(UserServiceImpl), opts...)
|
||||
|
Loading…
x
Reference in New Issue
Block a user