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.PatrolLinkageStrategyReverse;
import com.inspect.patrol.service.IPatrolLinkageStrategyReverseService;
import io.swagger.annotations.Api;

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;

@RestController
@ApiIgnore
@Api(
        tags = {"反向联动"}
)
@RequestMapping({"/linkage_reverse"})
public class PatrolLinkageStrategyReverseController extends BaseController {
    private final IPatrolLinkageStrategyReverseService patrolLinkageStrategyReverseService;

    public PatrolLinkageStrategyReverseController(IPatrolLinkageStrategyReverseService patrolLinkageStrategyReverseService) {
        this.patrolLinkageStrategyReverseService = patrolLinkageStrategyReverseService;
    }

    @GetMapping({"/list"})
    public TableDataInfo list(PatrolLinkageStrategyReverse patrolLinkageStrategyReverse) {
        this.startPage();
        List<PatrolLinkageStrategyReverse> list = this.patrolLinkageStrategyReverseService.selectPatrolLinkageStrategyReverseList(patrolLinkageStrategyReverse);
        return this.getDataTable(list);
    }

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

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

    @Log(
            title = "联动点(hongww)",
            businessType = BizType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody PatrolLinkageStrategyReverse patrolLinkageStrategyReverse) {
        return this.toAjax(this.patrolLinkageStrategyReverseService.insertPatrolLinkageStrategyReverse(patrolLinkageStrategyReverse));
    }

    @Log(
            title = "联动点(hongww)",
            businessType = BizType.UPDATE
    )
    @PostMapping({"/edit"})
    public AjaxResult edit(@RequestBody PatrolLinkageStrategyReverse patrolLinkageStrategyReverse) {
        return this.toAjax(this.patrolLinkageStrategyReverseService.updatePatrolLinkageStrategyReverse(patrolLinkageStrategyReverse));
    }

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