feat:完善项目信息

This commit is contained in:
henry
2022-01-05 16:09:55 +08:00
parent 822ced6041
commit 53c1f3912b
14 changed files with 352 additions and 922 deletions

View File

@ -4,6 +4,7 @@ import (
config2 "SciencesServer/app/basic/config"
"SciencesServer/app/common/model"
"SciencesServer/utils"
"fmt"
"gorm.io/gorm"
)
@ -22,12 +23,16 @@ type synchronized struct {
func (this *Instance) Handle() {
db := this.gormDB
successCount, failureCount := 0, 0
function := func(synchronized ...*synchronized) {
for _, v := range synchronized {
if !db.Migrator().HasTable(v.iModel) {
err := db.Migrator().CreateTable(v.iModel)
if err != nil {
panic(err)
successCount++
} else {
failureCount++
}
if v.iValues != nil && v.iValues() != nil {
db.Table(v.iModel.TableName()).Create(v.iValues())
@ -136,6 +141,7 @@ func (this *Instance) Handle() {
&synchronized{iModel: model.NewActivityInstance()}, &synchronized{iModel: model.NewActivityApply()},
&synchronized{iModel: model.NewActivityExamine()}, &synchronized{iModel: model.NewActivityJoin()},
)
fmt.Printf("========================\n=== 数据迁移,成功【%d】失败【%d】 ===\n========================\n", successCount, failureCount)
}
func WithGormDBOption(db *gorm.DB) Option {

View File

@ -1,21 +1,15 @@
package model
import "encoding/json"
// SysTenant 租户数据管理模型
type SysTenant struct {
Model
Key string `gorm:"column:key;type:varchar(30);default:'';comment:key" json:"key"`
ParentID uint64 `gorm:"column:parent_id;type:int;default:0;comment:父级ID" json:"-"`
Image
Name string `gorm:"column:name;type:varchar(30);default:'';comment:名称" json:"name"`
Code string `gorm:"column:code;type:varchar(30);default:'';comment:信用代码" json:"code"`
Images
Key string `gorm:"column:key;type:varchar(30);default:'';comment:key" json:"key"`
Name string `gorm:"column:name;type:varchar(30);default:'';comment:名称" json:"name"`
Contact string `gorm:"column:contact;type:varchar(30);default:'';comment:联系人" json:"contact"`
ContactMobile string `gorm:"column:contact_mobile;type:varchar(15);default:'';comment:联系方式" json:"contact_mobile"`
Area
Position string `gorm:"column:position;type:varchar(255);default:'';comment:坐标" json:"-"`
Industry string `gorm:"column:industry;type:varchar(255);default:'';comment:所属领域;行业信息" json:"-"`
Introduce string `gorm:"column:introduce;type:text;comment:介绍描述" json:"introduce"`
Config string `gorm:"column:config;type:varchar(255);default:'';comment:配置信息" json:"-"`
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注信息" json:"remark"`
Domain string `gorm:"column:domain;type:varchar(255);default:'';comment:domain" json:"域名地址"`
Remark string `gorm:"column:remark;type:varchar(255);default:'';comment:备注信息" json:"remark"`
ModelDeleted
ModelAt
}
@ -24,17 +18,6 @@ func (m *SysTenant) TableName() string {
return "sys_tenant"
}
func (m *SysTenant) GetIndustryAttribute() []string {
out := make([]string, 0)
_ = json.Unmarshal([]byte(m.Industry), &out)
return out
}
func (m *SysTenant) SetIndustryAttribute(value []string) {
_bytes, _ := json.Marshal(value)
m.Industry = string(_bytes)
}
func NewSysTenant() *SysTenant {
return &SysTenant{}
}