控制层中:

// 根据店家id查找图书,已售数量要大于等于1才显示
        List<SoldBook> sbList = shopService.getSoldBookByShopidAndBookName(
                shopid, bname);

服务层中:

//通过搜索图书名重载数据表格
    public List<SoldBook> getSoldBookByShopidAndBookName(int shopid,
            String bname) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("sid", shopid);
        map.put("bname", bname);
        List<Book> books = bookMapper.getSoldBookByShopidAndBookName(map);
        ArrayList<SoldBook> list = new ArrayList<SoldBook>();}

mapper.xml中:

<!-- 通过搜索图书名得到销售数量大于0的指定店家的图书数据 -->
           <!-- 其中hashmap是mybatis自己配置好的,用来传递多个不同类型的参数 -->
           <!-- 模糊查询要这样写:b.longname like concat(concat('%',#{bname}),'%') -->
    <select id="getSoldBookByShopidAndBookName" parameterType="java.util.HashMap" resultMap="BookWithPicAndShopResultMap">
    select
    <include refid="BookWithPicAndShop_Column_List" />
    from t_book b, t_shop s, t_picture p, t_categorytwo c
    where b.shopid = s.shopid 
    and b.picid = p.picid
    and b.pass = "通过"
    and b.categoryid = c.twoid
    and b.sold > 0
    and s.shopid = #{sid, jdbcType=INTEGER}
    and b.longname like concat(concat('%',#{bname}),'%')
   </select>

 

相关文章:

  • 2021-07-10
  • 2021-09-01
  • 2022-02-11
  • 2022-12-23
  • 2021-10-02
  • 2021-08-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2023-04-08
  • 2021-12-03
  • 2021-06-02
  • 2022-01-06
  • 2022-02-20
相关资源
相似解决方案