feat:完善网站信息,增加案例解决方案数据管理
This commit is contained in:
48
app/api/website/model/service_solution_case.go
Normal file
48
app/api/website/model/service_solution_case.go
Normal file
@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ServiceSolutionCase struct {
|
||||
*model.ServiceSolutionCase
|
||||
}
|
||||
|
||||
// ServiceSolutionCaseInfo 解决方案案例信息
|
||||
type ServiceSolutionCaseInfo struct {
|
||||
model.Model
|
||||
Kind model.ServiceSolutionCaseKind `json:"kind"`
|
||||
Title string `json:"title"`
|
||||
model.Image
|
||||
DetailID uint64 `json:"detail_id"`
|
||||
DetailTitle string `json:"detail_title"`
|
||||
DetailImage string `json:"detail_image"`
|
||||
DetailDescription string `json:"detail_description"`
|
||||
}
|
||||
|
||||
// SolutionCase 解决方案案例信息
|
||||
func (m *ServiceSolutionCase) SolutionCase(limit int) ([]*ServiceSolutionCaseInfo, error) {
|
||||
mServiceSolutionCaseDetail := model.NewServiceSolutionCaseDetail()
|
||||
|
||||
db := orm.GetDB().Table(m.TableName()+" AS s").
|
||||
Select("s.id", "s.kind", "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`,
|
||||
mServiceSolutionCaseDetail.TableName(), mServiceSolutionCaseDetail.TableName(), model.DeleteStatusForNot, limit, model.DeleteStatusForNot)).
|
||||
Where("s.is_deleted = ?", model.DeleteStatusForNot).
|
||||
Order("s.sort " + model.OrderModeToDesc)
|
||||
|
||||
out := make([]*ServiceSolutionCaseInfo, 0)
|
||||
|
||||
err := db.Scan(&out).Error
|
||||
|
||||
return out, err
|
||||
}
|
||||
|
||||
func NewServiceSolutionCase() *ServiceSolutionCase {
|
||||
return &ServiceSolutionCase{model.NewServiceSolutionCase()}
|
||||
}
|
11
app/api/website/model/service_solution_case_detail.go
Normal file
11
app/api/website/model/service_solution_case_detail.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type ServiceSolutionCaseDetail struct {
|
||||
*model.ServiceSolutionCaseDetail
|
||||
}
|
||||
|
||||
func NewServiceSolutionCaseDetail() *ServiceSolutionCaseDetail {
|
||||
return &ServiceSolutionCaseDetail{model.NewServiceSolutionCaseDetail()}
|
||||
}
|
11
app/api/website/model/sys_banner.go
Normal file
11
app/api/website/model/sys_banner.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type SysBanner struct {
|
||||
*model.SysBanner
|
||||
}
|
||||
|
||||
func NewSysBanner() *SysBanner {
|
||||
return &SysBanner{model.NewSysBanner()}
|
||||
}
|
Reference in New Issue
Block a user