feat:完善项目信息
This commit is contained in:
@ -12,10 +12,10 @@ import (
|
||||
// Innovate 创新服务
|
||||
type Innovate struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
tenantID uint64
|
||||
}
|
||||
|
||||
type InnovateHandle func(session *session.Enterprise, local string) *Innovate
|
||||
type InnovateHandle func(session *session.Enterprise, tenantID uint64) *Innovate
|
||||
|
||||
type (
|
||||
// InnovateInfo 创新服务信息
|
||||
@ -39,7 +39,7 @@ type (
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Innovate) Instance(kind int, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
func (c *Innovate) Instance(kind uint64, title string, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceInnovate := model.NewServiceInnovate()
|
||||
|
||||
out := make([]*model2.ServiceInnovate, 0)
|
||||
@ -109,10 +109,10 @@ func (c *Innovate) Detail(id uint64) (*InnovateDetailInfo, error) {
|
||||
}
|
||||
|
||||
func NewInnovate() InnovateHandle {
|
||||
return func(session *session.Enterprise, local string) *Innovate {
|
||||
return func(session *session.Enterprise, tenantID uint64) *Innovate {
|
||||
return &Innovate{
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
tenantID: tenantID,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,17 +14,17 @@ import (
|
||||
// SolutionCase 解决方案案例
|
||||
type SolutionCase struct {
|
||||
*session.Enterprise
|
||||
local string
|
||||
tenantID uint64
|
||||
}
|
||||
|
||||
type SolutionCaseHandle func(session *session.Enterprise, local string) *SolutionCase
|
||||
type SolutionCaseHandle func(session *session.Enterprise, tenantID uint64) *SolutionCase
|
||||
|
||||
type (
|
||||
// SolutionCaseInfo 基本信息
|
||||
SolutionCaseInfo struct {
|
||||
ID string `json:"id"`
|
||||
MarkID uint64 `json:"-"`
|
||||
Kind model2.ServiceSolutionCaseKind `json:"kind"`
|
||||
Mode model2.ServiceSolutionCaseMode `json:"mode"`
|
||||
Title string `json:"title"`
|
||||
Image string `json:"image"`
|
||||
Children []*SolutionCaseBasic `json:"children"`
|
||||
@ -48,7 +48,7 @@ type (
|
||||
// Instance 服务解决方案案例
|
||||
func (c *SolutionCase) Instance() ([]*SolutionCaseInfo, error) {
|
||||
mServiceSolutionCase := model.NewServiceSolutionCase()
|
||||
out, err := mServiceSolutionCase.SolutionCase(2)
|
||||
out, err := mServiceSolutionCase.SolutionCase(6)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -72,7 +72,7 @@ func (c *SolutionCase) Instance() ([]*SolutionCaseInfo, error) {
|
||||
}
|
||||
if !isExist {
|
||||
ret = append(ret, &SolutionCaseInfo{
|
||||
ID: v.GetEncodeID(), MarkID: v.ID, Kind: v.Kind, Title: v.Title,
|
||||
ID: v.GetEncodeID(), MarkID: v.ID, Mode: v.Mode, Title: v.Title,
|
||||
Image: v.Image.Analysis(config.SettingInfo.Domain),
|
||||
Children: []*SolutionCaseBasic{detail},
|
||||
})
|
||||
@ -82,17 +82,17 @@ func (c *SolutionCase) Instance() ([]*SolutionCaseInfo, error) {
|
||||
}
|
||||
|
||||
// List 列表信息
|
||||
func (c *SolutionCase) List(id uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceSolutionCaseDetail := model.NewServiceSolutionCaseDetail()
|
||||
func (c *SolutionCase) List(kindID uint64, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mServiceSolutionCase := model.NewServiceSolutionCase()
|
||||
|
||||
out := make([]*model2.ServiceSolutionCaseDetail, 0)
|
||||
out := make([]*model2.ServiceSolutionCase, 0)
|
||||
|
||||
var count int64
|
||||
|
||||
err := model2.PagesFields(mServiceSolutionCaseDetail.ServiceSolutionCaseDetail, &out, []string{"id", "title",
|
||||
err := model2.PagesFields(mServiceSolutionCase.ServiceSolutionCase, &out, []string{"id", "title",
|
||||
"image", "description"}, page, pageSize, &count,
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("solution_case_id", id),
|
||||
Where: model2.NewWhere("kind_id", kindID),
|
||||
Order: model2.NewOrder("sort", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
@ -114,36 +114,37 @@ func (c *SolutionCase) List(id uint64, page, pageSize int) (*controller.ReturnPa
|
||||
|
||||
// Detail 详细信息
|
||||
func (c *SolutionCase) Detail(id uint64) (*SolutionCaseDetail, error) {
|
||||
mServiceSolutionCaseDetail := model.NewServiceSolutionCaseDetail()
|
||||
mServiceSolutionCaseDetail.ID = id
|
||||
mServiceSolutionCase := model.NewServiceSolutionCase()
|
||||
mServiceSolutionCase.ID = id
|
||||
|
||||
if isExist, err := model2.FirstField(mServiceSolutionCaseDetail.ServiceSolutionCaseDetail, []string{"id", "title",
|
||||
if isExist, err := model2.FirstField(mServiceSolutionCase.ServiceSolutionCase, []string{"id", "title",
|
||||
"image", "description", "content", "visits", "created_at"}); err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,案例信息不存在或已被删除")
|
||||
}
|
||||
_ = model2.Updates(mServiceSolutionCaseDetail.ServiceSolutionCaseDetail, map[string]interface{}{
|
||||
|
||||
_ = model2.Updates(mServiceSolutionCase.ServiceSolutionCase, map[string]interface{}{
|
||||
"visits": gorm.Expr("visits + ?", 1), "updated_at": time.Now(),
|
||||
})
|
||||
return &SolutionCaseDetail{
|
||||
SolutionCaseBasic: SolutionCaseBasic{
|
||||
ID: mServiceSolutionCaseDetail.GetEncodeID(),
|
||||
Title: mServiceSolutionCaseDetail.Title,
|
||||
Image: mServiceSolutionCaseDetail.Image.Analysis(config.SettingInfo.Domain),
|
||||
Description: mServiceSolutionCaseDetail.Description,
|
||||
ID: mServiceSolutionCase.GetEncodeID(),
|
||||
Title: mServiceSolutionCase.Title,
|
||||
Image: mServiceSolutionCase.Image.Analysis(config.SettingInfo.Domain),
|
||||
Description: mServiceSolutionCase.Description,
|
||||
},
|
||||
Visits: mServiceSolutionCaseDetail.Visits,
|
||||
Content: mServiceSolutionCaseDetail.Content,
|
||||
CreatedAt: mServiceSolutionCaseDetail.CreatedAt,
|
||||
Visits: mServiceSolutionCase.Visits,
|
||||
Content: mServiceSolutionCase.Content,
|
||||
CreatedAt: mServiceSolutionCase.CreatedAt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewSolutionCase() SolutionCaseHandle {
|
||||
return func(session *session.Enterprise, local string) *SolutionCase {
|
||||
return func(session *session.Enterprise, tenantID uint64) *SolutionCase {
|
||||
return &SolutionCase{
|
||||
Enterprise: session,
|
||||
local: local,
|
||||
tenantID: tenantID,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user