package com.fs.delivery.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.delivery.domain.TagGroup;
import com.fs.delivery.service.ITagGroupService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 标签分组Controller
 * 
 * @author fs
 * @date 2026-01-20
 */
@RestController
@RequestMapping("/delivery/group")
public class TagGroupController extends BaseController
{
    @Autowired
    private ITagGroupService tagGroupService;

    /**
     * 查询标签分组列表
     */
    @PreAuthorize("@ss.hasPermi('delivery:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(TagGroup tagGroup)
    {
        startPage();
        List<TagGroup> list = tagGroupService.selectTagGroupList(tagGroup);
        return getDataTable(list);
    }

    /**
     * 导出标签分组列表
     */
    @PreAuthorize("@ss.hasPermi('delivery:group:export')")
    @Log(title = "标签分组", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TagGroup tagGroup)
    {
        List<TagGroup> list = tagGroupService.selectTagGroupList(tagGroup);
        ExcelUtil<TagGroup> util = new ExcelUtil<TagGroup>(TagGroup.class);
        return util.exportExcel(list, "标签分组数据");
    }

    /**
     * 获取标签分组详细信息
     */
    @PreAuthorize("@ss.hasPermi('delivery:group:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tagGroupService.selectTagGroupById(id));
    }

    /**
     * 新增标签分组
     */
    @PreAuthorize("@ss.hasPermi('delivery:group:add')")
    @Log(title = "标签分组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TagGroup tagGroup)
    {
        return toAjax(tagGroupService.insertTagGroup(tagGroup));
    }

    /**
     * 修改标签分组
     */
    @PreAuthorize("@ss.hasPermi('delivery:group:edit')")
    @Log(title = "标签分组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TagGroup tagGroup)
    {
        return toAjax(tagGroupService.updateTagGroup(tagGroup));
    }

    /**
     * 删除标签分组
     */
    @PreAuthorize("@ss.hasPermi('delivery:group:remove')")
    @Log(title = "标签分组", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tagGroupService.deleteTagGroupByIds(ids));
    }
}
