package com.engine.htsc.jjhyy.web;


import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.jjhyy.service.JjhyybaseService;
import com.engine.htsc.jjhyy.service.impl.JjhyybaseServiceImpl;

import weaver.general.BaseBean;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.interfaces.htsc.GlobatTools.JAVATools;

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;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName JjhyySealBaseAction.java
 * @createTime 2022年03月18日 17:07:00
 */
public class JjhyySealBaseAction {

    private JjhyybaseService jjhyyBaseService= ServiceUtil.getService(JjhyybaseServiceImpl.class);

    @POST
    @Path("/getwkdoneuser")
    @Produces({MediaType.TEXT_PLAIN})
    public String getwkyygldoneuser(@Context HttpServletRequest request, @Context HttpServletResponse response){
        JAVATools.SetCmdwritelog("-------------JjhyySealAction.getwkyygldoneuser-------------");
        User user = HrmUserVarify.getUser(request, response);
        boolean flag=jjhyyBaseService.getwkyygldoneuser(user,ParamUtil.request2Map(request));
        if(flag){
            return JAVATools.Apiretrun("200",true);
        }else{
            return JAVATools.Apiretrun("400",false);
        }
    }
    @POST
    @Path("/getsealname")
    @Produces({MediaType.TEXT_PLAIN})
    public String getsealname(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        BaseBean bs = new BaseBean();
        Map<String, Object> retmap = new HashMap<String, Object>();
        bs.writeLog("----sealApplication-----");
        try {
            User user = HrmUserVarify.getUser(request, response);
            retmap = jjhyyBaseService.getsealname(user, ParamUtil.request2Map(request));
        } catch (Exception e) {

            return JAVATools.Apiretrun("400", "error");
        }

        return JAVATools.Apiretrun("200", new JSONObject(retmap));
    }


    @POST
    @Path("/getOtherReadUser")
    @Produces({MediaType.TEXT_PLAIN})
    public String getOtherReadUser(@Context HttpServletRequest request, @Context HttpServletResponse response){
        JAVATools.SetCmdwritelog("-------------getOtherReadUSer.getwkyygldoneuser-------------");
        User user = HrmUserVarify.getUser(request, response);
        JSONObject jsonObject=jjhyyBaseService.getOtherReadUser(user,ParamUtil.request2Map(request));
        if(jsonObject!=null){
            return JAVATools.Apiretrun("200",jsonObject);
        }else{
            return JAVATools.Apiretrun("400",false);
        }
    }
}
