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.StepGroup;
import com.hxhq.business.service.IStepGroupService;
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/stepGroup")
public class StepGroupController extends BaseController
{
    @Autowired
    private IStepGroupService stepGroupService;

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

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

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

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