46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package test
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"ifms/internal/mods/trace/dal"
|
||
"ifms/internal/mods/trace/schema"
|
||
"ifms/internal/wirex"
|
||
"testing"
|
||
"time"
|
||
)
|
||
|
||
func TestPlan(t *testing.T) {
|
||
|
||
db, _, err := wirex.InitDB(context.Background())
|
||
if err != nil {
|
||
fmt.Println(err)
|
||
return
|
||
}
|
||
plan := dal.BreedingPlan{DB: db}
|
||
|
||
param := schema.BreedingPlanForm{BreedingVariety: "test", FishSource: "test", FishStage: "test"}
|
||
|
||
list, err := plan.QueryList(context.Background(), param)
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
fmt.Println(len(list))
|
||
}
|
||
|
||
func TestBatchNum(t *testing.T) {
|
||
var todayList []dal.BreedingPlan
|
||
i := len(todayList)
|
||
// 获取当前时间
|
||
now := time.Now()
|
||
// 格式化年份为两位数(例如 2025 -> 25)
|
||
year := now.Year() % 100
|
||
yearStr := fmt.Sprintf("%02d", year)
|
||
// 格式化日期为 "0406" 的格式
|
||
dateStr := now.Format("0102")
|
||
// 格式化序号为两位数
|
||
sequenceStr := fmt.Sprintf("%02d", i+1)
|
||
// 拼接最终的字符串
|
||
fmt.Println(fmt.Sprintf("%s年%s%s%s批", yearStr, "鲈鱼", dateStr, sequenceStr))
|
||
}
|