不多说直接上代码!

接口:


public interface CommodityMapper {
int deleteByPrimaryKey(Integer productId); int insert(Commodity record); Commodity selectByPrimaryKey(Integer productId); List<Commodity> selectAll(); List<Commodity> getType(int id); int updateByPrimaryKey(Commodity record); int getCount(); List<Commodity> SearchCommodity(@Param("productName") String productName);//注意传参的名字必须要和Mapper文件一致 }
 

Constroller层:

 //搜索
@RequestMapping(path = "/search", method = RequestMethod.GET)
public ResponseEntity Search(String productName) {
if (commodityService.SearchCommodity(productName).size() != 0) {
return ResponseEntity.ok(commodityService.SearchCommodity(productName));
} else {
return ResponseEntity.ok("error");
} }

Mapper文件

    <select id="SearchCommodity"  resultType="string" resultMap="BaseResultMap">
select
c.product_id,
c.product_name,
c.product_content,
s.product_specs,
s.product_price,
d.product_simg
from commodity c
cross join Standard s
on c.product_id=s.product_id
cross join dommodityAttribute d
on c.product_id=d.product_id
where c.product_name like concat('%',#{productName},'%') group by c.product_id
</select>

最新文章

  1. asp.net MVC 通用登录验证模块
  2. [linux系统]查看内核版本和系统版本方法
  3. GEF: 图形拖拽处理
  4. MVVM架构~knockoutjs系列之扩展ajax验证~验证输入数据是否与后台数据相等
  5. ubuntu安装VNC、Xfce桌面
  6. SSH相关
  7. ACTIVITI 研究代码 之 模版模式
  8. OSG中的示例程序简介(转)
  9. HDU 1848 Fibonacci again and again
  10. Ubuntu Crontab
  11. shell 中最常使用的 FD (file descriptor)
  12. Csocket基本原理
  13. 记录一次JavaWeb开发的乱码解决
  14. linux 保存git的账号密码
  15. VS2012使用验证控件出现[ASP.NET]WebForms UnobtrusiveValidationMode 需要 &#39;jquery&#39; 的 ScriptResourceMapping。請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)。的解决办法。
  16. python-面向对象增强版
  17. Android开发之getX,getRawX,getWidth,getTranslationX等的区别
  18. intellij 快捷键整理
  19. flink 根据时间消费kafka
  20. fatal error LNK1104: 无法打开文件“libc.lib”的问题

热门文章

  1. 记:第一次更新服务器CUDA和GPU驱动
  2. C++代码审查
  3. H264 RTP包解析
  4. linux中忘记mysql用户root密码解决方案
  5. [pwnable.kr] - wtf
  6. JS的for循环包裹异步函数的问题
  7. win10系统中photoshop cs6中界面字体太小的解决方法
  8. Qt Creator的初步使用
  9. 【转】UBOOT——启动内核
  10. 表达式,数据类型和变量(Expressions,Data Types &amp; Variables)