代码拉取完成,页面将自动刷新
package xt
import (
"github.com/lixh00/xt/utils"
"testing"
)
type User struct {
Id uint `json:"id" gorm:"primary_key"`
Name string `json:"name" form:"type:varchar(20);not null;comment:'姓名'"`
Age int `json:"age" gorm:"type:tinyint(3);default:1;not null;comment:'年龄'"`
}
func (User) TableName() string {
return "test_user"
}
type UserInfo struct {
Id uint `json:"id" gorm:"primary_key"`
Sex string `json:"sex" form:"type:varchar(20);not null;comment:'姓名'"`
Avatar int `json:"avatar" gorm:"type:tinyint(3);default:1;not null;comment:'年龄'"`
}
func (UserInfo) TableName() string {
return "test_user_info"
}
func getDBS() []DatabaseClientInfo {
var dbs []DatabaseClientInfo
dbs = append(dbs, DatabaseClientInfo{
TenantId: "1",
Info: TenantInfo{
Name: "李寻欢测试",
ShortName: "测试",
Logo: "",
TypeCode: "school",
},
Host: "10.11.0.10",
Port: 3307,
User: "saas",
Password: "saas123",
Db: "saas_hsxl",
})
return dbs
}
func TestSyncModels(t *testing.T) {
_ = AddModel(User{})
_ = AddModel(UserInfo{})
//DisableSyncModels(true)
SetSyncModelsAsync(true)
err := Init(getDBS, nil, true)
if err != nil {
return
}
_, err = GetByTenantId("1")
if err != nil {
return
}
t.Log("成功")
}
// 更新租户信息
func TestSyncTenantInfo(t *testing.T) {
inIds := []uint{1, 2, 3}
newIds := []uint{1, 2, 4}
needClearIds := utils.Difference(inIds, newIds)
t.Logf("需要清理的Id: %v", needClearIds)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。