63 lines
2.0 KiB
Go
63 lines
2.0 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"fusenapi/model/gmodel"
|
|
"fusenapi/server/home-user-auth/internal/svc"
|
|
"fusenapi/server/home-user-auth/internal/types"
|
|
"fusenapi/utils/auth"
|
|
"fusenapi/utils/basic"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type UserBasicInfoLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewUserBasicInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserBasicInfoLogic {
|
|
return &UserBasicInfoLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UserBasicInfoLogic) UserBasicInfo(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
|
|
|
if !userinfo.IsUser() {
|
|
// 返回未授权
|
|
return resp.SetStatus(basic.CodeUnAuth)
|
|
}
|
|
|
|
m := gmodel.NewFsUserModel(l.svcCtx.MysqlConn)
|
|
|
|
user, err := m.FindUserById(l.ctx, userinfo.UserId)
|
|
if err != nil {
|
|
logx.Error(err)
|
|
return resp.SetStatus(basic.CodeServiceErr)
|
|
}
|
|
|
|
// $userInfo->type = $userInfo->type != 0 ? $userInfo->type : '';
|
|
// $userInfo->is_order_status_email = (boolean)$userInfo->is_order_status_email;
|
|
// $userInfo->is_email_advertisement = (boolean)$userInfo->is_email_advertisement;
|
|
// $userInfo->is_order_status_phone = (boolean)$userInfo->is_order_status_phone;
|
|
// $userInfo->is_phone_advertisement = (boolean)$userInfo->is_phone_advertisement;
|
|
// $userInfo->is_open_render = (boolean)$userInfo->is_open_render;
|
|
// $userInfo->is_low_rendering = (boolean)$userInfo->is_low_rendering;
|
|
// $userInfo->is_remove_bg = (boolean)$userInfo->is_remove_bg;
|
|
|
|
return resp.SetStatus(basic.CodeOK, types.DataUserBasicInfo{
|
|
Type: *user.Type,
|
|
IsOrderStatusEmail: *user.IsOrderStatusEmail > 0,
|
|
IsEmailAdvertisement: *user.IsEmailAdvertisement > 0,
|
|
IsOrderStatusPhone: *user.IsOrderStatusPhone > 0,
|
|
IsPhoneAdvertisement: *user.IsPhoneAdvertisement > 0,
|
|
IsOpenRender: *user.IsOpenRender > 0,
|
|
IsLowRendering: *user.IsLowRendering > 0,
|
|
IsRemoveBg: *user.IsRemoveBg > 0,
|
|
})
|
|
}
|