package com.engine.htsc.sendimage.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.sendimage.service.SendImageService;
import com.engine.htsc.sendimage.service.impl.SendImageServiceImpl;
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.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:DTY-PC
 * Date:2020/10/26 15:15
 * Description:
 * Copyright:上海泛微网络科技股份有限公司
 */
public class SendImageAction {
    private SendImageService getService(User user){
        return ServiceUtil.getService(SendImageServiceImpl.class,user);
    }

    @GET
    @Path("/doSendImage")
    @Produces({MediaType.TEXT_PLAIN})
    public String sendImage(@Context HttpServletRequest request, @Context HttpServletResponse response){
        Map<String, Object> apidatas = new HashMap<>();
        try {
            //获取当前用户
            User user = HrmUserVarify.getUser(request, response);
            Map<String,Object> para = ParamUtil.request2Map(request);
            BaseBean bb = new BaseBean();
            apidatas.putAll(getService(user).doSendImage(para));
            apidatas.put("api_status", true);
        } catch (Exception e) {
            e.printStackTrace();
            apidatas.put("api_status", false);
            apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
        }
        return JSONObject.toJSONString(apidatas);


    }
}
