2023-06-08 07:41:49 +00:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"fusenapi/model"
|
|
|
|
"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) (resp *types.Response) {
|
|
|
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
|
|
|
m := model.NewFsAddressModel(l.svcCtx.MysqlConn)
|
|
|
|
user := auth.GetUserInfoFormCtx(l.ctx)
|
2023-06-08 10:55:08 +00:00
|
|
|
if user.UserId == 0 {
|
|
|
|
return resp.SetStatus(basic.CodeUnAuth)
|
|
|
|
}
|
2023-06-08 07:41:49 +00:00
|
|
|
// model里设置了 返回值. 和 types 里的一至可以直接返回
|
|
|
|
data, err := m.FindDataAddressList(l.ctx, user.UserId)
|
|
|
|
if err != nil {
|
|
|
|
logx.Error(err)
|
|
|
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error())
|
|
|
|
}
|
|
|
|
return resp.SetStatus(basic.CodeOK, data)
|
|
|
|
}
|