feat:增加专利模型数据

This commit is contained in:
henry
2021-11-26 17:26:01 +08:00
parent 3908a05bfa
commit dabb567d41
17 changed files with 512 additions and 7 deletions

View File

@ -49,6 +49,9 @@ func initModel() {
&synchronized{iModel: model.NewSysConfig(), iValues: func() interface{} {
return nil
}},
&synchronized{iModel: model.NewSysPatent(), iValues: func() interface{} {
return nil
}},
// 日志管理
&synchronized{iModel: model.NewSysUserRole()},
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},

View File

@ -74,7 +74,7 @@ const (
// ShelfStatus 上下架状态
type ShelfStatus struct {
ShelfStatus ShelfStatusKind `gorm:"column:shelf_status;type:tinyint(1);default:0;comment:上下架状态1上架2下架" json:"shelf_status"`
Shelf ShelfStatusKind `gorm:"column:shelf;type:tinyint(1);default:0;comment:上下架状态1上架2下架" json:"shelf"`
}
type ShelfStatusKind int

View File

@ -373,6 +373,25 @@ func ScanFields(model IModel, out interface{}, fields []string, where ...*ModelW
return db.Scan(out).Error
}
func ScanLimitFields(model IModel, out interface{}, fields []string, limit int, where ...*ModelWhereOrder) error {
db := orm.GetDB().Table(model.TableName()).Select(fields)
if len(where) > 0 {
for _, wo := range where {
if wo.Where != nil {
db = db.Where(wo.Where.Condition, wo.Where.Value)
}
if wo.Order != nil {
db = db.Order(fmt.Sprintf("%s %s", wo.Order.Field, wo.Order.Mode))
}
}
}
if db.Migrator().HasColumn(model, FieldsForDeleted) {
db = db.Where(FieldsForDeleted, DeleteStatusForNot)
}
return db.Offset(0).Limit(limit).Scan(out).Error
}
func Pluck(model IModel, field string, out interface{}, where ...*ModelWhere) error {
db := orm.GetDB().Table(model.TableName())

View File

@ -0,0 +1,55 @@
package model
// SysPatent 专利信息数据模型
type SysPatent struct {
Model
Kind SysParentKind `gorm:"column:kind;type:tinyint(1);default:0;comment:专利类型" json:"kind"`
Title string `gorm:"column:title;type:varchar(255);default:null;comment:名称标题" json:"title"`
FileUrl string `gorm:"column:file_url;type:varchar(255);default:null;comment:文件地址" json:"file_url"`
ApplyCode string `gorm:"column:apply_code;type:varchar(50);default:null;comment:申请号" json:"apply_code"`
ApplyAt string `gorm:"column:apply_at;type:varchar(30);default:null;comment:申请日" json:"apply_at"`
OpenCode string `gorm:"column:open_code;type:varchar(50);default:null;comment:公开(公告)号" json:"open_code"`
OpenAt string `gorm:"column:open_at;type:varchar(30);default:null;comment:公开(公告)日" json:"open_at"`
ApplyName string `gorm:"column:apply_name;type:varchar(100);default:null;comment:申请(专利权)人" json:"apply_name"`
ApplyAddress string `gorm:"column:apply_address;type:varchar(255);default:null;comment:申请人地址" json:"apply_address"`
Inventor string `gorm:"column:inventor;type:varchar(100);default:null;comment:发明人" json:"inventor"`
Description string `gorm:"column:description;type:text;default:null;comment:摘要" json:"description"`
PrincipalClaim string `gorm:"column:principal_claim;type:text;default:null;comment:主权项" json:"principal_claim"`
IPCCode string `gorm:"column:ipc_code;type:varchar(50);default:null;comment:IPC主分类号" json:"ipc_code"`
ShelfStatus
Status SysParentStatus `gorm:"column:status;type:tinyint(1);default:1;comment:专利状态(1授权2实审3公开)" json:"-"`
ModelDeleted
ModelAt
}
// SysParentKind 专利类型
type SysParentKind int
const (
// SysParentKindForInvent 发明专利
SysParentKindForInvent SysParentKind = iota + 1
// SysParentKindForDesign 外观设计
SysParentKindForDesign
// SysParentKindForNewPractical 实用新型
SysParentKindForNewPractical
)
// SysParentStatus 专利状态
type SysParentStatus int
const (
// SysParentStatusForAuthorize 授权
SysParentStatusForAuthorize SysParentStatus = iota + 1
// SysParentStatusForActualTrial 实审
SysParentStatusForActualTrial
// SysParentStatusForPublic 公开
SysParentStatusForPublic
)
func (m *SysPatent) TableName() string {
return "sys_patent"
}
func NewSysPatent() *SysPatent {
return &SysPatent{}
}

View File

@ -0,0 +1,108 @@
package model
import (
"SciencesServer/app/basic/config"
"encoding/json"
)
// TechnologyProduct 技术产品数据模型
type TechnologyProduct struct {
Model
ModelTenant
Local
MUid uint64 `gorm:"column:m_uid;type:int;default:0;comment:用户manage_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"`
Material string `gorm:"column:material;type:varchar(255);default:null;comment:证明材料" json:"material"`
Industry string `gorm:"column:industry;type:varchar(255);default:null;comment:所属领域" json:"industry"`
Customer string `gorm:"column:customer;type:varchar(255);default:null;comment:应用客户" json:"-"`
Maturity config.TechnologyMaturity `gorm:"column:maturity;type:tinyint(1);default:0;comment:技术成熟度" json:"maturity"`
LeadStandard TechnologyProductLeadStandard `gorm:"column:lead_standard;type:tinyint(1);default:0;comment:领先标准" json:"lead_standard"`
CooperationMode config.TechnologyCooperationMode `gorm:"column:cooperation_mode;type:tinyint(1);default:0;comment:合作模式" json:"cooperation_mode"`
Keyword string `gorm:"column:keyword;type:varchar(255);default:null;comment:关键词" json:"-"`
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
ShelfStatus
Status TechnologyProductStatus `gorm:"column:status;type:tinyint(1);default:0;comment:状态" json:"status"`
ModelDeleted
ModelAt
}
// TechnologyProductLeadStandard 领先标准
type TechnologyProductLeadStandard int
const (
// TechnologyProductLeadStandardForDomesticXJ 国内先进
TechnologyProductLeadStandardForDomesticXJ TechnologyProductLeadStandard = iota + 1
// TechnologyProductLeadStandardForDomesticLX 国内领先
TechnologyProductLeadStandardForDomesticLX
// TechnologyProductLeadStandardForInternationalXJ 国际先进
TechnologyProductLeadStandardForInternationalXJ
// TechnologyProductLeadStandardForInternationalLX 国际领先
TechnologyProductLeadStandardForInternationalLX
)
// TechnologyProductStatus 状态
type TechnologyProductStatus int
const (
// TechnologyProductStatusForDraft 草稿箱
TechnologyProductStatusForDraft TechnologyProductStatus = iota
// TechnologyProductStatusForExamining 审核中
TechnologyProductStatusForExamining
// TechnologyProductStatusForAgree 审核通过
TechnologyProductStatusForAgree
// TechnologyProductStatusForRefuse 审核拒绝
TechnologyProductStatusForRefuse
)
// TechnologyProductShelfStatus 上下架状态
type TechnologyProductShelfStatus int
const (
// TechnologyProductShelfStatusForUp 上架
TechnologyProductShelfStatusForUp TechnologyProductShelfStatus = iota + 1
// TechnologyProductShelfStatusForDown 下架
TechnologyProductShelfStatusForDown
)
func (m *TechnologyProduct) TableName() string {
return "technology_product"
}
func (m *TechnologyProduct) GetIndustryAttribute() []string {
out := make([]string, 0)
_ = json.Unmarshal([]byte(m.Industry), &out)
return out
}
func (m *TechnologyProduct) SetIndustryAttribute(value []string) {
_bytes, _ := json.Marshal(value)
m.Industry = string(_bytes)
}
func (m *TechnologyProduct) GetCustomerAttribute() []string {
out := make([]string, 0)
_ = json.Unmarshal([]byte(m.Customer), &out)
return out
}
func (m *TechnologyProduct) SetCustomerAttribute(value []string) {
_bytes, _ := json.Marshal(value)
m.Customer = string(_bytes)
}
func (m *TechnologyProduct) GetKeywordAttribute() []string {
out := make([]string, 0)
_ = json.Unmarshal([]byte(m.Keyword), &out)
return out
}
func (m *TechnologyProduct) SetKeywordAttribute(value []string) {
_bytes, _ := json.Marshal(value)
m.Keyword = string(_bytes)
}
func NewTechnologyProduct() *TechnologyProduct {
return &TechnologyProduct{}
}

View File

@ -0,0 +1,18 @@
package model
// UserConsume 用户资产消耗
type UserConsume struct {
Model
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
Source int `json:"source"`
ModelDeleted
ModelAt
}
func (m *UserConsume) TableName() string {
return "user_consume"
}
func NewUserConsume() *UserConsume {
return &UserConsume{}
}

View File

@ -0,0 +1,19 @@
package model
// UserPatent 用户专利信息数据模型
type UserPatent struct {
Model
Local
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户uuid" json:"-"`
PatentID uint64 `gorm:"column:patent_id;type:int(11);default:0;comment:专利ID" json:"-"`
ModelDeleted
ModelAt
}
func (m *UserPatent) TableName() string {
return "user_patent"
}
func NewUserPatent() *UserPatent {
return &UserPatent{}
}