商品上下架功能

后台上下架功能

后台实现上架,下架功能

代码演示:

dao类


    //    改变书籍上架下架状态
    public int editState(Book book) throws Exception {
        String sql = "update t_easyui_book set state = ? where id = ?";
        return super.executeUpdate(sql, book, new String[]{"state", "id"});
    }

action类

  //    上架
    public String shangjia(HttpServletRequest request, HttpServletResponse response) {
        try {
            int res = this.bookDao.editState(book);
            ResponseUtil.writeJson(response, res);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }

    //    下架
    public String xiajia(HttpServletRequest request, HttpServletResponse response) {
        try {
            int res = this.bookDao.editState(book);
            ResponseUtil.writeJson(response, res);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

结果展示:

上架
商品上下架功能_第1张图片
下架
商品上下架功能_第2张图片

你可能感兴趣的:(商品上下架功能)