package com.engine.htxc.eseal.web;


import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htxc.eseal.service.impl.EsealServiceImpl;
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;

/**
 * <p>送用印流程入口</p>
 * @author K1810015
 * @version 1.0.0
 * @ClassName esealAction.java
 * @createTime 2022年06月16日 11:41:00
 * @REMARK
 */
public class EsealAction {

    private EsealServiceImpl esealService=ServiceUtil.getService(EsealServiceImpl.class);

    /**
     * <p>合同流程送eseal关联</p>
     * @title sendeseal
     * @author K1810015
     * @updateTime 2022/9/13 10:11
     */
    @POST
    @Path("/sendeseal")
    @Produces(MediaType.TEXT_PLAIN)
    public String sendeseal(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        try {
            User user = HrmUserVarify.getUser(request, response);
            return esealService.sendcontracteseal(ParamUtil.request2Map(request), user);
        } catch (Exception e) {
            return JAVATools.Apiretrun("400", "error");
        }
        //数据转换
    }

    /**
     * <p>查询eseal名称</p>
     * @title getsealname
     * @author K1810015
     * @updateTime 2022/9/13 10:12
     */
    @POST
    @Path("/getsealname")
    @Produces({MediaType.TEXT_PLAIN})
    public String getsealname(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        Map<String, Object> retmap = new HashMap<String, Object>(1);
        JAVATools.SetCmdwritelog("----getsealname-----");
        try {
            User user = HrmUserVarify.getUser(request, response);
            retmap = esealService.getsealname(ParamUtil.request2Map(request),user);
        } catch (Exception e) {
            return JAVATools.Apiretrun("400", "error");
        }
        return JAVATools.Apiretrun("200", new JSONObject(retmap));
    }



}
