package com.mortals.xhx.module.platform.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.impl.LocalCacheServiceImpl;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.platform.model.PlatformEntity;
import com.mortals.xhx.module.platform.service.PlatformService;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 平台系统
 *
 * @author zxfei
 * @date 2022-04-25
 */
@RestController
@RequestMapping("platform")
public class PlatformController extends BaseCRUDJsonMappingController<PlatformService, PlatformForm, PlatformEntity, Long> {

    @Autowired
    private ParamService paramService;

    public PlatformController() {
        super.setFormClass(PlatformForm.class);
        super.setModuleDesc("平台系统");
    }

    @Override
    protected void init(HttpServletRequest request, HttpServletResponse response, PlatformForm form, Map<String, Object> model, Context context) {
        this.addDict(model, "sendMsgType", paramService.getParamBySecondOrganize("Platform", "sendMsgType"));
        this.addDict(model, "sendSwitch", paramService.getParamBySecondOrganize("Platform", "sendSwitch"));
        super.init(request, response, form, model, context);
    }
}