Commit dc465373 authored by hujiebin's avatar hujiebin

feat

parent 70fb5d05
......@@ -14,12 +14,13 @@ import (
)
type CvHeadwear struct {
Id uint64 `json:"id"`
Using bool `json:"using"`
PicUrl mysql.Str `json:"picUrl"`
EffectUrl mysql.Str `json:"effectUrl"`
TimeLeft int64 `json:"timeLeft"` // 离到期还有多少秒(过期则是负数)
HeadwearIcon string `json:"headwearIcon"`
Id uint64 `json:"id"`
Using bool `json:"using"`
PicUrl mysql.Str `json:"picUrl"`
EffectUrl mysql.Str `json:"effectUrl"`
ReverseEffectUrl mysql.Str `json:"reverseEffectUrl"`
TimeLeft int64 `json:"timeLeft"` // 离到期还有多少秒(过期则是负数)
HeadwearIcon string `json:"headwearIcon"`
}
type CvHeadwearDiamond struct {
......@@ -61,11 +62,12 @@ func GetHeadwearList(db *gorm.DB, userId uint64) ([]CvHeadwear, error) {
// TODO: 没过期并且有设置using的,才算是,因为写入方不维护using状态的更新
isUsing := i.Using == headwear_e.YesUsing && i.EndTime.After(now)
result = append(result, CvHeadwear{
Id: i.HeadwearId,
PicUrl: resHwMap[i.HeadwearId].PicUrl,
EffectUrl: resHwMap[i.HeadwearId].EffectUrl,
Using: isUsing,
TimeLeft: i.EndTime.Unix() - now.Unix(),
Id: i.HeadwearId,
PicUrl: resHwMap[i.HeadwearId].PicUrl,
EffectUrl: resHwMap[i.HeadwearId].EffectUrl,
ReverseEffectUrl: resHwMap[i.HeadwearId].ReverseEffectUrl,
Using: isUsing,
TimeLeft: i.EndTime.Unix() - now.Unix(),
})
if isUsing {
hasUsing = true
......@@ -100,10 +102,11 @@ func GetCvHeadwear(userId uint64) (*CvHeadwear, error) {
return nil, myerr.WrapErr(err)
}
return &CvHeadwear{
Id: userHeadwear.HeadwearId,
PicUrl: resHeadwear.PicUrl,
EffectUrl: resHeadwear.EffectUrl,
Using: userHeadwear.Using == headwear_e.YesUsing,
Id: userHeadwear.HeadwearId,
PicUrl: resHeadwear.PicUrl,
EffectUrl: resHeadwear.EffectUrl,
ReverseEffectUrl: resHeadwear.ReverseEffectUrl,
Using: userHeadwear.Using == headwear_e.YesUsing,
}, nil
}
......@@ -159,11 +162,12 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
headwear, flag := resHeadwearMap[r.HeadwearId]
if flag {
result[r.UserId] = CvHeadwear{
Id: headwear.ID,
PicUrl: headwear.PicUrl,
EffectUrl: headwear.EffectUrl,
Using: r.Using == headwear_e.YesUsing,
HeadwearIcon: response[r.UserId],
Id: headwear.ID,
PicUrl: headwear.PicUrl,
EffectUrl: headwear.EffectUrl,
ReverseEffectUrl: headwear.ReverseEffectUrl,
Using: r.Using == headwear_e.YesUsing,
HeadwearIcon: response[r.UserId],
}
}
......
......@@ -9,10 +9,11 @@ import (
type ResHeadwear struct {
mysql.Entity
*domain.Model `gorm:"-"`
Name mysql.Str
PicUrl mysql.Str
EffectUrl mysql.Str
*domain.Model `gorm:"-"`
Name mysql.Str
PicUrl mysql.Str
EffectUrl mysql.Str
ReverseEffectUrl mysql.Str
}
//矛盾,项目负责人(产品不接受 商品 同上架分开两个数据结构的模式),又在页面上要求头饰同价格在一起展示,修改。
......@@ -134,4 +135,4 @@ func GetResHeadwearMap(db *gorm.DB) (map[uint64]ResHeadwear, error) {
result[i.ID] = i
}
return result, nil
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment