info address
This commit is contained in:
parent
79120e1fd9
commit
c42c37f65e
|
@ -68,7 +68,7 @@ func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (res
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func (a *FsAddressModel) UpdateAddAddress(ctx context.Context, address *FsAddress) (err error) {
|
||||
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).
|
||||
|
|
|
@ -88,7 +88,7 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
|
|||
}
|
||||
|
||||
// 插入数据库 更新地址
|
||||
err := m.UpdateAddAddress(l.ctx, address)
|
||||
err := m.UpdateAddress(l.ctx, address)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||
|
|
|
@ -42,6 +42,10 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
|
|||
|
||||
now := time.Now().UTC()
|
||||
|
||||
if req.AddressId == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, "address_id must setting")
|
||||
}
|
||||
|
||||
address := gmodel.FsAddress{
|
||||
AddressId: req.AddressId,
|
||||
UserId: &userinfo.UserId,
|
||||
|
@ -56,10 +60,9 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
|
|||
City: &req.City,
|
||||
State: &req.State,
|
||||
Utime: &now,
|
||||
Ltime: &now,
|
||||
}
|
||||
|
||||
err := l.svcCtx.AllModels.FsAddress.UpdateAddAddress(l.ctx, &address)
|
||||
err := l.svcCtx.AllModels.FsAddress.UpdateAddress(l.ctx, &address)
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ service info {
|
|||
post /api/info/address/add(AddressRequest) returns (response);
|
||||
|
||||
@handler AddressUpdateHandler
|
||||
post /api/info/address/update(AddressObjectRequest) returns (response);
|
||||
post /api/info/address/update(AddressRequest) returns (response);
|
||||
|
||||
@handler AddressDeleteHandler
|
||||
post /api/info/address/delete(AddressIdRequest) returns (response);
|
||||
|
|
Loading…
Reference in New Issue
Block a user