package com.engine.htsc.zhfw.web;

import com.engine.common.util.ServiceUtil;

import com.engine.htsc.zhfw.service.ComprehensiveArticleService;
import com.engine.htsc.zhfw.service.impl.ComprehensiveArticleServiceImpl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

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

public class ComprehensiveArticleAction {

    private Log log = LogFactory.getLog(this.getClass());
    private ComprehensiveArticleService getService(User user){
        return ServiceUtil.getService(ComprehensiveArticleServiceImpl.class,user);
    }

    private ComprehensiveArticleService getService(){
        return ServiceUtil.getService(ComprehensiveArticleServiceImpl.class);
    }



    /**
     *
     * @param request
     * @param response
     * @return
     */
    @GET
    @Path("/examApproval")
    @Produces({MediaType.APPLICATION_JSON})
    public Map<String,Object> examApproval(@Context HttpServletRequest request,
                                              @Context HttpServletResponse response,
                                              @QueryParam("requestid") String requestid){
        Map<String, Object> apidatas = new HashMap<>();
        try {
            User user = HrmUserVarify.getUser(request, response);
            apidatas = this.getService(user).examApproval(requestid);
            apidatas.put("api_status", 1);
        }catch (Exception e){
            e.printStackTrace();
            apidatas.put("api_status",-1);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return apidatas;
    }
}
