feat(backend): 出入库编码搜索双路匹配+建单填快照;finance 趋势/日期区间;partner/product 拼音搜索
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
This commit is contained in:
@@ -205,6 +205,33 @@ func TestPartnerHandler_List_KeywordSearch(t *testing.T) {
|
||||
assert.Equal(t, float64(0), resp["total"].(float64))
|
||||
}
|
||||
|
||||
// 拼音/联系人搜索(原型口径:名称 / 拼音 / 联系人):Create 时自动生成拼音列
|
||||
func TestPartnerHandler_List_PinyinAndContactSearch(t *testing.T) {
|
||||
db := testutil.SetupTestDB()
|
||||
shop := testutil.CreateTestShop(db, "PT006B")
|
||||
user := testutil.CreateTestUser(db, shop.ID, "admin", "pass", "admin")
|
||||
token := getAuthToken(user.ID, shop.ID, "admin")
|
||||
r := setupProtectedRouter(db)
|
||||
|
||||
makeRequest(r, "POST", "/api/v1/partners", token, map[string]interface{}{
|
||||
"name": "茅台华东总代", "type": "supplier", "contact": "张伟",
|
||||
})
|
||||
makeRequest(r, "POST", "/api/v1/partners", token, map[string]interface{}{
|
||||
"name": "鼎丰超市", "type": "customer", "contact": "王芳",
|
||||
})
|
||||
|
||||
for kw, want := range map[string]float64{
|
||||
"maotai": 1, // 全拼
|
||||
"mthdzd": 1, // 首字母
|
||||
"张伟": 1, // 联系人
|
||||
"dingfeng": 1,
|
||||
"buxiang": 0,
|
||||
} {
|
||||
w := makeRequest(r, "GET", "/api/v1/partners?keyword="+kw, token, nil)
|
||||
assert.Equal(t, want, parseResponse(w)["total"].(float64), "keyword=%s", kw)
|
||||
}
|
||||
}
|
||||
|
||||
// 下拉需一次取全部:请求大页(>默认 20)应返回全部,而非被 ValidatePageSize
|
||||
// 回退到默认 20(超上限即返回默认值的历史坑)。
|
||||
func TestPartnerHandler_List_LargePageSizeReturnsAll(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user