package com.malk.aiwei.controller;


import com.malk.aiwei.service.GZT_PN;
import com.malk.server.common.McException;
import com.malk.server.common.McR;
import com.malk.utils.UtilServlet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("pl")
public class PLController {

    @Autowired
    private GZT_PN gzt_pn;

    /**
     * jsApi 注册
     */
    @PostMapping("register")
    McR register(@RequestBody Map<String, String> data) {

        McException.assertParamException_Null(data, "url", "nonceStr");
        return McR.success(gzt_pn.register(data));
    }

    /**
     * 工作台数据 - 资讯中心
     */
    @PostMapping("portal/ZXZX")
    List<Map> portal_ZXZZ(HttpServletRequest request) {

        Map data = UtilServlet.getParamMap(request);
        log.info("工作台数据, {}", data);
        return gzt_pn.getPortalList("派能资讯");
    }

    @PostMapping("portal/NLPS")
    List<Map> portal_NLPS(HttpServletRequest request) {

        Map data = UtilServlet.getParamMap(request);
        log.info("工作台数据, {}", data);
        return gzt_pn.getPortalList("能量派送");
    }

    @PostMapping("portal/RZZX")
    List<Map> portal_RZZX(HttpServletRequest request) {

        Map data = UtilServlet.getParamMap(request);
        log.info("工作台数据, {}", data);
        return gzt_pn.getPortalList("人资资讯");
    }

    @PostMapping("portal/NBZX")
    List<Map> portal_NBZX(HttpServletRequest request) {

        Map data = UtilServlet.getParamMap(request);
        log.info("工作台数据, {}", data);
        return gzt_pn.getPortalList("内部资讯");
    }

}
