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.PatrolLinkageStrategyRef;
import com.inspect.patrol.service.IPatrolLinkageStrategyRefService;

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({"/ref"})
public class PatrolLinkageStrategyRefController extends BaseController {
    private final IPatrolLinkageStrategyRefService patrolLinkageStrategyRefService;

    public PatrolLinkageStrategyRefController(IPatrolLinkageStrategyRefService patrolLinkageStrategyRefService) {
        this.patrolLinkageStrategyRefService = patrolLinkageStrategyRefService;
    }

    @GetMapping({"/list"})
    public TableDataInfo list(PatrolLinkageStrategyRef patrolLinkageStrategyRef) {
        this.startPage();
        List<PatrolLinkageStrategyRef> list = this.patrolLinkageStrategyRefService.selectPatrolLinkageStrategyRefList(patrolLinkageStrategyRef);
        return this.getDataTable(list);
    }

    @Log(
            title = "联动点(hongww)",
            businessType = BizType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, PatrolLinkageStrategyRef patrolLinkageStrategyRef) {
        List<PatrolLinkageStrategyRef> list = this.patrolLinkageStrategyRefService.selectPatrolLinkageStrategyRefList(patrolLinkageStrategyRef);
        ExcelUtil<PatrolLinkageStrategyRef> util = new ExcelUtil<>(PatrolLinkageStrategyRef.class);
        util.exportExcel(response, list, "联动点(hongww)数据");
    }

    @GetMapping({"/{linkageStrategyRefId}"})
    public AjaxResult getInfo(@PathVariable("linkageStrategyRefId") Long linkageStrategyRefId) {
        return AjaxResult.success(this.patrolLinkageStrategyRefService.selectPatrolLinkageStrategyRefByLinkageStrategyRefId(linkageStrategyRefId));
    }

    @Log(
            title = "联动点(hongww)",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody PatrolLinkageStrategyRef patrolLinkageStrategyRef) {
        return this.toAjax(this.patrolLinkageStrategyRefService.insertPatrolLinkageStrategyRef(patrolLinkageStrategyRef));
    }

    @Log(
            title = "联动点(hongww)",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody PatrolLinkageStrategyRef patrolLinkageStrategyRef) {
        return this.toAjax(this.patrolLinkageStrategyRefService.updatePatrolLinkageStrategyRef(patrolLinkageStrategyRef));
    }

    @Log(
            title = "联动点(hongww)",
            businessType = BizType.DELETE
    )
    @PostMapping({"/remove/{linkageStrategyRefIds}"})
    public AjaxResult remove(@PathVariable Long[] linkageStrategyRefIds) {
        return this.toAjax(this.patrolLinkageStrategyRefService.deletePatrolLinkageStrategyRefByLinkageStrategyRefIds(linkageStrategyRefIds));
    }
}
