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.GnssStatusMsg;
import com.imdroid.secapi.dto.GnssStatusMsgMapper;
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;

/**
 * 状态消息 控制器
 *
 * @author LiGang
 * @date 2024/1/6 14:37
 */
@Controller
@RequiredArgsConstructor
public class GnssMsgStatusController extends BasicController implements CommonExcelService<GnssStatusMsg, GnssStatusMsg> {

    private final GnssStatusMsgMapper statusMsgMapper;

    @RequestMapping("/page/gnss_msg_status")
    public String gnssStatusMsg(Model m, HttpSession session) {
        initModel(m, session);
        return "/page/gnss_msg_status";
    }

    @RequestMapping("/gnss/msg/status/list")
    @ResponseBody
    public JSONObject listStatusMsg(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/status/export")
    @ResponseBody
    public void exportData(HttpSession session, HttpServletRequest request, HttpServletResponse response) throws Exception {
        this.export(session, request, response);
    }

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

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