package com.ruoyi.platform.controller.workflow;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.GenericsAjaxResult;
import com.ruoyi.platform.domain.WorkflowParam;
import com.ruoyi.platform.service.WorkflowParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (WorkflowParam)表控制层
 *
 * @author Xidaray
 * @since 2024-03-18 14:12:07
 */
@RestController
@RequestMapping("workflowParam")
@Api("流水线参数管理")
public class WorkflowParamController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private WorkflowParamService workflowParamService;

    /**
     * 分页查询
     *
     * @param workflowParam 筛选条件
     * @return 查询结果
     */
    @GetMapping
    @ApiOperation("分页查询")
    public GenericsAjaxResult<Page<WorkflowParam>> queryByPage(WorkflowParam workflowParam, int page, int size) {
        PageRequest pageRequest = PageRequest.of(page,size);
        return  genericsSuccess(this.workflowParamService.queryByPage(workflowParam, pageRequest));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation("根据id查询单条数据")
    public GenericsAjaxResult<WorkflowParam> queryById(@PathVariable("id") Integer id) {
        return  genericsSuccess(this.workflowParamService.queryById(id));
    }
    /**
     * 新增数据
     *
     * @param workflowParam 实体
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation("新增流水线参数")
    public GenericsAjaxResult<WorkflowParam> add(WorkflowParam workflowParam) throws Exception {
        return genericsSuccess(this.workflowParamService.insert(workflowParam));
    }

    /**
     * 编辑数据
     *
     * @param workflowParam 实体
     * @return 编辑结果
     */
    @PutMapping
    @ApiOperation("编辑流水线参数")
    public GenericsAjaxResult<WorkflowParam> edit(WorkflowParam workflowParam) {
        return genericsSuccess(this.workflowParamService.update(workflowParam));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    @ApiOperation("删除流水线参数")
    public GenericsAjaxResult<String> deleteById(Integer id) throws Exception {
        return genericsSuccess(this.workflowParamService.removeById(id));
    }

}

