package com.xunmei.core.access.controller;

import com.xunmei.common.core.web.controller.BaseController;
import com.xunmei.common.core.web.domain.AjaxResult;
import com.xunmei.common.core.web.page.TableDataInfo;
import com.xunmei.common.log.annotation.Log;
import com.xunmei.common.log.enums.BusinessType;
import com.xunmei.common.security.annotation.RequiresPermissions;
import com.xunmei.core.access.domain.TMonitoringRetrievalPlan;
import com.xunmei.core.access.service.ITMonitoringRetrievalPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 监控调阅计划Controller
 *
 * @author xunmei
 * @date 2023-08-24
 */
@Api(tags = {"TMonitoringRetrievalPlan"})
@RestController
@RequestMapping("/accessPlan")
public class TMonitoringRetrievalPlanController extends BaseController {
    @Autowired
    private ITMonitoringRetrievalPlanService tMonitoringRetrievalPlanService;

    /**
     * 查询监控调阅计划列表
     */
    @ApiOperation(value = "查询TMonitoringRetrievalPlan列表")
    @RequiresPermissions("core:access:list")
    @GetMapping("/list")
    public TableDataInfo<TMonitoringRetrievalPlan> list(TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {

        return tMonitoringRetrievalPlanService.selectPage(tMonitoringRetrievalPlan);
    }

    /**
     * 下发
     */
    @ApiOperation(value = "下发")
    @RequiresPermissions("core:accessPlan:add")
    @GetMapping(value = "/distribute/{id}")
    public AjaxResult distribute(@PathVariable(value = "id", required = false) Long id) {
        return success(tMonitoringRetrievalPlanService.distribute(id));
    }

    /**
     * 获取监控调阅计划详细信息
     */
    @ApiOperation(value = "获取TMonitoringRetrievalPlan详细信息")
    @RequiresPermissions("core:accessPlan:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tMonitoringRetrievalPlanService.selectTMonitoringRetrievalPlanById(id));
    }

    /**
     * 新增监控调阅计划
     */
    @ApiOperation(value = "新增TMonitoringRetrievalPlan")
    @RequiresPermissions("core:accessPlan:add")
    @Log(title = "监控调阅计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
        return toAjax(tMonitoringRetrievalPlanService.insertTMonitoringRetrievalPlan(tMonitoringRetrievalPlan));
    }

    /**
     * 修改监控调阅计划
     */
    @ApiOperation(value = "修改TMonitoringRetrievalPlan")
    @RequiresPermissions("core:accessPlan:edit")
    @Log(title = "监控调阅计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMonitoringRetrievalPlan tMonitoringRetrievalPlan) {
        return toAjax(tMonitoringRetrievalPlanService.updateTMonitoringRetrievalPlan(tMonitoringRetrievalPlan));
    }

    /**
     * 删除监控调阅计划
     */
    @ApiOperation(value = "删除TMonitoringRetrievalPlan")
    @RequiresPermissions("core:accessPlan:remove")
    @Log(title = "监控调阅计划", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tMonitoringRetrievalPlanService.deleteTMonitoringRetrievalPlanByIds(ids));
    }
}
