package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontPatDevPatRoute;
import com.inspect.metadata.montdata.service.IBasedataMontPatDevPatRouteService;
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.common.security.annotation.RequiresPermissions;

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

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;

@RestController
@RequestMapping({"/montdata/patdevpatroute"})
public class BasedataMontPatDevPatRouteController extends BaseController {
    @Resource
    private IBasedataMontPatDevPatRouteService basedataMontPatDevPatRouteService;

    @RequiresPermissions({"basedata/montdata:patdevpatroute:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontPatDevPatRoute basedataMontPatdevpatroute) {
        this.startPage();
        List<BasedataMontPatDevPatRoute> list = this.basedataMontPatDevPatRouteService.selectBasedataMontPatDevPatRouteList(basedataMontPatdevpatroute);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:patdevpatroute:export"})
    @Log(
            title = "巡视设备巡检路线",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontPatDevPatRoute basedataMontPatdevpatroute) {
        List<BasedataMontPatDevPatRoute> list = this.basedataMontPatDevPatRouteService.selectBasedataMontPatDevPatRouteList(basedataMontPatdevpatroute);
        ExcelUtil<BasedataMontPatDevPatRoute> util = new ExcelUtil<>(BasedataMontPatDevPatRoute.class);
        util.exportExcel(response, list, "巡视设备巡检路线数据");
    }

    @RequiresPermissions({"basedata/montdata:patdevpatroute:query"})
    @GetMapping({"/{mont_patdevcoord_id}"})
    public AjaxResult getInfo(@PathVariable("mont_patdevcoord_id") Long montPatDevCoordId) {
        return AjaxResult.success(this.basedataMontPatDevPatRouteService.selectBasedataMontPatDevPatRouteByMontPatDevRouteId(montPatDevCoordId));
    }

    @RequiresPermissions({"basedata/montdata:patdevpatroute:add"})
    @Log(
            title = "巡视设备巡检路线",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontPatDevPatRoute basedataMontPatdevpatroute) {
        return this.toAjax(this.basedataMontPatDevPatRouteService.insertBasedataMontPatDevPatRoute(basedataMontPatdevpatroute));
    }

    @RequiresPermissions({"basedata/montdata:patdevpatroute:edit"})
    @Log(
            title = "巡视设备巡检路线",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontPatDevPatRoute basedataMontPatdevpatroute) {
        return this.toAjax(this.basedataMontPatDevPatRouteService.updateBasedataMontPatDevPatRoute(basedataMontPatdevpatroute));
    }

    @RequiresPermissions({"basedata/montdata:patdevpatroute:remove"})
    @Log(
            title = "巡视设备巡检路线",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{mont_patdevcoord_ids}"})
    public AjaxResult remove(@PathVariable("mont_patdevcoord_ids") Long[] montPatDevCoordIds) {
        return this.toAjax(this.basedataMontPatDevPatRouteService.deleteBasedataMontPatDevPatRouteByMontPatDevPatRouteIds(montPatDevCoordIds));
    }

    @PostMapping({"/queryCoordAndRouteList"})
    public AjaxResult queryCoordAndRouteList(String patrolDeviceCode) {
        return AjaxResult.success(this.basedataMontPatDevPatRouteService.queryCoordAndRouteList(patrolDeviceCode));
    }
}
