package com.engine.htsc.Signet;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import org.apache.tools.ant.taskdefs.WaitFor;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
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.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 GetImagefileid {

    @POST
    @Path("/GetImagefileid")
    @Produces({MediaType.TEXT_PLAIN})
    public String GetImagefileid(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        Map<String, Object> apidatas = new HashMap<>();
        try {
            String docid=request.getParameter("docid");
            String imagefileid="";
            RecordSet rs=new RecordSet();
            String sql=" select imagefileid from (select imagefileid from docimagefile where docid in (?) order by versionid  desc) t\n" +
                    " where rownum<=1";
            rs.executeQuery(sql,docid);
            if(rs.next()){
                imagefileid= rs.getString("imagefileid");
            }
            if(!"".equals(imagefileid)){
                apidatas.put("data", imagefileid);
                apidatas.put("status", true);
            }else{
                apidatas.put("data", false);
                apidatas.put("status", "error");
            }

        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("status", false);
            apidatas.put("errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);
    }

    }
