feat:完善信息
This commit is contained in:
@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@ -12,6 +13,7 @@ import (
|
||||
// IModel
|
||||
type IModel interface {
|
||||
GetID() uint64
|
||||
GetEncodeID() string
|
||||
TableName() string
|
||||
SetDatabase(database string, key ...string)
|
||||
}
|
||||
@ -66,6 +68,10 @@ func (m *Model) GetID() uint64 {
|
||||
return m.ID
|
||||
}
|
||||
|
||||
func (m *Model) GetEncodeID() string {
|
||||
return utils.HASHIDEncode(int(m.ID))
|
||||
}
|
||||
|
||||
func (m *Model) SetDatabase(database string, key ...string) {
|
||||
m.Database = database + "_" + strings.Join(key, "_")
|
||||
}
|
||||
|
4
app/common/model/technology_instance.go
Normal file
4
app/common/model/technology_instance.go
Normal file
@ -0,0 +1,4 @@
|
||||
package model
|
||||
|
||||
type TechnologyInstance struct {
|
||||
}
|
40
app/common/model/technology_paper.go
Normal file
40
app/common/model/technology_paper.go
Normal file
@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"SciencesServer/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TechnologyPaper 科技论文数据模型
|
||||
type TechnologyPaper struct {
|
||||
Model
|
||||
ModelTenant
|
||||
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"`
|
||||
Ext string `gorm:"column:ext;type:varchar(30);default:null;comment:引用格式" json:"ext"`
|
||||
Author string `gorm:"column:author;type:varchar(100);default:null;comment:作者" json:"author"`
|
||||
PublishAt time.Time `gorm:"column:publish_at;type:datetime;not null;comment:出版日期" json:"publish_at"`
|
||||
Keyword string `gorm:"column:keyword;type:varchar(100);default:null;comment:关键词" json:"keyword"`
|
||||
Tag string `gorm:"column:tags;type:varchar(255);default:null;comment:标签" json:"-"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);default:null;comment:备注" json:"remark"`
|
||||
ModelDeleted
|
||||
ModelAt
|
||||
}
|
||||
|
||||
func (m *TechnologyPaper) TableName() string {
|
||||
return m.NewTableName("technology_paper")
|
||||
}
|
||||
|
||||
func (m *TechnologyPaper) GetTagAttribute() []string {
|
||||
tags := make([]string, 0)
|
||||
_ = utils.FromJSON(m.Tag, &tags)
|
||||
return tags
|
||||
}
|
||||
|
||||
func (m *TechnologyPaper) SetTagAttribute(tags []string) {
|
||||
m.Tag = utils.AnyToJSON(tags)
|
||||
}
|
||||
|
||||
func NewTechnologyPaper() *TechnologyPaper {
|
||||
return &TechnologyPaper{}
|
||||
}
|
Reference in New Issue
Block a user