package com.engine.htsc.seal.web;


import com.alibaba.fastjson.JSON;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.seal.service.UnionSealApplicationService;
import weaver.general.BaseBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;

public class UnionSealApplicationAction {

    UnionSealApplicationService getService() {
        return ServiceUtil.getService(UnionSealApplicationService.class);
    }

    @POST
    @Path("/getYzgly")
    @Produces({MediaType.TEXT_PLAIN})
    public String getYzgly(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bs = new BaseBean();
        Map<String, Object> apidatas = new HashMap<String, Object>();
        bs.writeLog("----UnionSealApplicationAction-----");
        try{
            String yz = request.getParameter("yz");
            String dzyy = request.getParameter("dzyy");

            UnionSealApplicationService service = getService();
            apidatas = service.getYzgly(yz,dzyy);
        }catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }

        return JSON.toJSONString(apidatas);
    }

    @POST
    @Path("/getPassUser")
    @Produces({MediaType.TEXT_PLAIN})
    public String getPassUser(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bs = new BaseBean();
        Map<String, Object> apidatas = new HashMap<String, Object>();
        bs.writeLog("----UnionSealApplicationAction-----");
        try{
            String requestid = request.getParameter("requestid");

            UnionSealApplicationService service = getService();
            apidatas = service.getPassUser(requestid);
        }catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }

        return JSON.toJSONString(apidatas);
    }

    @POST
    @Path("/noticeSignDeptCoDirector")
    @Produces({MediaType.TEXT_PLAIN})
    public String noticeSignDeptCoDirector(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bs = new BaseBean();
        Map<String, Object> apidatas = new HashMap<String, Object>();
        bs.writeLog("----UnionSealApplicationAction-----");
        try{
            String requestid = request.getParameter("requestid");
            String nodeid = request.getParameter("nodeid");
            String deptid = request.getParameter("deptid");

            UnionSealApplicationService service = getService();
            apidatas = service.noticeSignDeptCoDirector(requestid,nodeid,deptid);
        }catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }

        return JSON.toJSONString(apidatas);
    }

    @POST
    @Path("/checkCoDirectorNotice")
    @Produces({MediaType.TEXT_PLAIN})
    public String checkCoDirectorNotice(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bs = new BaseBean();
        Map<String, Object> apidatas = new HashMap<String, Object>();
        bs.writeLog("----UnionSealApplicationAction-----");
        try{
            String requestid = request.getParameter("requestid");
            String nodename = request.getParameter("nodename");

            UnionSealApplicationService service = getService();
            apidatas = service.checkCoDirectorNotice(requestid,nodename);
        }catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }

        return JSON.toJSONString(apidatas);
    }
}
