package com.engine.htsc.zbtybx.web;

import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ServiceUtil;
import com.engine.htsc.zbtybx.service.YdbxModeDataService;
import com.engine.htsc.zbtybx.service.YdbxModeDataServiceImpl;
import weaver.general.BaseBean;
import weaver.general.Util;

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;

public class YdbxAction {

    private YdbxModeDataService getService(){
        return ServiceUtil.getService(YdbxModeDataServiceImpl.class);
    }

    @GET
    @Path("/delmodedata")
    @Produces({MediaType.APPLICATION_JSON})
    public String delModeData(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bb = new BaseBean();
        bb.writeLog("====================YdbxAction check in =======================");
        Map<String,Object> result = new HashMap<>();
        String ids = Util.null2String(request.getParameter("ids"));
        bb.writeLog("============获取的ids参数为："+ids);
        if("".equals(ids)){
            result.put("code","500");
            result.put("message","ids参数为空");
        }else {
            Map<String,Object> params = new HashMap<>();
            params.put("ids",ids);
            result = getService().delModeData(params);
            result.put("code","200");
            result.put("message","success");
        }
        return JSONObject.toJSONString(result);
    }

    @GET
    @Path("/importData")
    @Produces({MediaType.APPLICATION_JSON})
    public String importData(@Context HttpServletRequest request, @Context HttpServletResponse response){
        BaseBean bb = new BaseBean();
        bb.writeLog("--------------------------importData ----------------------------------------");
        String lclx = Util.null2String(request.getParameter("lclx"));
        Map<String,Object> result = new HashMap<>();
        bb.writeLog("============获取的lclx参数为："+lclx);
        if("".equals(lclx)){
            result.put("code","500");
            result.put("message","lclx参数为空");
        }else {
            Map<String,Object> params = new HashMap<>();
            params.put("lclx",lclx);
            result = getService().importData(params);
            result.put("code","200");
            result.put("message","success");
        }
        return JSONObject.toJSONString(result);
    }






}
