Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
e991ee3966
|
@ -14,7 +14,7 @@ func (a *FsAddressModel) GetOne(ctx context.Context, addressId int64, userId int
|
|||
}
|
||||
|
||||
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []FsAddress, err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = ?", userId, 1).Order("`ltime` DESC").Find(&resp).Error
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = 1", userId).Order("`ltime` DESC").Find(&resp).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (res
|
|||
func (a *FsAddressModel) UpdateAddress(ctx context.Context, address *FsAddress) (err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Transaction(func(tx *gorm.DB) error {
|
||||
err = tx.
|
||||
Where("user_id = ? and address_id = ? and status = 1 ", address.UserId, address.AddressId).
|
||||
Where("address_id = ? and user_id = ? and status = 1 ", address.AddressId, address.UserId).
|
||||
Updates(address).Error
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -88,19 +88,19 @@ func (a *FsAddressModel) SettingUserDefaultAddress(ctx context.Context, userId i
|
|||
|
||||
now := time.Now().UTC()
|
||||
|
||||
err = tx.Where("`user_id` = ? and `status` = 1 and `address_id` = ? ", userId, addressId).Take(nil).Error
|
||||
err = tx.Where("`address_id` = ? and `user_id` = ? and `status` = 1 ", addressId, userId).Take(nil).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = tx.Where("`user_id` = ? and `status` = 1 and `address_id` = ?", userId, addressId).
|
||||
err = tx.Where("`address_id` = ? and `user_id` = ? and `status` = 1 ", addressId, userId).
|
||||
UpdateColumn("ltime", now.AddDate(250, 0, 0)).
|
||||
UpdateColumn("utime", now).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = tx.Model(&FsAddress{}).Where("`user_id` = ? and `status` = 1 and `address_id` != ? and `ltime` > ?", userId, addressId, now.AddDate(10, 0, 0)).
|
||||
err = tx.Model(&FsAddress{}).Where("`address_id` != ? and `user_id` = ? and `status` = 1 and `ltime` > ?", addressId, userId, now.AddDate(10, 0, 0)).
|
||||
UpdateColumn("ltime", now).Error
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
|
@ -109,12 +109,27 @@ func (a *FsAddressModel) SettingUserDefaultAddress(ctx context.Context, userId i
|
|||
return nil
|
||||
})
|
||||
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *FsAddressModel) DeleteOne(ctx context.Context, addressId int64, userId int64) (err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).
|
||||
Where("`address_id` = ? and `user_id` = ? and `status` = ? ", addressId, userId, 1).
|
||||
Where("`address_id` = ? and `user_id` = ? and `status` = 1 ", addressId, userId).
|
||||
UpdateColumn("status", 0).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateUsedAddress 当每次订单成功后, 更新一次地址使用时间
|
||||
func (a *FsAddressModel) UpdateUsedAddress(ctx context.Context, addressId int64, userId int64) (err error) {
|
||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Transaction(func(tx *gorm.DB) error {
|
||||
logx.Info("address_id:", addressId, " update used")
|
||||
now := time.Now().UTC()
|
||||
err = tx.Where("`address_id` = ? and `user_id` = ? and `status` = 1 and `ltime` < ?", addressId, userId, now).
|
||||
UpdateColumn("ltime", now).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -47,9 +47,7 @@ func (p *FsUserInfoModel) CreateOrUpdate(gormDB *gorm.DB, req *FsUserInfo) (resp
|
|||
}
|
||||
|
||||
func (m *FsUserInfoModel) MergeMetadata(userId int64, meta any) error {
|
||||
return fssql.MetadataModulePATCH(m.db, "profile", FsUserInfo{}, map[string]any{
|
||||
"base": meta,
|
||||
}, "user_id = ?", userId)
|
||||
return fssql.MetadataModulePATCH(m.db, "profile", FsUserInfo{}, meta, "user_id = ?", userId)
|
||||
}
|
||||
|
||||
func (m *FsUserInfoModel) GetProfile(ctx context.Context, pkey string, userId int64) (map[string]any, error) {
|
||||
|
|
|
@ -121,13 +121,58 @@ func (u *FsUserModel) RegisterByGoogleOAuth(ctx context.Context, token *auth.Reg
|
|||
user.GoogleId = &googleId
|
||||
user.PasswordHash = &token.Password
|
||||
user.FirstName = &firstName
|
||||
user.FirstName = &lastName
|
||||
user.LastName = &lastName
|
||||
err = tx.Model(&FsUser{}).Create(user).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 继承guest_id的资源表
|
||||
return InheritGuestIdResource(tx, user.Id, token.GuestId, nil)
|
||||
return InheritGuestIdResource(tx, user.Id, token.GuestId, func(txResouce, txUserMaterial, txUserInfo *gorm.DB) error {
|
||||
userProfileBase := UserProfileBase{
|
||||
FirstName: *user.FirstName,
|
||||
LastName: *user.LastName,
|
||||
Email: *user.Email,
|
||||
}
|
||||
|
||||
userProfile := &UserProfile{
|
||||
ProfileBase: userProfileBase,
|
||||
}
|
||||
|
||||
metadata, err := json.Marshal(userProfile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
now := time.Now().UTC()
|
||||
uinfo := &FsUserInfo{
|
||||
Module: FsString("profile"),
|
||||
UserId: &user.Id,
|
||||
GuestId: &token.GuestId,
|
||||
Metadata: &metadata,
|
||||
Ctime: &now,
|
||||
Utime: &now,
|
||||
}
|
||||
|
||||
// logx.Error(metadata)
|
||||
|
||||
err = txUserInfo.Where("module = 'profile' and user_id = ?", *uinfo.UserId).Take(nil).Error
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = tx.Model(&FsUserInfo{}).Create(uinfo).Error
|
||||
// logx.Info(err, "*uinfo.UserId:", *uinfo.UserId, " ", uinfo.Id)
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = fssql.MetadataModulePATCH(txUserInfo, "profile", FsUserInfo{}, metadata, "user_id = ?", *uinfo.UserId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -178,6 +223,7 @@ func (u *FsUserModel) RegisterByFusen(ctx context.Context, token *auth.RegisterT
|
|||
FirstName: FirstName,
|
||||
LastName: LastName,
|
||||
Resetaurant: Resetaurant,
|
||||
Email: *user.Email,
|
||||
}
|
||||
|
||||
userProfile := &UserProfile{
|
||||
|
|
|
@ -38,9 +38,15 @@ func FsBool(v bool) *bool {
|
|||
|
||||
// SubscriptionStatus 订阅状态
|
||||
type SubscriptionStatus struct {
|
||||
SubEmail bool `json:"all_emails"`
|
||||
ItemMap *struct {
|
||||
} `json:"item_map"`
|
||||
NotificationEmail *struct {
|
||||
OrderUpdate bool `json:"order_update"`
|
||||
Newseleter bool `json:"newseleter"`
|
||||
} `json:"notification_email"`
|
||||
|
||||
NotificationPhone *struct {
|
||||
OrderUpdate bool `json:"order_update"`
|
||||
Newseleter bool `json:"newseleter"`
|
||||
} `json:"notification_phone"`
|
||||
}
|
||||
|
||||
type UserProfile struct {
|
||||
|
@ -52,7 +58,7 @@ type UserProfile struct {
|
|||
type UserProfileBase struct {
|
||||
FirstName string `json:"first_name"` // 首名
|
||||
LastName string `json:"last_name"` // 后名
|
||||
UserName string `json:"user_name"` // 用户名
|
||||
Email string `json:"email"` // email
|
||||
Mobile string `json:"mobile"` // 电话
|
||||
Resetaurant string `json:"resetaurant"` // 不知道干什么
|
||||
Company string `json:"company"` // 公司
|
||||
|
|
|
@ -17,36 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/api/user/fonts",
|
||||
Handler: UserFontsHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/user/get-type",
|
||||
Handler: UserGetTypeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/user/basic-info",
|
||||
Handler: UserSaveBasicInfoHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/user/status-config",
|
||||
Handler: UserStatusConfigHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/user/basic-info",
|
||||
Handler: UserBasicInfoHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/user/address-list",
|
||||
Handler: UserAddressListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/user/add-address",
|
||||
Handler: UserAddAddressHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/user/contact-service",
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/home-user-auth/internal/logic"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
)
|
||||
|
||||
func UserAddAddressHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.RequestAddAddress
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewUserAddAddressLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.UserAddAddress(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"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) // IsDefault值超出范围, 返回安全值范围错误
|
||||
}
|
||||
|
||||
m := l.svcCtx.AllModels.FsAddress // 创建地址模型
|
||||
var status int64 = 1 // 默认地址状态为1(正常)
|
||||
|
||||
// 如果ID为0, 表示新增地址
|
||||
if req.Id == 0 {
|
||||
var (
|
||||
country string = "USA" // 国家默认为美国
|
||||
)
|
||||
createOne := &gmodel.FsAddress{ // 构建FsAddress结构体
|
||||
FirstName: &req.FirstName,
|
||||
LastName: &req.LastName,
|
||||
Mobile: &req.Mobile,
|
||||
Street: &req.Street,
|
||||
Suite: &req.Suite,
|
||||
City: &req.City,
|
||||
State: &req.State,
|
||||
Country: &country,
|
||||
Status: &status,
|
||||
UserId: &userinfo.UserId,
|
||||
ZipCode: &req.ZipCode,
|
||||
}
|
||||
created, err := m.CreateOne(l.ctx, createOne) // 新增地址
|
||||
if err != nil {
|
||||
logx.Error(err) // 日志记录错误
|
||||
return resp.SetStatus(basic.CodeDbCreateErr) // 返回数据库创建错误
|
||||
}
|
||||
return resp.SetStatus(basic.CodeOK, map[string]int64{"id": created.AddressId}) // 返回成功并返回地址ID
|
||||
}
|
||||
|
||||
address := &gmodel.FsAddress{
|
||||
AddressId: req.Id,
|
||||
FirstName: &req.FirstName,
|
||||
LastName: &req.LastName,
|
||||
Mobile: &req.Mobile,
|
||||
Street: &req.Street,
|
||||
Suite: &req.Suite,
|
||||
City: &req.City,
|
||||
State: &req.State,
|
||||
Status: &status,
|
||||
UserId: &userinfo.UserId,
|
||||
ZipCode: &req.ZipCode,
|
||||
}
|
||||
|
||||
// 插入数据库 更新地址
|
||||
err := m.UpdateAddress(l.ctx, address)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||
}
|
||||
|
||||
return resp.SetStatus(basic.CodeOK, map[string]int64{"id": address.AddressId})
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"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 := l.svcCtx.AllModels.FsAddress
|
||||
|
||||
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)
|
||||
}
|
|
@ -6,27 +6,27 @@ import (
|
|||
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"fusenapi/server/home-user-auth/internal/logic"
|
||||
"fusenapi/server/home-user-auth/internal/svc"
|
||||
"fusenapi/server/home-user-auth/internal/types"
|
||||
"fusenapi/server/info/internal/logic"
|
||||
"fusenapi/server/info/internal/svc"
|
||||
"fusenapi/server/info/internal/types"
|
||||
)
|
||||
|
||||
func UserAddressListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
func AddressUsedUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.Request
|
||||
var req types.AddressIdRequest
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 创建一个业务逻辑层实例
|
||||
l := logic.NewUserAddressListLogic(r.Context(), svcCtx)
|
||||
l := logic.NewAddressUsedUpdateLogic(r.Context(), svcCtx)
|
||||
|
||||
rl := reflect.ValueOf(l)
|
||||
basic.BeforeLogic(w, r, rl)
|
||||
|
||||
resp := l.UserAddressList(&req, userinfo)
|
||||
resp := l.AddressUsedUpdate(&req, userinfo)
|
||||
|
||||
if !basic.AfterLogic(w, r, rl, resp) {
|
||||
basic.NormalAfterLogic(w, r, resp)
|
|
@ -42,6 +42,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Path: "/api/info/address/update",
|
||||
Handler: AddressUpdateHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/info/address/update/used",
|
||||
Handler: AddressUsedUpdateHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/api/info/address/delete",
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
func UpdateProfileBaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.ProfileBaseRequest
|
||||
var req types.ProfileRequest
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
|
@ -40,6 +40,11 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
|
|||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
|
||||
// 确认这个IsDefault的值范围
|
||||
if !auth.CheckValueRange(req.IsDefault, 0, 1) {
|
||||
return resp.SetStatus(basic.CodeSafeValueRangeErr) // IsDefault值超出范围, 返回安全值范围错误
|
||||
}
|
||||
|
||||
now := time.Now().UTC()
|
||||
|
||||
if req.AddressId == 0 {
|
||||
|
@ -65,6 +70,10 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
|
|||
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
||||
}
|
||||
|
||||
if req.IsDefault > 0 {
|
||||
l.svcCtx.AllModels.FsAddress.SettingUserDefaultAddress(l.ctx, userinfo.UserId, address.AddressId)
|
||||
}
|
||||
|
||||
addresses, err := l.svcCtx.AllModels.FsAddress.GetUserAllAddress(l.ctx, userinfo.UserId)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
|
|
54
server/info/internal/logic/addressusedupdatelogic.go
Normal file
54
server/info/internal/logic/addressusedupdatelogic.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/info/internal/svc"
|
||||
"fusenapi/server/info/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddressUsedUpdateLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAddressUsedUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressUsedUpdateLogic {
|
||||
return &AddressUsedUpdateLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// 处理进入前逻辑w,r
|
||||
// func (l *AddressUsedUpdateLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *AddressUsedUpdateLogic) AddressUsedUpdate(req *types.AddressIdRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
if !userinfo.IsUser() {
|
||||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
|
||||
err := l.svcCtx.AllModels.FsAddress.UpdateUsedAddress(l.ctx, req.AddressId, userinfo.UserId)
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
||||
}
|
||||
|
||||
return resp.SetStatus(basic.CodeOK, map[string]any{
|
||||
"address_id": req.AddressId,
|
||||
}) // 返回成功并返回地址ID
|
||||
|
||||
}
|
||||
|
||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||
// func (l *AddressUsedUpdateLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
// }
|
|
@ -30,13 +30,15 @@ func NewUpdateProfileBaseLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
// func (l *UpdateProfileBaseLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||
// }
|
||||
|
||||
func (l *UpdateProfileBaseLogic) UpdateProfileBase(req *types.ProfileBaseRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
func (l *UpdateProfileBaseLogic) UpdateProfileBase(req *types.ProfileRequest, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||
// userinfo 传入值时, 一定不为null
|
||||
if !userinfo.IsUser() {
|
||||
return resp.SetStatus(basic.CodeUnAuth)
|
||||
}
|
||||
|
||||
req.ProfileBase.Email = nil
|
||||
|
||||
err := l.svcCtx.AllModels.FsUserInfo.MergeMetadata(userinfo.UserId, req)
|
||||
if err != nil {
|
||||
logx.Error(err) // 日志记录错误
|
||||
|
|
|
@ -31,15 +31,35 @@ type AddressRequest struct {
|
|||
State string `json:"state"` //州
|
||||
}
|
||||
|
||||
type ProfileBaseRequest struct {
|
||||
type ProfileRequest struct {
|
||||
ProfileBase *ProfileBase `json:"base,optional,omitempty"` // 基础的个人消息, 姓名 公司等
|
||||
SubscriptionStatus *SubscriptionStatus `json:"sub_status,optional,omitempty"` // 订阅的通知状态
|
||||
}
|
||||
|
||||
type ProfileBase struct {
|
||||
FirstName *string `json:"first_name,optional,omitempty"` // 首名
|
||||
LastName *string `json:"last_name,optional,omitempty"` // 后名
|
||||
UserName *string `json:"user_name,optional,omitempty"` // 用户名
|
||||
Email *string `json:"email,optional,omitempty"` // email
|
||||
Mobile *string `json:"mobile,optional,omitempty"` // 电话
|
||||
Resetaurant *string `json:"resetaurant,optional,omitempty"` // 不知道干什么
|
||||
Company *string `json:"company,optional,omitempty"` // 公司
|
||||
}
|
||||
|
||||
type SubscriptionStatus struct {
|
||||
NotificationEmail NotificationEmail `json:"notification_email,optional,omitempty"`
|
||||
NotificationPhone NotificationPhone `json:"notification_phone,optional,omitempty"`
|
||||
}
|
||||
|
||||
type NotificationEmail struct {
|
||||
OrderUpdate bool `json:"order_update,optional,omitempty"`
|
||||
Newseleter bool `json:"newseleter,optional,omitempty"`
|
||||
}
|
||||
|
||||
type NotificationPhone struct {
|
||||
OrderUpdate bool `json:"order_update,optional,omitempty"`
|
||||
Newseleter bool `json:"newseleter,optional,omitempty"`
|
||||
}
|
||||
|
||||
type QueryProfileRequest struct {
|
||||
TopKey string `json:"top_key"` // 首名
|
||||
}
|
||||
|
|
|
@ -10,68 +10,55 @@ info (
|
|||
import "basic.api"
|
||||
|
||||
service home-user-auth {
|
||||
|
||||
|
||||
// @handler UserRegisterHandler
|
||||
// post /api/user/register(RequestUserRegister) returns (response);
|
||||
//用户字体
|
||||
@handler UserFontsHandler
|
||||
get /api/user/fonts(request) returns (response);
|
||||
//获取用户类型
|
||||
@handler UserGetTypeHandler
|
||||
get /api/user/get-type(request) returns (response);
|
||||
//保存用户基础信息
|
||||
@handler UserSaveBasicInfoHandler
|
||||
post /api/user/basic-info(RequestBasicInfoForm) returns (response);
|
||||
|
||||
//状态配置
|
||||
@handler UserStatusConfigHandler
|
||||
get /api/user/status-config(request) returns (response);
|
||||
//基础信息
|
||||
@handler UserBasicInfoHandler
|
||||
get /api/user/basic-info(request) returns (response);
|
||||
//地址列表
|
||||
@handler UserAddressListHandler
|
||||
get /api/user/address-list(request) returns (response);
|
||||
//添加地址
|
||||
@handler UserAddAddressHandler
|
||||
post /api/user/add-address(RequestAddAddress) returns (response);
|
||||
|
||||
//联系服务
|
||||
@handler UserContactServiceHandler
|
||||
post /api/user/contact-service (RequestContactService) returns (response);
|
||||
|
||||
|
||||
// @handler UserOderListHandler
|
||||
// get /api/user/order-list(RequestOrderId) returns (response);
|
||||
//删除订单
|
||||
@handler UserOderDeleteHandler
|
||||
post /api/user/order-delete(RequestOrderId) returns (response);
|
||||
|
||||
|
||||
//订单列表
|
||||
@handler UserOrderListHandler
|
||||
get /api/user/order-list (UserOrderListReq) returns (response);
|
||||
|
||||
|
||||
//删除订单
|
||||
@handler UserOrderDeleteHandler
|
||||
get /api/user/order-delete (UserOrderDeleteReq) returns (response);
|
||||
|
||||
|
||||
//取消订单
|
||||
@handler UserOrderCancelHandler
|
||||
get /api/user/order-cancel (UserOrderCancelReq) returns (response);
|
||||
|
||||
|
||||
// 用户logo列表
|
||||
@handler UserLogoListHandler
|
||||
get /api/user/logo-list (UserLogoListReq) returns (response);
|
||||
|
||||
|
||||
// 再来一单
|
||||
@handler UserAgainOrderHandler
|
||||
get /api/user/one-more-order (UserAgainOrderReq) returns (response);
|
||||
|
||||
|
||||
// 保存商户信息
|
||||
@handler UserInfoSetHandler
|
||||
post /api/user/set_user_info (UserInfoSetReq) returns (response);
|
||||
|
||||
|
||||
// 用户logo设置当前
|
||||
@handler UserLogoSetHandler
|
||||
post /api/user/logo-set (UserLogoSetReq) returns (response);
|
||||
|
||||
|
||||
// 用户logo模版信息
|
||||
@handler UserLogoTemplateTagSetHandler
|
||||
post /api/user/logo-templatetag-set (UserLogoTemplateTagSetReq) returns (response);
|
||||
|
|
|
@ -17,7 +17,7 @@ service info {
|
|||
post /api/info/user/profile(QueryProfileRequest) returns (response);
|
||||
|
||||
@handler UpdateProfileBaseHandler
|
||||
post /api/info/user/profile/base/update(ProfileBaseRequest) returns (response);
|
||||
post /api/info/user/profile/base/update(ProfileRequest) returns (response);
|
||||
|
||||
@handler AddressDefaultHandler
|
||||
post /api/info/address/default(AddressIdRequest) returns (response);
|
||||
|
@ -28,6 +28,9 @@ service info {
|
|||
@handler AddressUpdateHandler
|
||||
post /api/info/address/update(AddressRequest) returns (response);
|
||||
|
||||
@handler AddressUsedUpdateHandler
|
||||
post /api/info/address/update/used(AddressIdRequest) returns (response);
|
||||
|
||||
@handler AddressDeleteHandler
|
||||
post /api/info/address/delete(AddressIdRequest) returns (response);
|
||||
|
||||
|
@ -62,15 +65,38 @@ type (
|
|||
State string `json:"state"` //州
|
||||
}
|
||||
|
||||
ProfileBaseRequest {
|
||||
FirstName *string `json:"first_name,optional,omitempty"` // 首名
|
||||
LastName *string `json:"last_name,optional,omitempty"` // 后名
|
||||
UserName *string `json:"user_name,optional,omitempty"` // 用户名
|
||||
ProfileRequest {
|
||||
ProfileBase *ProfileBase `json:"base,optional,omitempty"` // 基础的个人消息, 姓名 公司等
|
||||
SubscriptionStatus *SubscriptionStatus `json:"sub_status,optional,omitempty"` // 订阅的通知状态
|
||||
|
||||
}
|
||||
|
||||
ProfileBase {
|
||||
FirstName *string `json:"first_name,optional,omitempty"` // 首名
|
||||
LastName *string `json:"last_name,optional,omitempty"` // 后名
|
||||
// UserName *string `json:"user_name,optional,omitempty"` // 用户名
|
||||
Email *string `json:"email,optional,omitempty"` // email
|
||||
Mobile *string `json:"mobile,optional,omitempty"` // 电话
|
||||
Resetaurant *string `json:"resetaurant,optional,omitempty"` // 不知道干什么
|
||||
Company *string `json:"company,optional,omitempty"` // 公司
|
||||
|
||||
}
|
||||
|
||||
SubscriptionStatus {
|
||||
NotificationEmail NotificationEmail `json:"notification_email,optional,omitempty"`
|
||||
NotificationPhone NotificationPhone `json:"notification_phone,optional,omitempty"`
|
||||
} // 订阅的通知状态
|
||||
|
||||
NotificationEmail {
|
||||
OrderUpdate bool `json:"order_update,optional,omitempty"`
|
||||
Newseleter bool `json:"newseleter,optional,omitempty"`
|
||||
} // 邮件通知设置
|
||||
|
||||
NotificationPhone {
|
||||
OrderUpdate bool `json:"order_update,optional,omitempty"`
|
||||
Newseleter bool `json:"newseleter,optional,omitempty"`
|
||||
} // 电话通知设置
|
||||
|
||||
QueryProfileRequest {
|
||||
TopKey string `json:"top_key"` // 首名
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user