Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-10-08 12:04:08 +08:00
commit 98967990e7
2 changed files with 15 additions and 7 deletions

View File

@ -14,18 +14,26 @@ func (a *FsAddressModel) GetOne(ctx context.Context, addressId int64, userId int
}
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
var dbresp []*FsAddress
err = a.db.WithContext(ctx).Model(&FsAddress{}).Where("`user_id` = ? and `status` = 1", userId).Order("`ltime` DESC").Find(&dbresp).Error
if err != nil {
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
for _, r := range dbresp {
rd := &FsAddressWithDefault{
FsAddress: r,
}
if r.Ltime.UTC().Unix() > now {
rd.IsDefault = 1
} else {
rd.IsDefault = 0
}
resp = append(resp, rd)
}
return

View File

@ -65,6 +65,6 @@ type UserProfileBase struct {
}
type FsAddressWithDefault struct {
FsAddress
*FsAddress
IsDefault int64 `json:"is_default"`
}