feat:完善项目

This commit is contained in:
henry
2022-01-14 17:09:06 +08:00
parent cf68cfbd96
commit 9a41d7ff12
16 changed files with 646 additions and 38 deletions

View File

@ -225,6 +225,8 @@ func FirstWhere(model IModel, where ...*ModelWhere) (bool, error) {
for _, wo := range where {
db = db.Where(wo.Condition, wo.Value)
}
} else {
db = db.Where(fmt.Sprintf("%s = %d", FieldsForID, model.GetID()))
}
if db.Migrator().HasColumn(model, FieldsForDeleted) {
db = db.Where(FieldsForDeleted, DeleteStatusForNot)
@ -245,6 +247,8 @@ func FirstField(model IModel, fields []string, where ...*ModelWhere) (bool, erro
for _, wo := range where {
db = db.Where(wo.Condition, wo.Value)
}
} else {
db = db.Where(fmt.Sprintf("%s = %d", FieldsForID, model.GetID()))
}
if db.Migrator().HasColumn(model, FieldsForDeleted) {
db = db.Where(FieldsForDeleted, DeleteStatusForNot)

View File

@ -3,6 +3,7 @@ package model
// SysPatent 专利信息数据模型
type SysPatent struct {
Model
ModelTenant
Kind SysParentKind `gorm:"column:kind;index:idx_sys_patent_kind;type:tinyint(1);default:0;comment:专利类型" json:"kind"`
Title string `gorm:"column:title;type:varchar(100);default:'';comment:名称标题" json:"title"`
FileUrl string `gorm:"column:file_url;type:varchar(255);default:'';comment:文件地址" json:"file_url"`

View File

@ -1,8 +1,13 @@
package model
import (
"encoding/json"
)
// SysPatentClassify 专利分类信息数据模型
type SysPatentClassify struct {
Model
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"parent_id"`
IPC string `gorm:"column:ipc;type:varchar(18);default:'';comment:IPC主分类号" json:"ipc"`
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:行业领域" json:"-"`
IndustryDetail string `gorm:"column:industry_detail;type:varchar(255);default:'';comment:详细行业领域,包含父级领域信息" json:"industry_detail"`
@ -14,6 +19,28 @@ func (m *SysPatentClassify) TableName() string {
return "sys_patent_classify"
}
func (m *SysPatentClassify) GetIndustryAttribute() []string {
out := make([]string, 0)
_ = json.Unmarshal([]byte(m.Industry), &out)
return out
}
func (m *SysPatentClassify) SetIndustryAttribute(value []string) {
_bytes, _ := json.Marshal(value)
m.Industry = string(_bytes)
}
func (m *SysPatentClassify) GetIndustryDetailAttribute() []string {
out := make([]string, 0)
_ = json.Unmarshal([]byte(m.IndustryDetail), &out)
return out
}
func (m *SysPatentClassify) SetIndustryDetailAttribute(value []string) {
_bytes, _ := json.Marshal(value)
m.IndustryDetail = string(_bytes)
}
func NewSysPatentClassify() *SysPatentClassify {
return &SysPatentClassify{}
}

View File

@ -3,7 +3,6 @@ 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