feat:优化项目信息
This commit is contained in:
@ -31,10 +31,10 @@ func (c *Equipment) List(title string, page, pageSize int) (*controller.ReturnPa
|
||||
mTechnologyEquipment := model.NewTechnologyEquipment()
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("tenant_id", c.TenantID),
|
||||
Where: model2.NewWhere("local", c.local),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("local", c.local),
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
}}
|
||||
|
||||
if title != "" {
|
||||
@ -82,6 +82,7 @@ func (c *Equipment) Form(params *EquipmentParams) error {
|
||||
if mTechnologyEquipment.ID > 0 {
|
||||
return model2.Updates(mTechnologyEquipment.TechnologyEquipment, mTechnologyEquipment.TechnologyEquipment)
|
||||
}
|
||||
mTechnologyEquipment.UID = c.UID
|
||||
return model2.Create(mTechnologyEquipment.TechnologyEquipment)
|
||||
}
|
||||
|
||||
@ -95,8 +96,8 @@ func (c *Equipment) Delete(id uint64) error {
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,设备信息不存在")
|
||||
} else if mTechnologyEquipment.Local.Local != c.local {
|
||||
return errors.New("操作错误,设备信息不存在或已被删除")
|
||||
} else if mTechnologyEquipment.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Delete(mTechnologyEquipment.TechnologyEquipment)
|
||||
|
@ -44,6 +44,8 @@ func (c *Instance) List(status, page, pageSize int) (*controller.ReturnPages, er
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("status", status),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
}}
|
||||
var count int64
|
||||
|
||||
@ -68,14 +70,13 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
if params.ID > 0 {
|
||||
mTechnologyInstance.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "m_uid",
|
||||
"status", "created_at", "updated_at"})
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid", "status", "created_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.ManageUID != mTechnologyInstance.MUid {
|
||||
return errors.New("操作错误,技术信息不存在或已被删除")
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
|
||||
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
|
||||
@ -106,9 +107,8 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
mTechnologyInstance.Status = model2.TechnologyInstanceStatusForExamining
|
||||
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
|
||||
}
|
||||
mTechnologyInstance.MUid = c.ManageUID
|
||||
mTechnologyInstance.UID = c.UID
|
||||
mTechnologyInstance.Local.Local = c.local
|
||||
mTechnologyInstance.TenantID = c.TenantID
|
||||
|
||||
if params.IsSubmit > 0 {
|
||||
mTechnologyInstance.Status = model2.TechnologyInstanceStatusForExamining
|
||||
@ -120,13 +120,13 @@ 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", "m_uid", "shelf", "status"})
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid", "shelf", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.ManageUID != mTechnologyInstance.MUid {
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
|
||||
return errors.New("操作错误,当前状态不允许处理上下架")
|
||||
@ -145,13 +145,13 @@ 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", "m_uid"})
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.ManageUID != mTechnologyInstance.MUid {
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {
|
||||
|
@ -49,7 +49,7 @@ func (c *Product) List(title string, status, page, pageSize int) ([]*ProductInfo
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("m_uid", c.ManageUID),
|
||||
Where: model2.NewWhere("uid", c.UID),
|
||||
},
|
||||
&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("status", status),
|
||||
@ -112,7 +112,7 @@ func (c *Product) Form(params *ProductParams) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,产品信息不存在或已被删除")
|
||||
} else if mTechnologyProduct.MUid != c.ManageUID {
|
||||
} else if mTechnologyProduct.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
} else if mTechnologyProduct.Status != model2.TechnologyProductStatusForRefuse &&
|
||||
mTechnologyProduct.Status != model2.TechnologyProductStatusForDraft {
|
||||
@ -135,9 +135,8 @@ func (c *Product) Form(params *ProductParams) error {
|
||||
mTechnologyProduct.Status = model2.TechnologyProductStatusForExamining
|
||||
return model2.Updates(mTechnologyProduct.TechnologyProduct, mTechnologyProduct.TechnologyProduct)
|
||||
}
|
||||
mTechnologyProduct.TenantID = c.TenantID
|
||||
mTechnologyProduct.Local.Local = c.local
|
||||
mTechnologyProduct.MUid = c.UID
|
||||
mTechnologyProduct.UID = c.UID
|
||||
|
||||
if params.IsSubmit > 0 {
|
||||
mTechnologyProduct.Status = model2.TechnologyProductStatusForExamining
|
||||
@ -150,13 +149,13 @@ func (c *Product) Shelf(id uint64, status int) error {
|
||||
mTechnologyProduct := model.NewTechnologyProduct()
|
||||
mTechnologyProduct.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyProduct.TechnologyProduct, []string{"id", "m_uid", "status"})
|
||||
isExist, err := model2.FirstField(mTechnologyProduct.TechnologyProduct, []string{"id", "uid", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,产品信息不存在或已被删除")
|
||||
} else if mTechnologyProduct.MUid != c.ManageUID {
|
||||
} else if mTechnologyProduct.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
} else if mTechnologyProduct.ShelfStatus.Shelf == model2.ShelfStatusKind(status) {
|
||||
return errors.New("操作错误,无需变更上下架状态")
|
||||
@ -171,13 +170,13 @@ func (c *Product) Delete(id uint64) error {
|
||||
mTechnologyProduct := model.NewTechnologyProduct()
|
||||
mTechnologyProduct.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyProduct.TechnologyProduct, []string{"id", "m_uid"})
|
||||
isExist, err := model2.FirstField(mTechnologyProduct.TechnologyProduct, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,产品信息不存在或已被删除")
|
||||
} else if mTechnologyProduct.MUid != c.ManageUID {
|
||||
} else if mTechnologyProduct.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Delete(mTechnologyProduct.TechnologyProduct)
|
||||
|
@ -49,7 +49,7 @@ func (c *Topic) List(status int, page, pageSize int) (*controller.ReturnPages, e
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||
Where: model2.NewWhere("status", status),
|
||||
Order: model2.NewOrder("id", model2.OrderModeToDesc),
|
||||
}, &model2.ModelWhereOrder{Where: model2.NewWhere("uid", c.ManageUID)}}
|
||||
}, &model2.ModelWhereOrder{Where: model2.NewWhere("uid", c.UID)}}
|
||||
|
||||
var count int64
|
||||
|
||||
@ -94,13 +94,13 @@ func (c *Topic) Form(params *TopicParams) error {
|
||||
|
||||
if params.ID > 0 {
|
||||
mTechnologyTopic.ID = params.ID
|
||||
isExist, err := model2.FirstField(mTechnologyTopic.TechnologyTopic, []string{"id", "m_uid", "status"})
|
||||
isExist, err := model2.FirstField(mTechnologyTopic.TechnologyTopic, []string{"id", "uid", "status"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,课题信息不存在")
|
||||
} else if mTechnologyTopic.MUid != c.ManageUID {
|
||||
} else if mTechnologyTopic.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
} else if mTechnologyTopic.Status != model2.TechnologyTopicStatusForDraft &&
|
||||
mTechnologyTopic.Status != model2.TechnologyTopicStatusForRefuse {
|
||||
@ -122,9 +122,8 @@ func (c *Topic) Form(params *TopicParams) error {
|
||||
mTechnologyTopic.UpdatedAt = time.Now()
|
||||
return model2.Updates(mTechnologyTopic.TechnologyTopic, mTechnologyTopic.TechnologyTopic)
|
||||
}
|
||||
mTechnologyTopic.TenantID = c.TenantID
|
||||
mTechnologyTopic.Local.Local = c.local
|
||||
mTechnologyTopic.MUid = c.ManageUID
|
||||
mTechnologyTopic.UID = c.UID
|
||||
return model2.Create(mTechnologyTopic.TechnologyTopic)
|
||||
}
|
||||
|
||||
@ -139,7 +138,7 @@ func (c *Topic) Delete(id uint64) error {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("操作错误,课题信息不存在")
|
||||
} else if mTechnologyTopic.MUid != c.ManageUID {
|
||||
} else if mTechnologyTopic.UID != c.UID {
|
||||
return errors.New("无权限操作")
|
||||
}
|
||||
return model2.Delete(mTechnologyTopic.TechnologyTopic)
|
||||
|
@ -3,8 +3,8 @@ package model
|
||||
// TechnologyEquipment 技术设备管理信息
|
||||
type TechnologyEquipment struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Local
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Title string `gorm:"column:title;type:varchar(30);default:null;comment:名称" json:"title"`
|
||||
Research string `gorm:"column:research;type:varchar(255);default:null;comment:研究信息" json:"research"`
|
||||
Describe string `gorm:"column:describe;type:varchar(255);default:null;comment:描述" json:"describe"`
|
||||
|
@ -8,9 +8,8 @@ import (
|
||||
// TechnologyInstance 技术文档数据模型
|
||||
type TechnologyInstance struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Local
|
||||
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
PatentID uint64 `gorm:"column:patent_id;type:int;default:0;comment:代表专利" json:"patent_id"`
|
||||
Title string `gorm:"column:title;type:varchar(30);default:null;comment:名称" json:"title"`
|
||||
Company string `gorm:"column:company;type:varchar(30);default:null;comment:单位" json:"company"`
|
||||
|
@ -8,9 +8,8 @@ import (
|
||||
// TechnologyProduct 技术产品数据模型
|
||||
type TechnologyProduct struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Local
|
||||
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:产品名称" json:"title"`
|
||||
Image
|
||||
Video string `gorm:"column:video;type:varchar(255);default:null;comment:视频地址" json:"video"`
|
||||
|
@ -8,9 +8,8 @@ import (
|
||||
// TechnologyTopic 技术课题数据模型
|
||||
type TechnologyTopic struct {
|
||||
Model
|
||||
ModelTenant
|
||||
Local
|
||||
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_uuid" json:"-"`
|
||||
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
|
||||
Title string `gorm:"column:title;type:varchar(100);default:null;comment:名称" json:"title"`
|
||||
Code string `gorm:"column:code;type:varchar(30);default:null;comment:编号" json:"code"`
|
||||
Emcee string `gorm:"column:emcee;type:varchar(30);default:null;comment:主持人" json:"emcee"`
|
||||
|
Reference in New Issue
Block a user