43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
|
package logic
|
||
|
|
||
|
import (
|
||
|
"fusenapi/utils/auth"
|
||
|
"fusenapi/utils/basic"
|
||
|
|
||
|
"context"
|
||
|
|
||
|
"fusenapi/server/home-user-auth/internal/svc"
|
||
|
"fusenapi/server/home-user-auth/internal/types"
|
||
|
|
||
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
)
|
||
|
|
||
|
type UserAddAddressLogic struct {
|
||
|
logx.Logger
|
||
|
ctx context.Context
|
||
|
svcCtx *svc.ServiceContext
|
||
|
}
|
||
|
|
||
|
func NewUserAddAddressLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAddAddressLogic {
|
||
|
return &UserAddAddressLogic{
|
||
|
Logger: logx.WithContext(ctx),
|
||
|
ctx: ctx,
|
||
|
svcCtx: svcCtx,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||
|
// userinfo 传入值时, 一定不为null
|
||
|
if !userinfo.IsUser() {
|
||
|
return resp.SetStatus(basic.CodeUnAuth)
|
||
|
}
|
||
|
|
||
|
// 确认这个IsDefault的值范围
|
||
|
if !auth.CheckValueRange(req.IsDefault, 0, 1) {
|
||
|
return resp.SetStatus(basic.CodeSafeValueRangeErr)
|
||
|
}
|
||
|
|
||
|
return resp.SetStatus(basic.CodeOK)
|
||
|
}
|