package com.easyproject.web.controller.guide;

import java.util.List;

import com.easyproject.service.domain.guide.ServiceGuideItem;
import com.easyproject.system.service.guide.IServiceGuideItemService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.easyproject.common.annotation.Log;
import com.easyproject.common.core.controller.BaseController;
import com.easyproject.common.core.domain.AjaxResult;
import com.easyproject.common.enums.BusinessType;
import com.easyproject.common.core.page.TableDataInfo;

/**
 * 指南栏目Controller
 *
 * @author easyproject
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/system/guideItem")
public class ServiceGuideItemController extends BaseController {
    @Autowired
    private IServiceGuideItemService serviceGuideItemService;

    /**
     * 查询指南栏目列表
     */
    @PreAuthorize("@ss.hasPermi('system:guideItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceGuideItem serviceGuideItem) {
        startPage();
        List<ServiceGuideItem> list = serviceGuideItemService.selectServiceGuideItemList(serviceGuideItem);
        return getDataTable(list);
    }

    /**
     * 获取指南栏目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:guideItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(serviceGuideItemService.selectServiceGuideItemById(id));
    }

    /**
     * 新增指南栏目
     */
    @PreAuthorize("@ss.hasPermi('system:guideItem:add')")
    @Log(title = "指南栏目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceGuideItem serviceGuideItem) {
        return toAjax(serviceGuideItemService.insertServiceGuideItem(serviceGuideItem));
    }

    /**
     * 修改指南栏目
     */
    @PreAuthorize("@ss.hasPermi('system:guideItem:edit')")
    @Log(title = "指南栏目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceGuideItem serviceGuideItem) {
        return toAjax(serviceGuideItemService.updateServiceGuideItem(serviceGuideItem));
    }

    /**
     * 删除指南栏目
     */
    @PreAuthorize("@ss.hasPermi('system:guideItem:remove')")
    @Log(title = "指南栏目", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(serviceGuideItemService.deleteServiceGuideItemByIds(ids));
    }

    /**
     * 方法说明: 查询所有有效分类列表
     * @param
     * @return
     * @author java-101
     * @date 2025-03-21 15:36:15
     */
    @GetMapping("/selGategorTree")
    public AjaxResult selGategorTree() {
        return serviceGuideItemService.selGategorTree();
    }

}
