fix(csmanualentry): 编号搜索支持匹配带后缀的变体编号

- 按编号查询时同时命中本体与 -、/ 后缀变体(如 202611060124-0、202611060070/1)
- 补充变体匹配回归测试
This commit is contained in:
yml2213
2026-11-06 14:46:07 +08:00
parent e027f88fbb
commit ee08e343f4
3 changed files with 59 additions and 3 deletions
@@ -114,9 +114,17 @@ func (r *Repository) List(ctx context.Context, query ListQuery) (*PaginatedResul
db := r.db.WithContext(ctx).Model(&model.CSManualEntry{})
countDB := r.db.WithContext(ctx).Model(&model.CSManualEntry{})
// 编号查询:精确匹配该编号,并同时展示其带后缀的变体(如 202611060124-0、202611060124/1)。
if query.EntryNo != "" {
db = db.Where("entry_no = ?", query.EntryNo)
countDB = countDB.Where("entry_no = ?", query.EntryNo)
base := query.EntryNo
dashVariant := base + "-%"
slashVariant := base + "/%"
cond := r.db.Where(
"entry_no = ? OR entry_no LIKE ? OR entry_no LIKE ?",
base, dashVariant, slashVariant,
)
db = db.Where(cond)
countDB = countDB.Where(cond)
}
if query.EntryGroup != "" {
db = db.Where("entry_group = ?", query.EntryGroup)