44 lines
1.1 KiB
Go
44 lines
1.1 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 UserAddressListLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewUserAddressListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAddressListLogic {
|
|
return &UserAddressListLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *UserAddressListLogic) UserAddressList(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
|
if !userinfo.IsUser() {
|
|
return resp.SetStatus(basic.CodeUnAuth)
|
|
}
|
|
|
|
m := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
|
|
|
data, err := m.GetUserAllAddress(l.ctx, userinfo.UserId)
|
|
if err != nil {
|
|
logx.Error(err)
|
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
|
}
|
|
return resp.SetStatus(basic.CodeOK, data)
|
|
}
|