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.GnssTrxMsg;
import com.imdroid.secapi.dto.GnssTrxMsgMapper;
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;

/**
 * gnss统计消息 控制器
 *
 * @author LiGang
 * @date 2024/1/6 15:29
 */
@Controller
@RequiredArgsConstructor
public class GnssMsgTrxController extends BasicController implements CommonExcelService<GnssTrxMsg, GnssTrxMsg> {

    private final GnssTrxMsgMapper trxMsgMapper;

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

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

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

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