利用map格式参数传值,接收拼接sql语句

更新时间:2023-05-19 07:12:45 阅读: 评论:0

利⽤map格式参数传值,接收拼接sql语句通过将值存⼊map
@RequestMapping(value="/list", method = RequestMethod.POST)
@ResponBody
public Map<String, Object> list(HttpServletRequest request) throws Throwable {
String pageNo = Parameter("pager.pageNo");
String pageSize = Parameter("pager.pageSize");
Map<String, Object> map = new HashMap<String, Object>();
String product_name = Parameter("product_name");
if(product_name!=null && !"null".equals(product_name) && !"".equals(product_name)){
map.put("product_name like", "%" + product_name + "%");
}
String basic_ller_name = Parameter("basic_ller_name");
if(basic_ller_name!=null && !"null".equals(basic_ller_name) && !"".equals(basic_ller_name)){
map.put("basic_ller_name like", "%" + basic_ller_name + "%");
容易的近义词}
List<Map<String, Object>> list = productService.findViewByMapPage(map, Integer.parInt(pageNo), Integer.parInt(pageSize));  int total = productService.findViewByMapCount(map);
// 页⾯需要显⽰的列名
String[] column = {
"product_id",
durex是什么意思"product_name",
"product_specifications",
"product_short_name",
"product_unit_name",
"basic_ller_name",
"product_sort_name",
"product_brand_name",
"product_image",
"product_origin",
"product_manufacturer",
"product_pinyin",
"product_ll_stop",
"product_buyer_stop",
"product_minus_stock",
时代周刊
"product_barcode_number",
"product_update",
};
return Public.listTojson(list, column, pageNo, pageSize, total);墨西哥世界杯
}
sql语句拼接利⽤迭代器将map循环
public List<Map<String, Object>> findViewByMapPage(Map<String, Object> map,
parallelsint pageNo, int pageSize) {
road manStringBuffer sql = new StringBuffer("lect * from " + TableName.product_view);
Iterator it = Set().iterator();
Object object[] = new Object[map.size()];
int i = 0;乌拉圭回合
if (map.size() > 0) {
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String key = Key().toString();
Object value = Value();
if (i==0) {
sql.append(" where " + key + " ?");
object[i] = value;
} el if (i==1){
sql.append(" and " + key + " ?");
object[i] = value;
}
i++;
}
}
sql.append(" order by product_id desc");
return baDao.String(), object, this.findViewByMapCount(map), pageNo, pageSize, ProductServiceImpl.class); }
或者sql
public List<Map<String, Object>> findViewByMapPage(Map<String, Object> map,
int pageNo, int pageSize) {
StringBuffer sql = new StringBuffer("lect * from " + TableName.product_view);
Iterator it = Set().iterator();
Object[] object = new Object[map.size()];
int i = 0;
if (map.size() > 0) {
while (it.hasNext()) {
trevalMap.Entry entry = (Map.Entry) it.next();
String key = Key().toString();
Object value = Value();
sql.append(" where " + key + " ?");
object[i] = value;
bottledi++;
}
}
txusql.append(" order by product_id desc");
return baDao.String(), object, this.findViewByMapCount(map), pageNo, pageSize, ProductServiceImpl.class); }

本文发布于:2023-05-19 07:12:45,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/691570.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:拼接   语句   接收   需要   回合
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图