refactor(animals): 优化动物名称模糊查询逻辑
- 在 AnimalsCurd 的 ShowByName 方法中,保留了原有的名称模糊查询逻辑 - 在 AnimalWithNickNameHit 结构中,添加了注释解释模糊查询的实现方式 - 此修改旨在提高代码的可读性和可维护性,避免使用复杂的 SQL 查询
This commit is contained in:
parent
c018a63cd3
commit
75f2b9e59b
@ -104,7 +104,7 @@ func (a *AnimalsCurd) ShowByName(attrs string, name string) (temp []model.Animal
|
||||
for _, animal := range animals {
|
||||
animalWithNameHit := model.AnimalWithNickNameHit{
|
||||
Animal: animal,
|
||||
NickNameHit: !gorm_v2.IsLikePatternMatch(animal.Name, name), // 通过对比 name,然后取反。
|
||||
NickNameHit: !gorm_v2.IsLikePatternMatch(animal.Name, name), // 通过对比 name,然后取反;主要是不想让 SQL 过于复杂,、处理起来也麻烦。
|
||||
}
|
||||
temp = append(temp, animalWithNameHit)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user