feat:完善项目信息
This commit is contained in:
@ -39,6 +39,7 @@ func (*Service) InnovateDetail(c *gin.Context) {
|
|||||||
func (*Service) InnovateForm(c *gin.Context) {
|
func (*Service) InnovateForm(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
api.IDStringForm
|
api.IDStringForm
|
||||||
|
api.TenantIDStringForm
|
||||||
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" binding:"required"`
|
||||||
Content string `json:"content" form:"content" binding:"required"`
|
Content string `json:"content" form:"content" binding:"required"`
|
||||||
@ -50,8 +51,9 @@ func (*Service) InnovateForm(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Form(&service.InnovateParams{
|
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).Form(&service.InnovateParams{
|
||||||
ID: form.Convert(), KindID: (&api.IDStringForm{ID: form.KindID}).Convert(),
|
ID: form.IDStringForm.Convert(), TenantID: form.TenantIDStringForm.Convert(),
|
||||||
Title: form.Title, Content: form.Content, Tags: form.Tags, Sort: form.Sort,
|
KindID: (&api.IDStringForm{ID: form.KindID}).Convert(),
|
||||||
|
Title: form.Title, Content: form.Content, Tags: form.Tags, Sort: form.Sort,
|
||||||
})
|
})
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
@ -89,6 +91,7 @@ func (*Service) InnovateKindSelect(c *gin.Context) {
|
|||||||
func (*Service) InnovateKindForm(c *gin.Context) {
|
func (*Service) InnovateKindForm(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
api.IDStringForm
|
api.IDStringForm
|
||||||
|
api.TenantIDStringForm
|
||||||
Title string `json:"title" form:"title" binding:"required"`
|
Title string `json:"title" form:"title" binding:"required"`
|
||||||
Sort int `json:"sort" form:"sort"`
|
Sort int `json:"sort" form:"sort"`
|
||||||
}{}
|
}{}
|
||||||
@ -97,7 +100,7 @@ func (*Service) InnovateKindForm(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).KindForm(&service.InnovateKindParams{
|
err := service.NewInnovate()(api.GetSession()(c).(*session.Admin)).KindForm(&service.InnovateKindParams{
|
||||||
ID: form.Convert(), Title: form.Title, Sort: form.Sort,
|
ID: form.IDStringForm.Convert(), TenantID: form.TenantIDStringForm.Convert(), Title: form.Title, Sort: form.Sort,
|
||||||
})
|
})
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
@ -30,16 +30,17 @@ type (
|
|||||||
}
|
}
|
||||||
// InnovateParams 服务参数信息
|
// InnovateParams 服务参数信息
|
||||||
InnovateParams struct {
|
InnovateParams struct {
|
||||||
ID, KindID uint64
|
ID, TenantID, KindID uint64
|
||||||
Title, Content string
|
Title, Content string
|
||||||
Tags []string
|
Tags []string
|
||||||
Sort int
|
Sort int
|
||||||
}
|
}
|
||||||
// InnovateKindInfo 服务分类信息
|
// InnovateKindInfo 服务分类信息
|
||||||
InnovateKindInfo struct {
|
InnovateKindInfo struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
*model.ServiceInnovateKindInfo
|
*model.ServiceInnovateKindInfo
|
||||||
Area string `json:"area"`
|
TenantID string `json:"tenant_id"`
|
||||||
|
Area string `json:"area"`
|
||||||
}
|
}
|
||||||
// InnovateKindSelectInfo 服务分类筛选信息
|
// InnovateKindSelectInfo 服务分类筛选信息
|
||||||
InnovateKindSelectInfo struct {
|
InnovateKindSelectInfo struct {
|
||||||
@ -48,9 +49,9 @@ type (
|
|||||||
}
|
}
|
||||||
// InnovateKindParams 服务分类参数信息
|
// InnovateKindParams 服务分类参数信息
|
||||||
InnovateKindParams struct {
|
InnovateKindParams struct {
|
||||||
ID uint64
|
ID, TenantID uint64
|
||||||
Title string
|
Title string
|
||||||
Sort int
|
Sort int
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -134,9 +135,16 @@ func (c *Innovate) Form(params *InnovateParams) error {
|
|||||||
mServiceInnovate.Sort = params.Sort
|
mServiceInnovate.Sort = params.Sort
|
||||||
|
|
||||||
if mServiceInnovate.ID > 0 {
|
if mServiceInnovate.ID > 0 {
|
||||||
|
if c.TenantID <= 0 {
|
||||||
|
mServiceInnovate.TenantID = params.TenantID
|
||||||
|
}
|
||||||
return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate)
|
return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate)
|
||||||
}
|
}
|
||||||
mServiceInnovate.TenantID = c.TenantID
|
mServiceInnovate.TenantID = params.TenantID
|
||||||
|
|
||||||
|
if c.TenantID > 0 {
|
||||||
|
mServiceInnovate.TenantID = c.TenantID
|
||||||
|
}
|
||||||
return model2.Create(mServiceInnovate.ServiceInnovate)
|
return model2.Create(mServiceInnovate.ServiceInnovate)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +193,7 @@ func (c *Innovate) Kind(tenantID uint64, title string, page, pageSize int) (*con
|
|||||||
|
|
||||||
for _, v := range out {
|
for _, v := range out {
|
||||||
list = append(list, &InnovateKindInfo{
|
list = append(list, &InnovateKindInfo{
|
||||||
ID: v.GetEncodeID(), ServiceInnovateKindInfo: v, Area: v.FormatBasic(),
|
ID: v.GetEncodeID(), TenantID: v.GetEncodeTenantID(), ServiceInnovateKindInfo: v, Area: v.FormatBasic(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||||
@ -242,9 +250,16 @@ func (c *Innovate) KindForm(params *InnovateKindParams) error {
|
|||||||
mServiceInnovateKind.Sort = params.Sort
|
mServiceInnovateKind.Sort = params.Sort
|
||||||
|
|
||||||
if mServiceInnovateKind.ID > 0 {
|
if mServiceInnovateKind.ID > 0 {
|
||||||
|
if c.TenantID <= 0 {
|
||||||
|
mServiceInnovateKind.TenantID = params.TenantID
|
||||||
|
}
|
||||||
return model2.Updates(mServiceInnovateKind.ServiceInnovateKind, mServiceInnovateKind.ServiceInnovateKind)
|
return model2.Updates(mServiceInnovateKind.ServiceInnovateKind, mServiceInnovateKind.ServiceInnovateKind)
|
||||||
}
|
}
|
||||||
mServiceInnovateKind.TenantID = c.TenantID
|
mServiceInnovateKind.TenantID = params.TenantID
|
||||||
|
|
||||||
|
if c.TenantID > 0 {
|
||||||
|
mServiceInnovateKind.TenantID = c.TenantID
|
||||||
|
}
|
||||||
return model2.Create(mServiceInnovateKind.ServiceInnovateKind)
|
return model2.Create(mServiceInnovateKind.ServiceInnovateKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"SciencesServer/app/common/model"
|
"SciencesServer/app/common/model"
|
||||||
"SciencesServer/serve/orm"
|
"SciencesServer/serve/orm"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ServiceInnovateKind struct {
|
type ServiceInnovateKind struct {
|
||||||
@ -12,14 +13,16 @@ type ServiceInnovateKind struct {
|
|||||||
|
|
||||||
type ServiceInnovateKindInfo struct {
|
type ServiceInnovateKindInfo struct {
|
||||||
model.Model
|
model.Model
|
||||||
|
model.ModelTenant
|
||||||
model.Area
|
model.Area
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
CreatedAt time.Time `json:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kind 分类信息
|
// Kind 分类信息
|
||||||
func (m *ServiceInnovateKind) Kind(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceInnovateKindInfo, error) {
|
func (m *ServiceInnovateKind) Kind(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceInnovateKindInfo, error) {
|
||||||
db := orm.GetDB().Table(m.TableName()+" AS k").
|
db := orm.GetDB().Table(m.TableName()+" AS k").
|
||||||
Select("k.id", "i.title", "k.created_at", "t.province", "t.city").
|
Select("k.id", "k.tenant_id", "k.title", "k.created_at", "t.province", "t.city").
|
||||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON k.tenant_id = t.id", model.NewSysTenant().TableName())).
|
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON k.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||||
Where("k.is_deleted = ?", model.DeleteStatusForNot)
|
Where("k.is_deleted = ?", model.DeleteStatusForNot)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user