package com.cmvr.web.controller.test;

import com.cmvr.common.annotation.Log;
import com.cmvr.common.core.controller.BaseController;
import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.common.core.page.TableDataInfo;
import com.cmvr.common.enums.BusinessType;
import com.cmvr.test.model.domain.TeTaskConfigInfo;
import com.cmvr.test.model.vo.TeTaskConfigInfoVO;
import com.cmvr.test.service.ITeTaskConfigInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "测试--任务配置")
@RestController
@RequestMapping("/test/config")
@RequiredArgsConstructor
public class TeTaskConfigInfoController extends BaseController {

    private final ITeTaskConfigInfoService teTaskConfigInfoService;

    @ApiOperation("查询任务配置信息列表")
    @PreAuthorize("@ss.hasPermi('test:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeTaskConfigInfo teTaskConfigInfo) {
        startPage();
        List<TeTaskConfigInfoVO> list = teTaskConfigInfoService.selectTeTaskConfigInfoList(teTaskConfigInfo);
        return getDataTable(list);
    }

    @ApiOperation("获取任务配置信息详细信息")
    @PreAuthorize("@ss.hasPermi('test:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(teTaskConfigInfoService.selectTeTaskConfigInfoById(id));
    }

    @ApiOperation("新增任务配置信息")
    @PreAuthorize("@ss.hasPermi('test:config:add')")
    @Log(title = "任务配置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeTaskConfigInfo teTaskConfigInfo) {
        return toAjax(teTaskConfigInfoService.insertTeTaskConfigInfo(teTaskConfigInfo));
    }

    @ApiOperation("修改任务配置信息")
    @PreAuthorize("@ss.hasPermi('test:config:edit')")
    @Log(title = "任务配置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeTaskConfigInfo teTaskConfigInfo) {
        return toAjax(teTaskConfigInfoService.updateTeTaskConfigInfo(teTaskConfigInfo));
    }

    @ApiOperation("删除任务配置信息")
    @PreAuthorize("@ss.hasPermi('test:config:remove')")
    @Log(title = "任务配置信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(teTaskConfigInfoService.deleteTeTaskConfigInfoByIds(ids));
    }
}
