todo: add-address
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
@@ -38,5 +39,62 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
|
||||
return resp.SetStatus(basic.CodeSafeValueRangeErr)
|
||||
}
|
||||
|
||||
return resp.SetStatus(basic.CodeOK)
|
||||
m := gmodel.NewFsAddressModel(l.svcCtx.MysqlConn)
|
||||
var status int64 = 1
|
||||
|
||||
if req.Id == 0 {
|
||||
// $address->country = 'USA';
|
||||
// $address->status = 1;
|
||||
// $address->user_id = $uid;
|
||||
var (
|
||||
country string = "USA"
|
||||
|
||||
isDefautl int64 = 1
|
||||
)
|
||||
createOne := &gmodel.FsAddress{
|
||||
Name: &req.Name,
|
||||
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,
|
||||
IsDefault: &isDefautl,
|
||||
}
|
||||
_, 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": createOne.Id})
|
||||
}
|
||||
|
||||
address := &gmodel.FsAddress{
|
||||
Id: req.Id,
|
||||
Name: &req.Name,
|
||||
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,
|
||||
IsDefault: &req.IsDefault,
|
||||
}
|
||||
|
||||
err := m.UpdateAddAddress(l.ctx, address)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeDbUpdateErr)
|
||||
}
|
||||
|
||||
return resp.SetStatus(basic.CodeOK, map[string]int64{"id": address.Id})
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (l *UserSaveBasicInfoLogic) UserSaveBasicInfo(req *types.RequestBasicInfoFo
|
||||
case gmodel.ErrRecordNotFound:
|
||||
return resp.SetStatus(basic.CodeUserIdNotFoundErr)
|
||||
default:
|
||||
return resp.SetStatusWithMessage(basic.CodeUpdateErr, err.Error())
|
||||
return resp.SetStatusWithMessage(basic.CodeDbUpdateErr, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user