first commit
This commit is contained in:
40
apps/gateway/internal/logic/user/enterpriseauthlogic.go
Normal file
40
apps/gateway/internal/logic/user/enterpriseauthlogic.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"tianyuan-api/apps/user/user"
|
||||
|
||||
"tianyuan-api/apps/gateway/internal/svc"
|
||||
"tianyuan-api/apps/gateway/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type EnterpriseAuthLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewEnterpriseAuthLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EnterpriseAuthLogic {
|
||||
return &EnterpriseAuthLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *EnterpriseAuthLogic) EnterpriseAuth(req *types.EnterpriseAuthReq) error {
|
||||
// 从上下文中解析 JWT,获取用户ID
|
||||
userId, ok := l.ctx.Value("userId").(int64)
|
||||
if !ok {
|
||||
return errors.New("无法获取 userId")
|
||||
}
|
||||
_, err := l.svcCtx.EntRpc.CreateEnterpriseAuth(l.ctx, &user.EnterpriseAuthReq{UserId: userId, EnterpriseName: req.EnterpriseName, EnterpriseContact: req.EnterpriseContact, CreditCode: req.CreditCode, LegalPerson: req.LegalPerson, BusinessLicense: req.BusinessLicense})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user