feat:完善项目信息
This commit is contained in:
@ -13,7 +13,7 @@ type ServiceSolutionCase struct {
|
||||
// ServiceSolutionCaseInfo 解决方案案例信息
|
||||
type ServiceSolutionCaseInfo struct {
|
||||
model.Model
|
||||
Kind model.ServiceSolutionCaseKind `json:"kind"`
|
||||
Mode model.ServiceSolutionCaseMode `json:"mode"`
|
||||
Title string `json:"title"`
|
||||
model.Image
|
||||
DetailID uint64 `json:"detail_id"`
|
||||
@ -23,19 +23,37 @@ type ServiceSolutionCaseInfo struct {
|
||||
}
|
||||
|
||||
// SolutionCase 解决方案案例信息
|
||||
func (m *ServiceSolutionCase) SolutionCase(limit int) ([]*ServiceSolutionCaseInfo, error) {
|
||||
mServiceSolutionCaseDetail := model.NewServiceSolutionCaseDetail()
|
||||
func (m *ServiceSolutionCase) SolutionCase(limit int, where ...*model.ModelWhere) ([]*ServiceSolutionCaseInfo, error) {
|
||||
//mServiceSolutionCaseKind := model.NewServiceSolutionCaseKind()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS s").
|
||||
Select("s.id", "s.kind", "s.image",
|
||||
// db := orm.GetDB().Table(m.TableName()+" AS s").
|
||||
// Select("s.id", "s.mode", "s.image",
|
||||
// "d.id AS detail_id", "d.title AS detail_title", "d.image AS detail_image", "d.description AS detail_description").
|
||||
// Joins(fmt.Sprintf(`INNER JOIN (SELECT id, solution_case_id, title, image, description FROM %s AS a WHERE
|
||||
//(SELECT count( b.id ) FROM %s AS b WHERE a.solution_case_id = b.solution_case_id AND a.id < b.id AND b.is_deleted = %d) < %d
|
||||
//AND a.is_deleted = %d ORDER BY a.sort DESC, a.id DESC) AS d ON s.id = d.solution_case_id`,
|
||||
// mServiceSolutionCaseKind.TableName(), mServiceSolutionCaseKind.TableName(), model.DeleteStatusForNot, limit, model.DeleteStatusForNot)).
|
||||
// Where("s.is_deleted = ?", model.DeleteStatusForNot).
|
||||
// Order("s.sort " + model.OrderModeToDesc)
|
||||
|
||||
db := orm.GetDB().Table(model.NewServiceSolutionCaseKind().TableName()+" AS k").
|
||||
Select("k.id AS id", "k.mode", "k.image AS image",
|
||||
"d.id AS detail_id", "d.title AS detail_title", "d.image AS detail_image", "d.description AS detail_description").
|
||||
Joins(fmt.Sprintf(`INNER JOIN (SELECT id, solution_case_id, title, image, description FROM %s AS a WHERE
|
||||
(SELECT count( b.id ) FROM %s AS b WHERE a.solution_case_id = b.solution_case_id AND a.id < b.id AND b.is_deleted = %d) < %d
|
||||
AND a.is_deleted = %d ORDER BY a.sort DESC, a.id DESC) AS d ON s.id = d.solution_case_id`,
|
||||
mServiceSolutionCaseDetail.TableName(), mServiceSolutionCaseDetail.TableName(), model.DeleteStatusForNot, limit, model.DeleteStatusForNot)).
|
||||
Where("s.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("s.sort " + model.OrderModeToDesc)
|
||||
Joins(fmt.Sprintf(`LEFT JOIN (SELECT id, kind_id, title, image, description, sort FROM %s AS a WHERE
|
||||
(SELECT count( b.id ) FROM %s AS b WHERE a.kind_id = b.kind_id AND a.id < b.id AND b.is_deleted = %d) < %d
|
||||
AND a.is_deleted = %d ORDER BY a.sort ASC, a.id DESC) AS d ON k.id = d.kind_id`,
|
||||
m.TableName(), m.TableName(), model.DeleteStatusForNot, limit, model.DeleteStatusForNot)).
|
||||
Where("k.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("k.mode " + model.OrderModeToAsc).
|
||||
Order("k.sort " + model.OrderModeToAsc).
|
||||
Order("k.id " + model.OrderModeToDesc).
|
||||
Order("d.sort " + model.OrderModeToAsc)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, v := range where {
|
||||
db = db.Where(v.Condition, v.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ServiceSolutionCaseInfo, 0)
|
||||
|
||||
err := db.Scan(&out).Error
|
||||
|
@ -1,11 +0,0 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ServiceSolutionCaseDetail struct {
|
||||
*model.ServiceSolutionCaseDetail
|
||||
}
|
||||
|
||||
func NewServiceSolutionCaseDetail() *ServiceSolutionCaseDetail {
|
||||
return &ServiceSolutionCaseDetail{model.NewServiceSolutionCaseDetail()}
|
||||
}
|
11
app/api/website/model/service_solution_case_kind.go
Normal file
11
app/api/website/model/service_solution_case_kind.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ServiceSolutionCaseKind struct {
|
||||
*model.ServiceSolutionCaseKind
|
||||
}
|
||||
|
||||
func NewServiceSolutionCaseKind() *ServiceSolutionCaseKind {
|
||||
return &ServiceSolutionCaseKind{model.NewServiceSolutionCaseKind()}
|
||||
}
|
Reference in New Issue
Block a user