package com.inspect.metadata.montdata.controller;

import com.inspect.metadata.montdata.domain.BasedataMontPatDevCoord;
import com.inspect.metadata.montdata.service.IBasedataMontPatDevCoordService;
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/patdevcoord"})
public class BasedataMontPatDevCoordController extends BaseController {
    @Resource
    private IBasedataMontPatDevCoordService basedataMontPatDevCoordService;

    @RequiresPermissions({"basedata/montdata:patdevcoord:list"})
    @GetMapping({"/list"})
    public TableDataInfo list(BasedataMontPatDevCoord basedataMontPatdevcoord) {
        this.startPage();
        List<BasedataMontPatDevCoord> list = this.basedataMontPatDevCoordService.selectBasedataMontPatDevCoordList(basedataMontPatdevcoord);
        return this.getDataTable(list);
    }

    @RequiresPermissions({"basedata/montdata:patdevcoord:export"})
    @Log(
            title = "巡视设备坐标",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, BasedataMontPatDevCoord basedataMontPatdevcoord) {
        List<BasedataMontPatDevCoord> list = this.basedataMontPatDevCoordService.selectBasedataMontPatDevCoordList(basedataMontPatdevcoord);
        ExcelUtil<BasedataMontPatDevCoord> util = new ExcelUtil<>(BasedataMontPatDevCoord.class);
        util.exportExcel(response, list, "巡视设备坐标数据");
    }

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

    @RequiresPermissions({"basedata/montdata:patdevcoord:add"})
    @Log(
            title = "巡视设备坐标",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody BasedataMontPatDevCoord basedataMontPatdevcoord) {
        return this.toAjax(this.basedataMontPatDevCoordService.insertBasedataMontPatDevCoord(basedataMontPatdevcoord));
    }

    @RequiresPermissions({"basedata/montdata:patdevcoord:edit"})
    @Log(
            title = "巡视设备坐标",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody BasedataMontPatDevCoord basedataMontPatdevcoord) {
        return this.toAjax(this.basedataMontPatDevCoordService.updateBasedataMontPatDevCoord(basedataMontPatdevcoord));
    }

    @RequiresPermissions({"basedata/montdata:patdevcoord:remove"})
    @Log(
            title = "巡视设备坐标",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{mont_patdevcoord_ids}"})
    public AjaxResult remove(@PathVariable("mont_patdevcoord_ids") Long[] montPatDevCoordIds) {
        return this.toAjax(this.basedataMontPatDevCoordService.deleteBasedataMontPatDevCoordByMontPatDevCoordIds(montPatDevCoordIds));
    }
}
