feat:增加专利模型数据
This commit is contained in:
@ -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()},
|
||||
|
@ -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
|
||||
|
@ -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())
|
||||
|
||||
|
55
app/common/model/sys_patent.go
Normal file
55
app/common/model/sys_patent.go
Normal 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{}
|
||||
}
|
108
app/common/model/technology_prodcut.go
Normal file
108
app/common/model/technology_prodcut.go
Normal 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{}
|
||||
}
|
18
app/common/model/user_consume.go
Normal file
18
app/common/model/user_consume.go
Normal 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{}
|
||||
}
|
19
app/common/model/user_patent.go
Normal file
19
app/common/model/user_patent.go
Normal 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{}
|
||||
}
|
Reference in New Issue
Block a user