You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
package main
|
|
|
|
import (
|
|
"dsBaseRpc/Utils/CommonUtil"
|
|
"dsBaseRpc/Utils/DbUtil"
|
|
"dsBaseRpc/models"
|
|
"fmt"
|
|
)
|
|
|
|
var db = DbUtil.Engine
|
|
|
|
func main() {
|
|
//1、清空人员部门关系表
|
|
sql := `truncate table t_base_teacher_org`
|
|
db.SQL(sql).Execute()
|
|
|
|
//2、插入人员部门关系表
|
|
sql = `select * from t_base_teacher`
|
|
list, _ := db.SQL(sql).Query().List()
|
|
|
|
for i := range list {
|
|
var model models.TBaseTeacherOrg
|
|
model.Id = CommonUtil.GetUUID()
|
|
model.BureauId = list[i]["bureau_id"].(string)
|
|
model.OrgId = list[i]["org_id"].(string)
|
|
model.PersonId = list[i]["person_id"].(string)
|
|
model.SortId = int32(list[i]["sort_id"].(int64))
|
|
model.IsMain = 1
|
|
model.ProvinceCode = list[i]["province_code"].(string)
|
|
model.CityCode = list[i]["city_code"].(string)
|
|
model.DistrictCode = list[i]["district_code"].(string)
|
|
if list[i]["mainschool_id"] != nil {
|
|
model.MainSchoolId = list[i]["mainschool_id"].(string)
|
|
}
|
|
model.BUse = int32(list[i]["b_use"].(int64))
|
|
_,err:=db.Insert(model)
|
|
if err!=nil{
|
|
fmt.Println("发生致命错误:"+err.Error())
|
|
panic(err)
|
|
}
|
|
}
|
|
fmt.Println("恭喜,数据迁移成功完成!")
|
|
}
|