feat:完善项目信息
This commit is contained in:
@ -39,6 +39,7 @@ func (*Service) InnovateDetail(c *gin.Context) {
|
||||
func (*Service) InnovateForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
api.TenantIDStringForm
|
||||
KindID string `json:"kind_id" form:"kind_id" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Content string `json:"content" form:"content" binding:"required"`
|
||||
@ -50,7 +51,8 @@ func (*Service) InnovateForm(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
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(),
|
||||
KindID: (&api.IDStringForm{ID: form.KindID}).Convert(),
|
||||
Title: form.Title, Content: form.Content, Tags: form.Tags, Sort: form.Sort,
|
||||
})
|
||||
api.APIResponse(err)(c)
|
||||
@ -89,6 +91,7 @@ func (*Service) InnovateKindSelect(c *gin.Context) {
|
||||
func (*Service) InnovateKindForm(c *gin.Context) {
|
||||
form := &struct {
|
||||
api.IDStringForm
|
||||
api.TenantIDStringForm
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Sort int `json:"sort" form:"sort"`
|
||||
}{}
|
||||
@ -97,7 +100,7 @@ func (*Service) InnovateKindForm(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ type (
|
||||
}
|
||||
// InnovateParams 服务参数信息
|
||||
InnovateParams struct {
|
||||
ID, KindID uint64
|
||||
ID, TenantID, KindID uint64
|
||||
Title, Content string
|
||||
Tags []string
|
||||
Sort int
|
||||
@ -39,6 +39,7 @@ type (
|
||||
InnovateKindInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model.ServiceInnovateKindInfo
|
||||
TenantID string `json:"tenant_id"`
|
||||
Area string `json:"area"`
|
||||
}
|
||||
// InnovateKindSelectInfo 服务分类筛选信息
|
||||
@ -48,7 +49,7 @@ type (
|
||||
}
|
||||
// InnovateKindParams 服务分类参数信息
|
||||
InnovateKindParams struct {
|
||||
ID uint64
|
||||
ID, TenantID uint64
|
||||
Title string
|
||||
Sort int
|
||||
}
|
||||
@ -134,9 +135,16 @@ func (c *Innovate) Form(params *InnovateParams) error {
|
||||
mServiceInnovate.Sort = params.Sort
|
||||
|
||||
if mServiceInnovate.ID > 0 {
|
||||
if c.TenantID <= 0 {
|
||||
mServiceInnovate.TenantID = params.TenantID
|
||||
}
|
||||
return model2.Updates(mServiceInnovate.ServiceInnovate, mServiceInnovate.ServiceInnovate)
|
||||
}
|
||||
mServiceInnovate.TenantID = params.TenantID
|
||||
|
||||
if c.TenantID > 0 {
|
||||
mServiceInnovate.TenantID = c.TenantID
|
||||
}
|
||||
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 {
|
||||
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
|
||||
@ -242,9 +250,16 @@ func (c *Innovate) KindForm(params *InnovateKindParams) error {
|
||||
mServiceInnovateKind.Sort = params.Sort
|
||||
|
||||
if mServiceInnovateKind.ID > 0 {
|
||||
if c.TenantID <= 0 {
|
||||
mServiceInnovateKind.TenantID = params.TenantID
|
||||
}
|
||||
return model2.Updates(mServiceInnovateKind.ServiceInnovateKind, mServiceInnovateKind.ServiceInnovateKind)
|
||||
}
|
||||
mServiceInnovateKind.TenantID = params.TenantID
|
||||
|
||||
if c.TenantID > 0 {
|
||||
mServiceInnovateKind.TenantID = c.TenantID
|
||||
}
|
||||
return model2.Create(mServiceInnovateKind.ServiceInnovateKind)
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServiceInnovateKind struct {
|
||||
@ -12,14 +13,16 @@ type ServiceInnovateKind struct {
|
||||
|
||||
type ServiceInnovateKindInfo struct {
|
||||
model.Model
|
||||
model.ModelTenant
|
||||
model.Area
|
||||
Title string `json:"title"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// Kind 分类信息
|
||||
func (m *ServiceInnovateKind) Kind(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ServiceInnovateKindInfo, error) {
|
||||
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())).
|
||||
Where("k.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
|
Reference in New Issue
Block a user