package com.easyproject.web.controller.guide;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.easyproject.service.domain.guide.ServiceGuideCategory;
import com.easyproject.system.service.guide.IServiceGuideCategoryService;
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/guideCategory")
public class ServiceGuideCategoryController extends BaseController {
    @Autowired
    private IServiceGuideCategoryService serviceGuideCategoryService;

    /**
     * 查询指南分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:guideCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceGuideCategory serviceGuideCategory) {
        startPage();
        List<ServiceGuideCategory> list = serviceGuideCategoryService.selectServiceGuideCategoryList(serviceGuideCategory);
        return getDataTable(list);
    }

    /**
     * 获取指南分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:guideCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(serviceGuideCategoryService.selectServiceGuideCategoryById(id));
    }

    /**
     * 新增指南分类
     */
    @PreAuthorize("@ss.hasPermi('system:guideCategory:add')")
    @Log(title = "指南分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceGuideCategory serviceGuideCategory) {
        return toAjax(serviceGuideCategoryService.insertServiceGuideCategory(serviceGuideCategory));
    }

    /**
     * 修改指南分类
     */
    @PreAuthorize("@ss.hasPermi('system:guideCategory:edit')")
    @Log(title = "指南分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceGuideCategory serviceGuideCategory) {
        return toAjax(serviceGuideCategoryService.updateServiceGuideCategory(serviceGuideCategory));
    }

    /**
     * 删除指南分类
     */
    @PreAuthorize("@ss.hasPermi('system:guideCategory:remove')")
    @Log(title = "指南分类", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(serviceGuideCategoryService.deleteServiceGuideCategoryByIds(ids));
    }
}
