package com.hxhq.business.controller;

import java.util.Arrays;
import java.util.List;

import com.hxhq.common.security.annotation.Logical;
import com.hxhq.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.Step;
import com.hxhq.business.service.IStepService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;


/**
 * 步骤Controller
 *
 * @author hxhq
 * @date 2026-01-27
 */
@RestController
@RequestMapping("/business/step")
public class StepController extends BaseController
{
    @Autowired
    private IStepService stepService;

    /**
     * 查询步骤列表
     */
    @GetMapping("/list")
    @RequiresPermissions(value = {"business:step:list","business:stepGroup:list"},logical = Logical.OR)
    public TableDataInfo list(Step step)
    {
        startPage();
        List<Step> list = stepService.queryList(step);
        return getDataTable(list);
    }

    /**
     * 获取步骤详细信息
     */
    @GetMapping(value = "/info")
    @RequiresPermissions("business:step:list")
    public AjaxResult getInfo(Long id)
    {
        return AjaxResult.success(stepService.getById(id));
    }

    /**
     * 新增步骤信息
     */
    @PostMapping("/save")
    @RequiresPermissions("business:step:list")
    public AjaxResult save(@RequestBody Step step)
    {
        return toAjax(stepService.saveOrUpdate(step));
    }

    /**
     * 删除步骤信息
     */
    @PostMapping("/delete")
    @RequiresPermissions("business:step:list")
    public AjaxResult delete(@RequestBody Step step)
    {
        return toAjax(stepService.removeById(step.getId()));
    }
}
