package com.engine.htsc.mail.web;

import com.alibaba.fastjson.JSON;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.mail.service.MailService;
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 MailAction {

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

    @POST
    @Path("/getUserInfo")
    @Produces({MediaType.TEXT_PLAIN})
    public String getUserInfo(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bs = new BaseBean();
        Map<String, Object> apidatas = new HashMap<String, Object>();
        bs.writeLog("----MailAction-----");
        try{
            String userid = request.getParameter("userid");
            String lxr = request.getParameter("lxr");
            String ssjg = request.getParameter("ssjg");
            String sfyjcysjr = request.getParameter("sfyjcysjr");
            String sfzdcf = request.getParameter("sfzdcf");

            MailService mailService = getService();
            apidatas = mailService.getUserInfo(userid,lxr,ssjg,sfyjcysjr,sfzdcf);
        }catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }

        return JSON.toJSONString(apidatas);
    }
}
