49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package userlogic
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
|
|
|
"tianyuan-api/apps/user/internal/svc"
|
|
"tianyuan-api/apps/user/user"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetEnterpriseAuthStatusLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetEnterpriseAuthStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEnterpriseAuthStatusLogic {
|
|
return &GetEnterpriseAuthStatusLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetEnterpriseAuthStatusLogic) GetEnterpriseAuthStatus(in *user.GetEnterpriseAuthStatusReq) (*user.GetEnterpriseAuthStatusResp, error) {
|
|
// 查询企业信息
|
|
enterprise, err := l.svcCtx.EnterpriseModel.FindOneByUserId(l.ctx, in.UserId)
|
|
if err != nil {
|
|
if errors.Is(err, sqlc.ErrNotFound) {
|
|
return &user.GetEnterpriseAuthStatusResp{
|
|
IsAuth: false,
|
|
}, nil
|
|
}
|
|
return nil, err
|
|
}
|
|
|
|
if enterprise == nil {
|
|
return &user.GetEnterpriseAuthStatusResp{
|
|
IsAuth: false,
|
|
}, nil
|
|
}
|
|
return &user.GetEnterpriseAuthStatusResp{
|
|
IsAuth: true,
|
|
}, nil
|
|
}
|