feat:优化项目信息

This commit is contained in:
henry
2022-02-09 17:35:31 +08:00
parent 2d8be509b7
commit 56e8243724
15 changed files with 357 additions and 54 deletions

View File

@ -48,7 +48,7 @@ func mysql() *gorm.DB {
orm.WithMaxOpenConns(2000),
orm.WithMaxLifetime(1000),
orm.WithMysqlOption(&logic.Mysql{
Username: "appuser", Password: "ABCabc01!", Host: "192.168.0.188", Port: 3306,
Username: "appuser", Password: "ABCabc01", Host: "192.168.0.188", Port: 3306,
Database: "sciences", Parameters: "charset=utf8mb4,utf8&parseTime=True&loc=Local",
}),
).Init()
@ -129,7 +129,6 @@ func TestRecoveryPatent(t *testing.T) {
Description: filter(v.Description),
PrincipalClaim: filter(v.PrincipalClaim),
IPCCode: v.IPCCode,
Shelf: Shelf{ShelfStatus: 1},
ModelAt: ModelAt{
CreatedAt: now, UpdatedAt: now,
},
@ -146,6 +145,48 @@ func TestRecoveryPatent(t *testing.T) {
}
}
func TestB(t *testing.T) {
page := 1
mysql := mysql()
mTechnologyPatent := new(TechnologyPatent)
limit := 100
out := make([]*TechnologyPatent, 0)
for {
err := mysql.Table(mTechnologyPatent.TableName()).Select("id", "apply_code", "apply_at", "open_code",
"apply_name", "inventor").
Offset((page - 1) * limit).Limit(limit).
Scan(&out).Error
if err != nil {
t.Log(err)
return
}
if len(out) <= 0 {
t.Log("执行结束")
return
}
for _, v := range out {
if err = mysql.Table(mTechnologyPatent.TableName()).Where("id = ?", v.ID).Updates(map[string]interface{}{
"apply_code": strings.TrimLeft(v.ApplyCode, " "),
"apply_at": strings.TrimLeft(v.ApplyAt, " "),
"open_code": strings.TrimLeft(v.OpenCode, " "),
"apply_name": strings.Join(strings.Split(v.ApplyName, ";"), ","),
"inventor": strings.Join(strings.Split(v.Inventor, ";"), ","),
}).Error; err != nil {
t.Error("Mysql" + err.Error())
return
}
}
page++
out = make([]*TechnologyPatent, 0)
}
}
func TestA(t *testing.T) {
return
mysql := mysql()