fix: sql字符串拼接改为占位符形式,防sql注入

This commit is contained in:
meilin.huang
2022-10-31 18:39:52 +08:00
committed by 刘宗洋
parent f936331dff
commit 74e5ee41fb
7 changed files with 39 additions and 20 deletions

View File

@@ -23,11 +23,14 @@ func (d *mongoRepoImpl) GetList(condition *entity.MongoQuery, pageParam *model.P
if len(condition.TagIds) > 0 {
sql = sql + " AND d.tag_id IN " + fmt.Sprintf("(%s)", strings.Join(utils.NumberArr2StrArr(condition.TagIds), ","))
}
values := make([]interface{}, 0)
if condition.TagPathLike != "" {
sql = sql + " AND d.tag_path LIKE '" + condition.TagPathLike + "%'"
values = append(values, condition.TagPathLike+"%")
sql = sql + " AND d.tag_path LIKE ?"
}
sql = sql + " ORDER BY d.tag_path"
return model.GetPageBySql(sql, pageParam, toEntity)
return model.GetPageBySql(sql, pageParam, toEntity, values...)
}
func (d *mongoRepoImpl) Count(condition *entity.MongoQuery) int64 {