package com.ruoyi.web.controller.drillDeduction;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.drill.domain.TyDrillInfo;
import com.ruoyi.drill.service.ITyDrillInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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 javax.annotation.Resource;
import java.util.List;

/**
 * TyDrilInfoController
 *
 * @Auther: mtx
 * @Date: 2023/09/25 16:05
 */
@RestController
@RequestMapping("/drillInfo")
@Api(tags = "推演")
public class TyDrilInfoController extends BaseController {

    @Resource
    private ITyDrillInfoService drillInfoService;

    @GetMapping("/list")
    @ApiOperation("查询推演列表")
    public TableDataInfo list() {
        startPage();
        List<TyDrillInfo> list = drillInfoService.list();
        return getDataTable(list);
    }

    @GetMapping("/getDetails")
    @ApiOperation("查询推演列表")
    public AjaxResult getDetails(String id) {
        TyDrillInfo tyDrillInfo = drillInfoService.getById(id);
        return success(tyDrillInfo);
    }

    @Log(title = "新增推演", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    @ApiOperation("新增推演")
    public AjaxResult save(@Validated @RequestBody TyDrillInfo tyDrillInfo) {
        return toAjax(drillInfoService.saveOrUpdate(tyDrillInfo));
    }

    @Log(title = "删除推演", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    @ApiOperation("删除推演")
    public AjaxResult remove(String id) {
        return toAjax(drillInfoService.removeById(id));
    }

}
