feat:增加科技产品数据模型管理
This commit is contained in:
@ -3,6 +3,7 @@ package technology
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/api/manage/controller"
|
||||
"SciencesServer/app/basic/config"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"errors"
|
||||
@ -29,8 +30,9 @@ type (
|
||||
InstanceParams struct {
|
||||
ID, PatentID, Territory uint64
|
||||
Title, Company, Images, ProveImages, Introduce, Purpose, Remark string
|
||||
Maturity, Prototype, Source, Transaction, Status int
|
||||
Maturity, Prototype, Source, Transaction int
|
||||
Products, Keywords []string
|
||||
IsSubmit int
|
||||
}
|
||||
)
|
||||
|
||||
@ -66,7 +68,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
if params.ID > 0 {
|
||||
mTechnologyInstance.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid",
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "m_uid",
|
||||
"status", "created_at", "updated_at"})
|
||||
|
||||
if err != nil {
|
||||
@ -83,7 +85,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
mTechnologyInstance.PatentID = params.PatentID
|
||||
mTechnologyInstance.Title = params.Title
|
||||
mTechnologyInstance.Company = params.Company
|
||||
mTechnologyInstance.Maturity = model2.TechnologyInstanceMaturity(params.Maturity)
|
||||
mTechnologyInstance.Maturity = config.TechnologyMaturity(params.Maturity)
|
||||
mTechnologyInstance.Prototype = params.Prototype
|
||||
mTechnologyInstance.SetProductAttribute(params.Products)
|
||||
mTechnologyInstance.Source = model2.TechnologyInstanceSource(params.Source)
|
||||
@ -95,20 +97,22 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
mTechnologyInstance.Introduce = params.Introduce
|
||||
mTechnologyInstance.Purpose = params.Purpose
|
||||
mTechnologyInstance.Remark = params.Remark
|
||||
mTechnologyInstance.Status = model2.TechnologyInstanceStatus(params.Status)
|
||||
|
||||
if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
|
||||
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForExamining {
|
||||
return errors.New("操作错误,状态参数错误")
|
||||
}
|
||||
if params.ID > 0 {
|
||||
mTechnologyInstance.UpdatedAt = time.Now()
|
||||
mTechnologyInstance.Status = model2.TechnologyInstanceStatusForExamining
|
||||
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
|
||||
}
|
||||
mTechnologyInstance.MUid = c.ManageUID
|
||||
mTechnologyInstance.Local.Local = c.local
|
||||
mTechnologyInstance.TenantID = c.TenantID
|
||||
|
||||
if params.IsSubmit > 0 {
|
||||
mTechnologyInstance.Status = model2.TechnologyInstanceStatusForExamining
|
||||
}
|
||||
return model2.Create(mTechnologyInstance.TechnologyInstance)
|
||||
}
|
||||
|
||||
@ -116,7 +120,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
func (c *Instance) Shelf(id uint64, status int) error {
|
||||
mTechnologyInstance := model.NewTechnologyInstance()
|
||||
mTechnologyInstance.ID = id
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid", "shelf_status", "status"})
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "m_uid", "shelf_status", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -141,7 +145,7 @@ func (c *Instance) Shelf(id uint64, status int) error {
|
||||
func (c *Instance) Delete(id uint64) error {
|
||||
mTechnologyInstance := model.NewTechnologyInstance()
|
||||
mTechnologyInstance.ID = id
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid"})
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "m_uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user