package com.inspect.patrol.controller;

import com.inspect.base.core.utils.poi.ExcelUtil;
import com.inspect.base.core.web.controller.BaseController;
import com.inspect.base.core.web.domain.AjaxResult;
import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.common.log.annotation.Log;
import com.inspect.common.log.enums.BizType;
import com.inspect.patrol.domain.PatrolPosInfrared;
import com.inspect.patrol.service.IPatrolPosInfraredService;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@ApiIgnore
@RestController
@RequestMapping({"/param"})
public class PatrolPosInfraredController extends BaseController {
    private final IPatrolPosInfraredService patrolPosInfraredService;

    public PatrolPosInfraredController(IPatrolPosInfraredService patrolPosInfraredService) {
        this.patrolPosInfraredService = patrolPosInfraredService;
    }

    @GetMapping({"/list"})
    public TableDataInfo list(PatrolPosInfrared patrolPosInfrared) {
        this.startPage();
        List<PatrolPosInfrared> list = this.patrolPosInfraredService.selectPatrolPosInfraredList(patrolPosInfrared);
        return this.getDataTable(list);
    }

    @Log(
            title = "预置点红外测温",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, PatrolPosInfrared patrolPosInfrared) {
        List<PatrolPosInfrared> list = this.patrolPosInfraredService.selectPatrolPosInfraredList(patrolPosInfrared);
        ExcelUtil<PatrolPosInfrared> util = new ExcelUtil<>(PatrolPosInfrared.class);
        util.exportExcel(response, list, "预置点红外测温数据");
    }

    @GetMapping({"/{patrolPosInfraredId}"})
    public AjaxResult getInfo(@PathVariable("patrolPosInfraredId") Long patrolPosInfraredId) {
        return AjaxResult.success(this.patrolPosInfraredService.selectPatrolPosInfraredByPatrolPosInfraredId(patrolPosInfraredId));
    }

    @Log(
            title = "预置点红外测温",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody PatrolPosInfrared patrolPosInfrared) {
        return this.toAjax(this.patrolPosInfraredService.insertPatrolPosInfrared(patrolPosInfrared));
    }

    @Log(
            title = "预置点红外测温",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody PatrolPosInfrared patrolPosInfrared) {
        return this.toAjax(this.patrolPosInfraredService.updatePatrolPosInfrared(patrolPosInfrared));
    }

    @Log(
            title = "预置点红外测温",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{patrolPosInfraredIds}"})
    public AjaxResult remove(@PathVariable Long[] patrolPosInfraredIds) {
        return this.toAjax(this.patrolPosInfraredService.deletePatrolPosInfraredByPatrolPosInfraredIds(patrolPosInfraredIds));
    }
}
