feat:完善信息
This commit is contained in:
@ -1,11 +1,10 @@
|
||||
package config
|
||||
|
||||
// TenantUserIdentity 租户用户身份信息
|
||||
type TenantUserIdentity int
|
||||
// 身份信息
|
||||
|
||||
const (
|
||||
TenantUserIdentityForPerson int = 0 // 0
|
||||
TenantUserIdentityForCompany int = 1 // 1
|
||||
TenantUserIdentityForCompany int = 1 << 0 // 1
|
||||
TenantUserIdentityForExpert int = 1 << 1 // 2
|
||||
TenantUserIdentityForResearch int = 1 << 2 // 4
|
||||
TenantUserIdentityForLaboratory int = 1 << 3 // 8
|
||||
@ -19,3 +18,20 @@ var TenantUserIdentityData = map[int]string{
|
||||
TenantUserIdentityForResearch: "研究机构", TenantUserIdentityForLaboratory: "实验室",
|
||||
TenantUserIdentityForAgent: "科技经纪人",
|
||||
}
|
||||
|
||||
// 交易信息
|
||||
|
||||
const (
|
||||
TechnologyTransactionForTransfer int = 1 << 0
|
||||
TechnologyTransactionForPermit int = 1 << 1
|
||||
TechnologyTransactionForShare int = 1 << 2
|
||||
TechnologyTransactionForCooperation int = 1 << 3
|
||||
TechnologyTransactionForOther int = 1 << 4
|
||||
)
|
||||
|
||||
// TechnologyTransactionData 交易信息
|
||||
var TechnologyTransactionData = map[int]string{
|
||||
TechnologyTransactionForTransfer: "技术转让", TechnologyTransactionForPermit: "技术许可",
|
||||
TechnologyTransactionForShare: "技术入股", TechnologyTransactionForCooperation: "合作开发",
|
||||
TechnologyTransactionForOther: "其他",
|
||||
}
|
||||
|
@ -66,6 +66,20 @@ const (
|
||||
AccountStatusForDisable
|
||||
)
|
||||
|
||||
// ShelfStatus 上下架状态
|
||||
type ShelfStatus struct {
|
||||
ShelfStatus ShelfStatusKind `gorm:"column:shelf_status;type:tinyint(1);default:0;comment:上下架状态(1:上架,2:下架)" json:"shelf_status"`
|
||||
}
|
||||
|
||||
type ShelfStatusKind int
|
||||
|
||||
const (
|
||||
// ShelfStatusForUp 上架
|
||||
ShelfStatusForUp ShelfStatusKind = iota
|
||||
// ShelfStatusForDown 下架
|
||||
ShelfStatusForDown
|
||||
)
|
||||
|
||||
// ExamineStatus 审核状态
|
||||
type ExamineStatus struct {
|
||||
Status ExamineStatusKind `gorm:"column:status;type:tinyint(1);default:0;comment:审核状态(0:审核中,1:审核通过,2:审核拒绝)" json:"status"`
|
||||
|
@ -1,4 +1,105 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/utils"
|
||||
|
||||
// TechnologyInstance 技术文档数据模型
|
||||
type TechnologyInstance struct {
|
||||
Model
|
||||
ModelTenant
|
||||
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"`
|
||||
Maturity TechnologyInstanceMaturity `gorm:"column:maturity;type:tinyint(1);default:0;comment:成熟度" json:"maturity"`
|
||||
Prototype int `gorm:"column:prototype;type:tinyint(1);default:0;comment:样机(0:无,1:有)" json:"prototype"`
|
||||
Product string `gorm:"column:product;type:varchar(255);default:null;comment:应用产品" json:"product"`
|
||||
Source TechnologyInstanceSource `gorm:"column:source;type:tinyint(1);default:0;comment:来源" json:"source"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"keyword"`
|
||||
Territory uint64 `gorm:"column:territory;type:int(11);default:0;comment:技术领域" json:"territory"`
|
||||
Transaction int `gorm:"column:transaction;type:tinyint(3);default:0;comment:交易方式" json:"transaction"`
|
||||
Images
|
||||
ProveImages string `gorm:"column:prove_images;type:text;default:null;comment:证明材料图片" json:"prove_images"`
|
||||
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
|
||||
Purpose string `gorm:"column:purpose;type:text;comment:意图-承担科研项目" json:"purpose"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注信息" json:"remark"`
|
||||
ShelfStatus
|
||||
Status TechnologyInstanceStatus `gorm:"column:status;type:tinyint(1);default:0;comment:状态" json:"status"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
// TechnologyInstanceMaturity 技术文档成熟度
|
||||
type TechnologyInstanceMaturity int
|
||||
|
||||
const (
|
||||
// TechnologyInstanceMaturityForDev 正在研发
|
||||
TechnologyInstanceMaturityForDev TechnologyInstanceMaturity = iota + 1
|
||||
// TechnologyInstanceMaturityForTest 小试阶段
|
||||
TechnologyInstanceMaturityForTest
|
||||
// TechnologyInstanceMaturityForTestFinish 通过小试
|
||||
TechnologyInstanceMaturityForTestFinish
|
||||
// TechnologyInstanceMaturityForModerateTest 中试阶段
|
||||
TechnologyInstanceMaturityForModerateTest
|
||||
// TechnologyInstanceMaturityForModerateTestFinish 通过中试
|
||||
TechnologyInstanceMaturityForModerateTestFinish
|
||||
// TechnologyInstanceMaturityForProduce 可规模生产
|
||||
TechnologyInstanceMaturityForProduce
|
||||
)
|
||||
|
||||
// TechnologyInstanceSource 技术来源
|
||||
type TechnologyInstanceSource int
|
||||
|
||||
const (
|
||||
// TechnologyInstanceSourceForCompany 企业
|
||||
TechnologyInstanceSourceForCompany TechnologyInstanceSource = iota
|
||||
// TechnologyInstanceSourceForSchool 院校
|
||||
TechnologyInstanceSourceForSchool
|
||||
// TechnologyInstanceSourceForResearch 科研机构
|
||||
TechnologyInstanceSourceForResearch
|
||||
// TechnologyInstanceSourceForPerson 个人
|
||||
TechnologyInstanceSourceForPerson
|
||||
// TechnologyInstanceSourceForOther 其他
|
||||
TechnologyInstanceSourceForOther
|
||||
)
|
||||
|
||||
// TechnologyInstanceStatus 技术文档状态
|
||||
type TechnologyInstanceStatus int
|
||||
|
||||
const (
|
||||
// TechnologyInstanceStatusForDraft 草稿箱
|
||||
TechnologyInstanceStatusForDraft TechnologyInstanceStatus = iota
|
||||
// TechnologyInstanceStatusForExamining 审核中
|
||||
TechnologyInstanceStatusForExamining
|
||||
// TechnologyInstanceStatusForAgree 审核通过
|
||||
TechnologyInstanceStatusForAgree
|
||||
// TechnologyInstanceStatusForRefuse 审核拒绝
|
||||
TechnologyInstanceStatusForRefuse
|
||||
)
|
||||
|
||||
func (m *TechnologyInstance) TableName() string {
|
||||
return m.NewTableName("technology_instance")
|
||||
}
|
||||
|
||||
func (m *TechnologyInstance) GetKeywordAttribute() []string {
|
||||
keywords := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Keyword, &keywords)
|
||||
return keywords
|
||||
}
|
||||
|
||||
func (m *TechnologyInstance) SetKeywordAttribute(keywords []string) {
|
||||
m.Keyword = utils.AnyToJSON(keywords)
|
||||
}
|
||||
|
||||
func (m *TechnologyInstance) GetProductAttribute() []string {
|
||||
products := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Product, &products)
|
||||
return products
|
||||
}
|
||||
|
||||
func (m *TechnologyInstance) SetProductAttribute(products []string) {
|
||||
m.Product = utils.AnyToJSON(products)
|
||||
}
|
||||
|
||||
func NewTechnologyInstance() *TechnologyInstance {
|
||||
return &TechnologyInstance{}
|
||||
}
|
||||
|
@ -1,21 +1,150 @@
|
||||
package technology
|
||||
|
||||
import "SciencesServer/app/service"
|
||||
import (
|
||||
"SciencesServer/app/api/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/enterprise/model"
|
||||
"SciencesServer/app/service"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Instance 技术管理
|
||||
type Instance struct{ *service.SessionEnterprise }
|
||||
|
||||
type InstanceHandle func(enterprise *service.SessionEnterprise) *Instance
|
||||
|
||||
func (c *Instance) List(status, page, pageSize int) {
|
||||
type (
|
||||
// InstanceInfo 详细信息
|
||||
InstanceInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.TechnologyInstance
|
||||
Products []string `json:"products"`
|
||||
Keywords []string `json:"keywords"`
|
||||
}
|
||||
// InstanceParams 参数信息
|
||||
InstanceParams struct {
|
||||
ID, PatentID, Territory uint64
|
||||
Title, Company, Images, ProveImages, Introduce, Purpose, Remark string
|
||||
Maturity, Prototype, Source, Transaction, Status int
|
||||
Products, Keywords []string
|
||||
}
|
||||
)
|
||||
|
||||
// List 列表信息
|
||||
func (c *Instance) List(status, page, pageSize int) (*controller.ReturnPages, error) {
|
||||
mTechnologyInstance := model.NewTechnologyInstance()
|
||||
out := make([]*model2.TechnologyInstance, 0)
|
||||
|
||||
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{Order: model2.NewOrder("id", model2.OrderModeToDesc)}}
|
||||
|
||||
var count int64
|
||||
|
||||
if err := model2.Pages(mTechnologyInstance.TechnologyInstance, &out, page, pageSize, &count, where...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
list := make([]*InstanceInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
list = append(list, &InstanceInfo{
|
||||
ID: v.GetEncodeID(), TechnologyInstance: v,
|
||||
Products: v.GetProductAttribute(), Keywords: v.GetKeywordAttribute(),
|
||||
})
|
||||
}
|
||||
return &controller.ReturnPages{Data: list, Count: count}, nil
|
||||
}
|
||||
|
||||
func (c *Instance) Form() {
|
||||
// Form 数据操作
|
||||
func (c *Instance) Form(params *InstanceParams) error {
|
||||
mTechnologyInstance := model.NewTechnologyInstance()
|
||||
|
||||
if params.ID > 0 {
|
||||
mTechnologyInstance.ID = params.ID
|
||||
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid",
|
||||
"status", "created_at", "updated_at"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
|
||||
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
|
||||
return errors.New("操作错误,当前状态不允许修改")
|
||||
}
|
||||
}
|
||||
mTechnologyInstance.UID = c.UID
|
||||
mTechnologyInstance.PatentID = params.PatentID
|
||||
mTechnologyInstance.Title = params.Title
|
||||
mTechnologyInstance.Company = params.Company
|
||||
mTechnologyInstance.Maturity = model2.TechnologyInstanceMaturity(params.Maturity)
|
||||
mTechnologyInstance.Prototype = params.Prototype
|
||||
mTechnologyInstance.SetProductAttribute(params.Products)
|
||||
mTechnologyInstance.Source = model2.TechnologyInstanceSource(params.Source)
|
||||
mTechnologyInstance.SetKeywordAttribute(params.Keywords)
|
||||
mTechnologyInstance.Territory = params.Territory
|
||||
mTechnologyInstance.Transaction = params.Transaction
|
||||
mTechnologyInstance.Images = model2.Images{Images: params.Images}
|
||||
mTechnologyInstance.ProveImages = params.ProveImages
|
||||
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 {
|
||||
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
|
||||
}
|
||||
return model2.Create(mTechnologyInstance.TechnologyInstance)
|
||||
}
|
||||
|
||||
func (c *Instance) Delete() {
|
||||
// Shelf 上下架操作
|
||||
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"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
|
||||
return errors.New("操作错误,当前状态不允许处理上下架")
|
||||
} else if mTechnologyInstance.ShelfStatus.ShelfStatus == model2.ShelfStatusKind(status) {
|
||||
return errors.New("操作错误,状态异常")
|
||||
}
|
||||
if err = model2.Updates(mTechnologyInstance.TechnologyInstance, map[string]interface{}{
|
||||
"shelf_status": status, "updated_at": time.Now(),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func (c *Instance) Delete(id uint64) error {
|
||||
mTechnologyInstance := model.NewTechnologyInstance()
|
||||
mTechnologyInstance.ID = id
|
||||
isExist, err := model2.FirstField(mTechnologyInstance.TechnologyInstance, []string{"id", "uid"})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !isExist {
|
||||
return errors.New("信息不存在")
|
||||
} else if c.UID != mTechnologyInstance.UID {
|
||||
return errors.New("操作错误,无权限操作")
|
||||
}
|
||||
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewInstance() InstanceHandle {
|
||||
|
11
app/enterprise/model/technology_instance.go
Normal file
11
app/enterprise/model/technology_instance.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type TechnologyInstance struct {
|
||||
*model.TechnologyInstance
|
||||
}
|
||||
|
||||
func NewTechnologyInstance() *TechnologyInstance {
|
||||
return &TechnologyInstance{model.NewTechnologyInstance()}
|
||||
}
|
Reference in New Issue
Block a user