feat:完善项目信息
This commit is contained in:
@ -35,7 +35,7 @@ type (
|
|||||||
// ProductVisitInfo 产品浏览信息
|
// ProductVisitInfo 产品浏览信息
|
||||||
ProductVisitInfo struct {
|
ProductVisitInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model.TechnologyProductVisitInfo
|
*model.ProductVisitInfo
|
||||||
CompanyID string `json:"company_id"`
|
CompanyID string `json:"company_id"`
|
||||||
CompanyKeywords []string `json:"company_keywords"`
|
CompanyKeywords []string `json:"company_keywords"`
|
||||||
}
|
}
|
||||||
@ -116,14 +116,14 @@ func (c *Product) Match(id uint64) {
|
|||||||
|
|
||||||
// Visit 访问信息
|
// Visit 访问信息
|
||||||
func (c *Product) Visit(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
func (c *Product) Visit(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||||
mTechnologyProductVisit := model.NewTechnologyProductVisit()
|
mUserVisit := model.NewUserVisit()
|
||||||
|
|
||||||
where := []*model2.ModelWhere{
|
where := []*model2.ModelWhere{
|
||||||
model2.NewWhere("product_id", id),
|
model2.NewWhere("product_id", id),
|
||||||
}
|
}
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
out, err := mTechnologyProductVisit.Visit(page, pageSize, &count, where...)
|
out, err := mUserVisit.Product(page, pageSize, &count, where...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -138,10 +138,10 @@ func (c *Product) Visit(id uint64, page, pageSize int) (*controller.ReturnPages,
|
|||||||
v.CompanyImage = mManageCompany.Image.Analysis(config2.SettingInfo.Domain)
|
v.CompanyImage = mManageCompany.Image.Analysis(config2.SettingInfo.Domain)
|
||||||
|
|
||||||
list = append(list, &ProductVisitInfo{
|
list = append(list, &ProductVisitInfo{
|
||||||
ID: v.GetEncodeID(),
|
ID: v.GetEncodeID(),
|
||||||
TechnologyProductVisitInfo: v,
|
ProductVisitInfo: v,
|
||||||
CompanyID: (&model2.Model{ID: v.CompanyID}).GetEncodeID(),
|
CompanyID: (&model2.Model{ID: v.CompanyID}).GetEncodeID(),
|
||||||
CompanyKeywords: mManageCompany.GetKeywordAttribute(),
|
CompanyKeywords: mManageCompany.GetKeywordAttribute(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
|
@ -64,8 +64,8 @@ func (m *ManageExpert) CompanyVisit(page, pageSize int, count *int64, where ...*
|
|||||||
db := orm.GetDB().Table(m.TableName()+" e").
|
db := orm.GetDB().Table(m.TableName()+" e").
|
||||||
Select("e.id", "e.name", "e.mobile", "e.industry", "v.count AS visit_count", "v.date AS visit_at",
|
Select("e.id", "e.name", "e.mobile", "e.industry", "v.count AS visit_count", "v.date AS visit_at",
|
||||||
"c.name AS company_name").
|
"c.name AS company_name").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS v ON e.id = v.expert_id AND v.is_deleted = %d",
|
Joins(fmt.Sprintf("LEFT JOIN %s AS v ON e.id = v.object_id AND v.kind = %d AND v.is_deleted = %d",
|
||||||
model.NewManageExpertVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserVisitKindForCompany, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u_c ON v.uid = u_c.uid AND u_c.invalid_status = %d",
|
Joins(fmt.Sprintf("LEFT JOIN %s AS u_c ON v.uid = u_c.uid AND u_c.invalid_status = %d",
|
||||||
model.NewUserCompany().TableName(), model.InvalidStatusForNot)).
|
model.NewUserCompany().TableName(), model.InvalidStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u_c.company_id = c.id", model.NewManageCompany().TableName())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u_c.company_id = c.id", model.NewManageCompany().TableName())).
|
||||||
|
@ -28,10 +28,10 @@ func (m *ManageLaboratory) Laboratory(page, pageSize int, count *int64, where ..
|
|||||||
Select("l.id", "l.name", "l.industry", "u.name AS username", "u.mobile", "v.count AS visit_count",
|
Select("l.id", "l.name", "l.industry", "u.name AS username", "u.mobile", "v.count AS visit_count",
|
||||||
"c.count AS collect_count", "l.examine_at AS settled_at").
|
"c.count AS collect_count", "l.examine_at AS settled_at").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON l.uid = u.uuid", model.NewUserInstance().TableName())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS u ON l.uid = u.uuid", model.NewUserInstance().TableName())).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY laboratory_id) AS v ON l.id = v.laboratory_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON l.id = v.object_id",
|
||||||
model.NewManageLaboratoryVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserCollectKindForLaboratory, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT laboratory_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY laboratory_id) AS c ON l.id = c.laboratory_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON l.id = c.object_id",
|
||||||
model.NewManageLaboratoryCollect().TableName(), model.DeleteStatusForNot))
|
model.NewUserCollect().TableName(), model.UserCollectKindForLaboratory, model.DeleteStatusForNot))
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
for _, v := range where {
|
for _, v := range where {
|
||||||
|
@ -24,8 +24,8 @@ type TechnologyAchievementInfo struct {
|
|||||||
func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyAchievementInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||||
Select("a.id", "a.title", "a.industry", "v.count AS visit_count", "a.shelf_status", "a.created_at").
|
Select("a.id", "a.title", "a.industry", "v.count AS visit_count", "a.shelf_status", "a.created_at").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d) AS v ON a.id = v.achievement_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON a.id = v.object_id",
|
||||||
model.NewTechnologyAchievementVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
|
@ -30,10 +30,10 @@ func (m *TechnologyProduct) Product(page, pageSize int, count *int64, where ...*
|
|||||||
db := orm.GetDB().Table(m.TableName()+" AS p").
|
db := orm.GetDB().Table(m.TableName()+" AS p").
|
||||||
Select("p.id", "p.title", "p.image", "p.maturity", "p.industry", "p.cooperation_mode", "p.keyword",
|
Select("p.id", "p.title", "p.image", "p.maturity", "p.industry", "p.cooperation_mode", "p.keyword",
|
||||||
"v.count AS v visit_count", "c.count AS collect_count").
|
"v.count AS v visit_count", "c.count AS collect_count").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS v ON p.id = v.product_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON p.id = v.object_id",
|
||||||
model.NewTechnologyProductVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserVisitKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS c ON p.id = c.product_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON p.id = c.object_id",
|
||||||
model.NewTechnologyProductCollect().TableName(), model.DeleteStatusForNot))
|
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyProduct, model.DeleteStatusForNot))
|
||||||
|
|
||||||
out := make([]*TechnologyProductInfo, 0)
|
out := make([]*TechnologyProductInfo, 0)
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
|
||||||
|
|
||||||
type TechnologyProductCollect struct {
|
|
||||||
*model.TechnologyProductCollect
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyProductCollect() *TechnologyProductCollect {
|
|
||||||
return &TechnologyProductCollect{model.NewTechnologyProductCollect()}
|
|
||||||
}
|
|
11
app/api/enterprise/model/user_collect.go
Normal file
11
app/api/enterprise/model/user_collect.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type UserCollect struct {
|
||||||
|
*model.UserCollect
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserCollect() *UserCollect {
|
||||||
|
return &UserCollect{model.NewUserCollect()}
|
||||||
|
}
|
@ -7,17 +7,19 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TechnologyProductVisit struct {
|
type UserVisit struct {
|
||||||
*model.TechnologyProductVisit
|
*model.UserVisit
|
||||||
}
|
}
|
||||||
|
|
||||||
type TechnologyProductVisitInfo struct {
|
type (
|
||||||
model.Model
|
ProductVisitInfo struct {
|
||||||
VisitAt time.Time `json:"visit_at"`
|
model.Model
|
||||||
model.ManageCompanyBasic
|
VisitAt time.Time `json:"visit_at"`
|
||||||
}
|
model.ManageCompanyBasic
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyProductVisitInfo, error) {
|
func (m *UserVisit) Product(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ProductVisitInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS v").
|
db := orm.GetDB().Table(m.TableName()+" AS v").
|
||||||
Select("v.id", "v.visit_at", "c.id AS company_id", "c.name AS company_name", "c.image AS company_image",
|
Select("v.id", "v.visit_at", "c.id AS company_id", "c.name AS company_name", "c.image AS company_image",
|
||||||
"c.kind AS company_kind", "c.url AS company_url").
|
"c.kind AS company_kind", "c.url AS company_url").
|
||||||
@ -25,9 +27,10 @@ func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where .
|
|||||||
model.NewUserCompany().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
model.NewUserCompany().TableName(), model.InvalidStatusForNot, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u_c.company_id = c.id", model.NewManageCompany().TableName())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS c ON u_c.company_id = c.id", model.NewManageCompany().TableName())).
|
||||||
Where("v.is_deleted = ?", model.DeleteStatusForNot).
|
Where("v.is_deleted = ?", model.DeleteStatusForNot).
|
||||||
|
Where("v.kind = ?", model.UserVisitKindForTechnologyProduct).
|
||||||
Where("u_c.id > ?", 0)
|
Where("u_c.id > ?", 0)
|
||||||
|
|
||||||
out := make([]*TechnologyProductVisitInfo, 0)
|
out := make([]*ProductVisitInfo, 0)
|
||||||
|
|
||||||
if len(where) > 0 {
|
if len(where) > 0 {
|
||||||
for _, v := range where {
|
for _, v := range where {
|
||||||
@ -43,6 +46,6 @@ func (m *TechnologyProductVisit) Visit(page, pageSize int, count *int64, where .
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTechnologyProductVisit() *TechnologyProductVisit {
|
func NewUserVisit() *UserVisit {
|
||||||
return &TechnologyProductVisit{model.NewTechnologyProductVisit()}
|
return &UserVisit{model.NewUserVisit()}
|
||||||
}
|
}
|
@ -9,8 +9,6 @@ import (
|
|||||||
"SciencesServer/config"
|
"SciencesServer/config"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"gorm.io/gorm"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Achievement 技术成果
|
// Achievement 技术成果
|
||||||
@ -91,16 +89,19 @@ func (c *Achievement) Detail(id uint64) (*AchievementDetailInfo, error) {
|
|||||||
} else if out.ID <= 0 {
|
} else if out.ID <= 0 {
|
||||||
return nil, errors.New("操作错误,成果信息不存在或已被删除")
|
return nil, errors.New("操作错误,成果信息不存在或已被删除")
|
||||||
}
|
}
|
||||||
var uid uint64 = 0
|
//var uid uint64 = 0
|
||||||
|
|
||||||
if c.Enterprise != nil {
|
if c.Enterprise != nil {
|
||||||
uid = c.UID
|
//uid = c.UID
|
||||||
}
|
}
|
||||||
mTechnologyAchievementCollect := model.NewTechnologyAchievementCollect()
|
// TODO:缺少错误
|
||||||
|
//mUserCollect := model.NewUserCollect()
|
||||||
_ = model2.UpdatesWhere(mTechnologyAchievementCollect.TechnologyAchievementCollect, map[string]interface{}{
|
//
|
||||||
"count": gorm.Expr("count + ?", 1), "updated_at": time.Now(),
|
//_ = model2.UpdatesWhere(mUserCollect.UserCollect, map[string]interface{}{
|
||||||
}, []*model2.ModelWhere{model2.NewWhere("uid", uid), model2.NewWhere("achievement_id", id)})
|
// "count": gorm.Expr("count + ?", 1), "updated_at": time.Now(),
|
||||||
|
//}, []*model2.ModelWhere{model2.NewWhere("uid", uid),
|
||||||
|
// model2.NewWhere("kind", model2.UserCollectKindForTechnologyAchievement),
|
||||||
|
// model2.NewWhere("achievement_id", id)})
|
||||||
|
|
||||||
return &AchievementDetailInfo{
|
return &AchievementDetailInfo{
|
||||||
AchievementInfo: AchievementInfo{
|
AchievementInfo: AchievementInfo{
|
||||||
|
@ -20,19 +20,19 @@ type ManageCompanyProduct struct {
|
|||||||
|
|
||||||
// Product 产品信息
|
// Product 产品信息
|
||||||
func (m *ManageCompany) Product(id, uid uint64, page, pageSize int, count *int64) ([]*ManageCompanyProduct, error) {
|
func (m *ManageCompany) Product(id, uid uint64, page, pageSize int, count *int64) ([]*ManageCompanyProduct, error) {
|
||||||
mTechnologyProductCollect := model.NewTechnologyProductCollect()
|
mNewUserCollect := model.NewUserCollect()
|
||||||
|
|
||||||
db := orm.GetDB().Table(model.NewUserCompany().TableName()+" u_c").
|
db := orm.GetDB().Table(model.NewUserCompany().TableName()+" u_c").
|
||||||
Select("p.id", "p.title", "p.image", "p.industry", "p.maturity", "p.lead_standard", "p.cooperation_mode",
|
Select("p.id", "p.title", "p.image", "p.industry", "p.maturity", "p.lead_standard", "p.cooperation_mode",
|
||||||
"p.keyword", "v.count AS visit_count", "IFNULL(c_u.id, 0) AS is_collect", "c.count AS collect_count").
|
"p.keyword", "v.count AS visit_count", "IFNULL(c_u.id, 0) AS is_collect", "c.count AS collect_count").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_c.uid = p.uid AND p.shelf_status = %d AND p.status = %d AND p.is_deleted = %d",
|
Joins(fmt.Sprintf("LEFT JOIN %s AS p ON u_c.uid = p.uid AND p.shelf_status = %d AND p.status = %d AND p.is_deleted = %d",
|
||||||
model.NewTechnologyProduct().TableName(), model.ShelfStatusForUp, model.TechnologyProductStatusForAgree, model.DeleteStatusForNot)).
|
model.NewTechnologyProduct().TableName(), model.ShelfStatusForUp, model.TechnologyProductStatusForAgree, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS v ON p.id = v.product_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON p.id = v.object_id",
|
||||||
model.NewTechnologyProductVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserVisitKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT product_id, COUNT(count) AS count FROM %s WHERE is_deleted = %d GROUP BY product_id) AS c ON p.id = c.product_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON p.id = c.object_id",
|
||||||
mTechnologyProductCollect.TableName(), model.DeleteStatusForNot)).
|
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS c_u ON p.id = c_u.product_id AND c_u.uid = %d AND c_u.is_deleted = %d",
|
Joins(fmt.Sprintf("LEFT JOIN %s AS c_u ON p.id = c_u.product_id AND c_u.uid = %d AND c_u.kind = %d AND c_u.is_deleted = %d",
|
||||||
mTechnologyProductCollect.TableName(), uid, model.DeleteStatusForNot)).
|
mNewUserCollect.TableName(), uid, model.UserCollectKindForTechnologyProduct, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("")).
|
Joins(fmt.Sprintf("")).
|
||||||
Where("u_c.company_id = ?", id).
|
Where("u_c.company_id = ?", id).
|
||||||
Where("u_c.invalid_status = ?", model.InvalidStatusForNot).
|
Where("u_c.invalid_status = ?", model.InvalidStatusForNot).
|
||||||
|
@ -22,10 +22,10 @@ func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, wh
|
|||||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||||
Select("a.id", "a.title", "a.mode", "a.image", "a.charge_info", "a.industry", "a.customer", "a.maturity",
|
Select("a.id", "a.title", "a.mode", "a.image", "a.charge_info", "a.industry", "a.customer", "a.maturity",
|
||||||
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
|
"a.cooperation_mode", "a.keyword", "v.count AS visit_count", "c.count AS collect_count").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS v ON a.id = v.achievement_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON a.id = v.object_id",
|
||||||
model.NewTechnologyAchievementVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, COUNT(id) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS c ON a.id = c.achievement_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON a.id = c.object_id",
|
||||||
model.NewTechnologyAchievementCollect().TableName(), model.DeleteStatusForNot)).
|
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||||
Where("a.status = ?", model.TechnologyAchievementStatusForAgree).
|
Where("a.status = ?", model.TechnologyAchievementStatusForAgree).
|
||||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
@ -49,10 +49,10 @@ func (m *TechnologyAchievement) Achievement(page, pageSize int, count *int64, wh
|
|||||||
func (m *TechnologyAchievement) Detail(id uint64) (*TechnologyAchievementInfo, error) {
|
func (m *TechnologyAchievement) Detail(id uint64) (*TechnologyAchievementInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||||
Select("a.*", "v.count AS visit_count", "c.count AS collect_count").
|
Select("a.*", "v.count AS visit_count", "c.count AS collect_count").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS v ON a.id = v.achievement_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, SUM(count) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS v ON a.id = v.object_id",
|
||||||
model.NewTechnologyAchievementVisit().TableName(), model.DeleteStatusForNot)).
|
model.NewUserVisit().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT achievement_id, SUM(count) AS count FROM %s WHERE is_deleted = %d GROUP BY achievement_id) AS c ON a.id = c.achievement_id",
|
Joins(fmt.Sprintf("LEFT JOIN (SELECT object_id, COUNT(id) AS count FROM %s WHERE kind = %d AND is_deleted = %d GROUP BY object_id) AS c ON a.id = c.object_id",
|
||||||
model.NewTechnologyAchievementCollect().TableName(), model.DeleteStatusForNot)).
|
model.NewUserCollect().TableName(), model.UserCollectKindForTechnologyAchievement, model.DeleteStatusForNot)).
|
||||||
Where("a.id = ?", id)
|
Where("a.id = ?", id)
|
||||||
|
|
||||||
out := new(TechnologyAchievementInfo)
|
out := new(TechnologyAchievementInfo)
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "SciencesServer/app/common/model"
|
|
||||||
|
|
||||||
type TechnologyAchievementCollect struct {
|
|
||||||
*model.TechnologyAchievementCollect
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyAchievementCollect() *TechnologyAchievementCollect {
|
|
||||||
return &TechnologyAchievementCollect{model.NewTechnologyAchievementCollect()}
|
|
||||||
}
|
|
11
app/api/website/model/user_collect.go
Normal file
11
app/api/website/model/user_collect.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type UserCollect struct {
|
||||||
|
*model.UserCollect
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserCollect() *UserCollect {
|
||||||
|
return &UserCollect{model.NewUserCollect()}
|
||||||
|
}
|
@ -1,22 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// ManageExpertVisit 专家浏览记录数据模型
|
|
||||||
type ManageExpertVisit struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
ExpertID uint64 `gorm:"column:expert_id;index:idx_expert_visit_expert;type:int(11);default:0;comment:专家ID" json:"-"`
|
|
||||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
|
||||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ManageExpertVisit) TableName() string {
|
|
||||||
return "manage_expert_visit"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewManageExpertVisit() *ManageExpertVisit {
|
|
||||||
return &ManageExpertVisit{}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
// ManageLaboratoryCollect 实验室收藏数据模型
|
|
||||||
type ManageLaboratoryCollect struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
LaboratoryID uint64 `gorm:"column:laboratory_id;type:int(11);default:0;comment:实验室ID" json:"-"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ManageLaboratoryCollect) TableName() string {
|
|
||||||
return "manage_laboratory_collect"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewManageLaboratoryCollect() *ManageLaboratoryCollect {
|
|
||||||
return &ManageLaboratoryCollect{}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// ManageLaboratoryVisit 实验室浏览记录数据模型
|
|
||||||
type ManageLaboratoryVisit struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
LaboratoryID uint64 `gorm:"column:laboratory_id;index:idx_laboratory_visit_laboratory;type:int(11);default:0;comment:实验室ID" json:"-"`
|
|
||||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
|
||||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *ManageLaboratoryVisit) TableName() string {
|
|
||||||
return "manage_laboratory_visit"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewManageLaboratoryVisit() *ManageLaboratoryVisit {
|
|
||||||
return &ManageLaboratoryVisit{}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
// TechnologyAchievementCollect 科技成果收藏数据模型
|
|
||||||
type TechnologyAchievementCollect struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
AchievementID uint64 `gorm:"column:achievement_id;type:int(11);default:0;comment:科技成果ID" json:"-"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *TechnologyAchievementCollect) TableName() string {
|
|
||||||
return "technology_achievement_collect"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyAchievementCollect() *TechnologyAchievementCollect {
|
|
||||||
return &TechnologyAchievementCollect{}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// TechnologyAchievementVisit 科技成果访问数据模型
|
|
||||||
type TechnologyAchievementVisit struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
AchievementID uint64 `gorm:"column:achievement_id;index:idx_achievement_visit_achievement;type:int(11);default:0;comment:科技成果ID" json:"-"`
|
|
||||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
|
||||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *TechnologyAchievementVisit) TableName() string {
|
|
||||||
return "technology_achievement_visit"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyAchievementVisit() *TechnologyAchievementVisit {
|
|
||||||
return &TechnologyAchievementVisit{}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// TechnologyDemandVisit 技术需求访问数据模型
|
|
||||||
type TechnologyDemandVisit struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
DemandID uint64 `gorm:"column:demand_id;index:idx_demand_visit_demand;type:int(11);default:0;comment:科技产品ID" json:"product_id"`
|
|
||||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
|
||||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *TechnologyDemandVisit) TableName() string {
|
|
||||||
return "technology_demand_visit"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyDemandVisit() *TechnologyDemandVisit {
|
|
||||||
return &TechnologyDemandVisit{}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// TechnologyProductVisit 技术产品访问数据模型
|
|
||||||
type TechnologyProductVisit struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
ProductID uint64 `gorm:"column:product_id;index:idx_product_visit_product;type:int(11);default:0;comment:科技产品ID" json:"product_id"`
|
|
||||||
Count int `gorm:"column:count;type:int(8);default:0;comment:浏览次数" json:"count"`
|
|
||||||
Date time.Time `gorm:"column:date;type:datetime;not null;comment:浏览时间" json:"date"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *TechnologyProductVisit) TableName() string {
|
|
||||||
return "technology_product_visit"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyProductVisit() *TechnologyProductVisit {
|
|
||||||
return &TechnologyProductVisit{}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package model
|
|
||||||
|
|
||||||
// TechnologyProductCollect 产品收藏数据模型
|
|
||||||
type TechnologyProductCollect struct {
|
|
||||||
Model
|
|
||||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
|
||||||
ProductID uint64 `gorm:"column:product_id;type:int(11);default:0;comment:产品ID" json:"-"`
|
|
||||||
ModelDeleted
|
|
||||||
ModelAt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *TechnologyProductCollect) TableName() string {
|
|
||||||
return "technology_product_collect"
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewTechnologyProductCollect() *TechnologyProductCollect {
|
|
||||||
return &TechnologyProductCollect{}
|
|
||||||
}
|
|
@ -17,6 +17,12 @@ const (
|
|||||||
UserCollectKindForLaboratory UserCollectKind = iota + 1
|
UserCollectKindForLaboratory UserCollectKind = iota + 1
|
||||||
// UserCollectKindForExpert 专家
|
// UserCollectKindForExpert 专家
|
||||||
UserCollectKindForExpert
|
UserCollectKindForExpert
|
||||||
|
// UserCollectKindForCompany 公司
|
||||||
|
UserCollectKindForCompany
|
||||||
|
// UserCollectKindForTechnologyAchievement 技术成果
|
||||||
|
UserCollectKindForTechnologyAchievement
|
||||||
|
// UserCollectKindForTechnologyProduct 技术产品
|
||||||
|
UserCollectKindForTechnologyProduct
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *UserCollect) TableName() string {
|
func (m *UserCollect) TableName() string {
|
||||||
|
@ -21,6 +21,12 @@ const (
|
|||||||
UserVisitKindForLaboratory UserCollectKind = iota + 1
|
UserVisitKindForLaboratory UserCollectKind = iota + 1
|
||||||
// UserVisitKindForExpert 专家
|
// UserVisitKindForExpert 专家
|
||||||
UserVisitKindForExpert
|
UserVisitKindForExpert
|
||||||
|
// UserVisitKindForCompany 公司
|
||||||
|
UserVisitKindForCompany
|
||||||
|
// UserVisitKindForTechnologyAchievement 技术成果
|
||||||
|
UserVisitKindForTechnologyAchievement
|
||||||
|
// UserVisitKindForTechnologyProduct 技术产品
|
||||||
|
UserVisitKindForTechnologyProduct
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *UserVisit) TableName() string {
|
func (m *UserVisit) TableName() string {
|
||||||
|
Reference in New Issue
Block a user