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:
@@ -66,6 +66,30 @@ func TestProductHandler_CRUD(t *testing.T) {
|
||||
assert.Equal(t, float64(0), resp["total"].(float64))
|
||||
}
|
||||
|
||||
// 拼音搜索(原型口径:商品名 / 拼音 / 编码):List keyword 匹配 name_pinyin/name_initials
|
||||
func TestProductHandler_List_PinyinSearch(t *testing.T) {
|
||||
db := testutil.SetupTestDB()
|
||||
shop := testutil.CreateTestShop(db, "PROD_PY")
|
||||
user := testutil.CreateTestUser(db, shop.ID, "admin", "pass", "admin")
|
||||
token := getAuthToken(user.ID, shop.ID, "admin")
|
||||
r := setupProtectedRouter(db)
|
||||
|
||||
w := makeRequest(r, "POST", "/api/v1/products", token, map[string]interface{}{
|
||||
"name": "飞天茅台", "code": "MT-FT-500", "unit": "件",
|
||||
})
|
||||
require.Equal(t, http.StatusCreated, w.Code)
|
||||
|
||||
for kw, want := range map[string]float64{
|
||||
"feitian": 1, // 全拼
|
||||
"ftmt": 1, // 首字母
|
||||
"MT-FT": 1, // 编码
|
||||
"wuliang": 0,
|
||||
} {
|
||||
w := makeRequest(r, "GET", "/api/v1/products?keyword="+kw, token, nil)
|
||||
assert.Equal(t, want, parseResponse(w)["total"].(float64), "keyword=%s", kw)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProductHandler_HotelIsolation(t *testing.T) {
|
||||
db := testutil.SetupTestDB()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user