m'yBatis之巧用Map

myba'ti's可以用Map作为parameterType,或者resultType

   


//直接封装到map中,key就是id,text,(查出来的列名)
List<Map>mapList=userMapper.findBrandList();


<select id="findBrandList" resultType="map">
  SELECT id,name as text from tb_brand
</select>

  @Override
    public void deleteLuoJi(Long[] ids, String flag) {
        for (Long id : ids) {
            Map map=new HashMap();
            map.put("id",id);
            map.put("flag",flag);
            goodsMapper.deleteLuoJi(map);
        }
    }


 <update id="deleteLuoJi" parameterType="map">
     UPDATE tb_goods set is_delete=#{flag} where id=#{id}
  </update>

猜你喜欢

转载自blog.csdn.net/hlz5857475/article/details/81123329