控制层:
/**
* 产品下架
*/
@RequestMapping(value = "/shelfDown", method = RequestMethod.POST )
public @ResponseBody Bean shelfDown(Integer[] ids) {
int result = zgoodsService.shelfDown(ids);
if (result > 0) {
return new Bean("1", "OK", "下架成功");
} else {
return null;
}
}mybatis:
<!-- 产品下架 -->
<update id="shelfDown" parameterType="Integer[]">
update z_goods set shelf = 1
<where>
id
<foreach collection="array" item="id" open="in (" close=")"
separator=",">
#{id}
</foreach>
</where>
</update>
本文介绍了一个简单的RESTful API设计,用于实现批量下架产品的功能。通过POST请求发送产品ID数组,更新数据库中对应产品的上架状态。文章展示了Controller层的实现逻辑及MyBatis的映射文件。
5547





