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 org.springframework.beans.factory.annotation.Autowired;
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.HttpSession;
import java.util.List;

@Controller
public class GnssResendController extends BasicController implements CommonExcelService<ResendRecord, ResendRecord> {
    @Autowired
    GnssGroupFwdMapper gnssGroupFwdMapper;
    @Autowired
    ResendRecordMapper resendRecordMapper;

    /********* 推送页面 *********/
    @RequestMapping("/page/resend_records")
    public String fwdRecords(Model m, HttpSession session) {
        initModel(m, session);
        //以下用于下拉框数据
        List<GnssGroupFwd> gnssGroupFwds = gnssGroupFwdMapper.selectList(null);
        m.addAttribute("gnss_group_fwd_list", gnssGroupFwds);

        return "/page/resend_records";
    }

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

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

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