package com.dayou.controller;

import com.dayou.annotation.IgnoreAuth;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.IGisVisitedService;
import com.dayou.entity.GisVisited;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * GIS访问记录
 *
 * @author wucl
 * @since 2023-05-19
 */
@RestController
@RequestMapping("gisVisited")
@Slf4j
public class GisVisitedController extends BaseController {
    @Autowired
    private IGisVisitedService gisVisitedService;

    /**
    * GIS访问记录列表
    */
    @GetMapping("")
    public RestResponse<Page<GisVisited>> page(GisVisited gisVisited, Page page){
        Page<GisVisited> pages=gisVisitedService.selectPage(page,gisVisited);
        return RestResponse.data(pages);
    }

    /**
     * GIS访问记录详情
     */
    @GetMapping("/{id}")
    public RestResponse<GisVisited> detail(@PathVariable Long id){
        GisVisited xGisVisited =gisVisitedService.detail(id);
        return RestResponse.data(xGisVisited);
     }

    /**
     * GIS访问记录新增
     */
    @PostMapping("")
    public void save(HttpServletRequest request) {
        gisVisitedService.add(request);
    }

    /**
     * GIS访问记录更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody GisVisited gisVisited) {
        Boolean ret = gisVisitedService.update(gisVisited);
        return RestResponse.data(ret);
    }

    /**
     * GIS访问记录删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = gisVisitedService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 访问计数
     * @return
     */
    @IgnoreAuth
    @GetMapping("/count")
    public RestResponse<Integer> countTotal(){
        int count = gisVisitedService.count();
        return RestResponse.data(count);
    }

}

