package com.cab.controller;

import com.cab.service.ShareServiceImpl;
import com.cku.core.RESTResponse;
import com.cku.core.ZAException;
import com.cku.util.PageBean;
import com.cku.util.ServletUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by user on 2016/5/5.
 */
@Controller
@RequestMapping("share")
public class ShareController {
    @Autowired
    private ShareServiceImpl shareService;

    @RequestMapping("/getShare")
    public void getShare(HttpServletRequest request, HttpServletResponse response) throws IOException {
        RESTResponse result = null;
        try {
            Long id = ServletUtils.getParameterLong(request,"id");
            PageBean pb = ServletUtils.getParameterBean(request);
            Object obj = shareService.getShare(id,pb);
            result = new RESTResponse("items", obj);
        } catch (ZAException e ) {
            result = new RESTResponse(e);
        }
        ServletUtils.writeResponse(response,result);
    }
}
