Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
e917792988
|
@ -1,8 +1,9 @@
|
||||||
package gmodel
|
package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gorm.io/gorm"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fs_address 用户地址表
|
// fs_address 用户地址表
|
||||||
|
@ -19,7 +20,6 @@ type FsAddress struct {
|
||||||
Country *string `gorm:"default:'';" json:"country"` //
|
Country *string `gorm:"default:'';" json:"country"` //
|
||||||
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
ZipCode *string `gorm:"default:'';" json:"zip_code"` //
|
||||||
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
Status *int64 `gorm:"default:0;" json:"status"` // 1正常 0异常
|
||||||
IsDefault *int64 `gorm:"index;default:0;" json:"is_default"` // 1默认地址,0非默认地址
|
|
||||||
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` // 创建时间
|
Ctime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ctime"` // 创建时间
|
||||||
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` // 更新时间
|
Utime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"utime"` // 更新时间
|
||||||
Ltime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"ltime"` // 上次被使用的时间
|
Ltime *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"ltime"` // 上次被使用的时间
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (a *FsAddressModel) CreateOne(ctx context.Context, address *FsAddress) (res
|
||||||
Country: address.Country,
|
Country: address.Country,
|
||||||
ZipCode: address.ZipCode,
|
ZipCode: address.ZipCode,
|
||||||
Status: address.Status,
|
Status: address.Status,
|
||||||
IsDefault: address.IsDefault,
|
|
||||||
Ctime: &now,
|
Ctime: &now,
|
||||||
Utime: &now,
|
Utime: &now,
|
||||||
Ltime: &now,
|
Ltime: &now,
|
||||||
|
|
|
@ -46,7 +46,6 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
|
||||||
if req.Id == 0 {
|
if req.Id == 0 {
|
||||||
var (
|
var (
|
||||||
country string = "USA" // 国家默认为美国
|
country string = "USA" // 国家默认为美国
|
||||||
isDefautl int64 = 1 // 默认地址为1
|
|
||||||
)
|
)
|
||||||
createOne := &gmodel.FsAddress{ // 构建FsAddress结构体
|
createOne := &gmodel.FsAddress{ // 构建FsAddress结构体
|
||||||
FirstName: &req.FirstName,
|
FirstName: &req.FirstName,
|
||||||
|
@ -60,7 +59,6 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
|
||||||
Status: &status,
|
Status: &status,
|
||||||
UserId: &userinfo.UserId,
|
UserId: &userinfo.UserId,
|
||||||
ZipCode: &req.ZipCode,
|
ZipCode: &req.ZipCode,
|
||||||
IsDefault: &isDefautl,
|
|
||||||
}
|
}
|
||||||
created, err := m.CreateOne(l.ctx, createOne) // 新增地址
|
created, err := m.CreateOne(l.ctx, createOne) // 新增地址
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -82,7 +80,6 @@ func (l *UserAddAddressLogic) UserAddAddress(req *types.RequestAddAddress, useri
|
||||||
Status: &status,
|
Status: &status,
|
||||||
UserId: &userinfo.UserId,
|
UserId: &userinfo.UserId,
|
||||||
ZipCode: &req.ZipCode,
|
ZipCode: &req.ZipCode,
|
||||||
IsDefault: &req.IsDefault,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插入数据库 更新地址
|
// 插入数据库 更新地址
|
||||||
|
|
|
@ -50,7 +50,6 @@ func (l *AddressAddLogic) AddressAdd(req *types.AddressRequest, userinfo *auth.U
|
||||||
|
|
||||||
var (
|
var (
|
||||||
country string = "USA" // 国家默认为美国
|
country string = "USA" // 国家默认为美国
|
||||||
isDefautl int64 = 1 // 默认地址为1
|
|
||||||
status int64 = 1 // 默认地址状态为1(正常)
|
status int64 = 1 // 默认地址状态为1(正常)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -66,7 +65,6 @@ func (l *AddressAddLogic) AddressAdd(req *types.AddressRequest, userinfo *auth.U
|
||||||
Status: &status,
|
Status: &status,
|
||||||
UserId: &userinfo.UserId,
|
UserId: &userinfo.UserId,
|
||||||
ZipCode: &req.ZipCode,
|
ZipCode: &req.ZipCode,
|
||||||
IsDefault: &isDefautl,
|
|
||||||
}
|
}
|
||||||
address, err := m.CreateOne(l.ctx, createOne) // 新增地址
|
address, err := m.CreateOne(l.ctx, createOne) // 新增地址
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -85,6 +83,7 @@ func (l *AddressAddLogic) AddressAdd(req *types.AddressRequest, userinfo *auth.U
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK, map[string]any{
|
return resp.SetStatus(basic.CodeOK, map[string]any{
|
||||||
|
"address_id": address.AddressId,
|
||||||
"address_list": addresses,
|
"address_list": addresses,
|
||||||
}) // 返回成功并返回地址ID
|
}) // 返回成功并返回地址ID
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,9 @@ func (l *AddressDeleteLogic) AddressDelete(req *types.AddressIdRequest, userinfo
|
||||||
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
return resp.SetStatusWithMessage(basic.CodeApiErr, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK)
|
return resp.SetStatus(basic.CodeOK, map[string]any{
|
||||||
|
"address_id": req.AddressId,
|
||||||
|
}) // 返回成功并返回地址ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||||||
|
|
|
@ -49,7 +49,6 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
|
||||||
address := gmodel.FsAddress{
|
address := gmodel.FsAddress{
|
||||||
AddressId: req.AddressId,
|
AddressId: req.AddressId,
|
||||||
UserId: &userinfo.UserId,
|
UserId: &userinfo.UserId,
|
||||||
IsDefault: &req.IsDefault,
|
|
||||||
FirstName: &req.FirstName,
|
FirstName: &req.FirstName,
|
||||||
LastName: &req.LastName,
|
LastName: &req.LastName,
|
||||||
Mobile: &req.Mobile,
|
Mobile: &req.Mobile,
|
||||||
|
@ -73,6 +72,7 @@ func (l *AddressUpdateLogic) AddressUpdate(req *types.AddressRequest, userinfo *
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.SetStatus(basic.CodeOK, map[string]any{
|
return resp.SetStatus(basic.CodeOK, map[string]any{
|
||||||
|
"address_id": req.AddressId,
|
||||||
"address_list": addresses,
|
"address_list": addresses,
|
||||||
}) // 返回成功并返回地址ID
|
}) // 返回成功并返回地址ID
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user