info address default
This commit is contained in:
parent
f8c8c634cb
commit
bfeacad5f0
|
@ -13,11 +13,21 @@ func (a *FsAddressModel) GetOne(ctx context.Context, addressId int64, userId int
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []FsAddress, err error) {
|
func (a *FsAddressModel) GetUserAllAddress(ctx context.Context, userId int64) (resp []*FsAddressWithDefault, err error) {
|
||||||
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = 1", userId).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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now := time.Now().UTC().AddDate(10, 0, 0).Unix()
|
||||||
|
for _, r := range resp {
|
||||||
|
if r.Ltime.UTC().Unix() > now {
|
||||||
|
r.IsDefault = 1
|
||||||
|
} else {
|
||||||
|
r.IsDefault = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,3 +63,8 @@ type UserProfileBase struct {
|
||||||
Resetaurant string `json:"resetaurant"` // 不知道干什么
|
Resetaurant string `json:"resetaurant"` // 不知道干什么
|
||||||
Company string `json:"company"` // 公司
|
Company string `json:"company"` // 公司
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FsAddressWithDefault struct {
|
||||||
|
FsAddress
|
||||||
|
IsDefault int64 `json:"is_default"`
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user