package com.imdroid.beidou.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.imdroid.beidou.service.CommonExcelService;
import com.imdroid.secapi.dto.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 消息摘要 控制器
 */
@Controller
@RequiredArgsConstructor
public class GnssMsgController extends BasicController implements CommonExcelService<GnssMsg, GnssMsg> {

    private final GnssMsgMapper msgMapper;

    /**** 推送页面  *****/
    @RequestMapping("/page/gnss_msg")
    public String gnssMsg(Model m, HttpSession session) {
        initModel(m, session);
        return "/page/gnss_msg";
    }


    /**** 推送数据  *****/
    @RequestMapping("/gnss/msg/list_all")
    @ResponseBody
    public JSONObject listMsg(HttpSession session, Integer page, Integer limit, String searchParams) {
        return this.pageList(session, page, limit, searchParams);
    }

    /**
     * 导出excel
     *
     * @param session      HttpSession
     * @param request HttpServletRequest
     * @param response     HttpServletResponse
     * @throws Exception
     */
    @RequestMapping("/gnss/msg/export")
    @ResponseBody
    public void exportData(HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
        this.export(session, request, response);
    }

    /**
     * 获取实体类的class
     *
     * @return 实体类的class
     */
    @Override
    public Class<GnssMsg> getEntityClass() {
        return GnssMsg.class;
    }

    /**
     * 获取实体类对应的mybatis mapper
     *
     * @return 实体类对应的mybatis mapper
     */
    @Override
    public BaseMapper<GnssMsg> getMapper() {
        return msgMapper;
    }
}
