|
@@ -22,6 +22,7 @@ type BiZhiCollection struct {
|
|
|
CreateTime string `gorm:"column:create_time;type:datetime" json:"create_time"` // 插入时间
|
|
|
UpdateTime string `gorm:"column:update_time;type:datetime" json:"update_time"` // 更新时间
|
|
|
BiZhiId int `gorm:"column:bizhi_id;type:bigint(20)" json:"biZhiId"`
|
|
|
+ UrlSize string `json:"urlSize"` //缩略图
|
|
|
}
|
|
|
|
|
|
func (m *BiZhi) TableName() string {
|
|
@@ -101,25 +102,34 @@ func (o *BiZhi) BiZhiGroup(label string, openid string) ([]BiZhiCollection, erro
|
|
|
var doc []BiZhiCollection
|
|
|
var data []BiZhiCollection
|
|
|
var bizhi BiZhiCollection
|
|
|
- table := orm.BzMysql.Table("bizhi b ").Where("label = ?", label)
|
|
|
|
|
|
- if err := table.Select("b.*,(SELECT bizhi_id FROM collection WHERE bizhi_id = b.id and open_id = ?) as bizhi_id", openid).Order("id desc").Limit(30).Find(&doc).Error; err != nil {
|
|
|
+ err := orm.BzMysql.Table("bizhi b").Where("b.id = ?", o.ID).Select("b.*,(SELECT bizhi_id FROM collection WHERE bizhi_id = b.id and open_id = ?) as bizhi_id", openid).Order("id desc").Find(&bizhi).Error
|
|
|
+ if err != nil {
|
|
|
return doc, err
|
|
|
}
|
|
|
+ table := orm.BzMysql.Table("bizhi b ").Where("label = ?", label)
|
|
|
|
|
|
- for i := 0; i < len(doc); i++ {
|
|
|
- if doc[i].ID == o.ID {
|
|
|
- bizhi.Url = doc[i].Url
|
|
|
- bizhi.ID = doc[i].ID
|
|
|
- bizhi.Label = doc[i].Label
|
|
|
- bizhi.BiZhiId = doc[i].BiZhiId
|
|
|
- }
|
|
|
+ if err := table.Select("b.*,(SELECT bizhi_id FROM collection WHERE bizhi_id = b.id and open_id = ?) as bizhi_id", openid).Order("id desc").Limit(10).Find(&doc).Error; err != nil {
|
|
|
+ return doc, err
|
|
|
}
|
|
|
+
|
|
|
+ //for i := 0; i < len(doc); i++ {
|
|
|
+ // if doc[i].ID == o.ID {
|
|
|
+ // bizhi.Url = doc[i].Url
|
|
|
+ // bizhi.ID = doc[i].ID
|
|
|
+ // bizhi.Label = doc[i].Label
|
|
|
+ // bizhi.BiZhiId = doc[i].BiZhiId
|
|
|
+ // bizhi.UrlSize = bizhi.Url + "?imageView2/2"
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ bizhi.UrlSize = bizhi.Url + "?imageView2/2"
|
|
|
data = append(data, bizhi)
|
|
|
for i := 0; i < len(doc); i++ {
|
|
|
if doc[i].ID == o.ID {
|
|
|
continue
|
|
|
} else {
|
|
|
+ doc[i].UrlSize = doc[i].Url + "?imageView2/2"
|
|
|
data = append(data, doc[i])
|
|
|
}
|
|
|
|