package com.fs.web.controller.system;

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.system.domain.SysUserSet;
import com.fs.system.service.ISysUserSetService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 用户设置Controller
 *
 * @author fs
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/system/set")
public class SysUserSetController extends BaseController
{
    @Autowired
    private ISysUserSetService sysUserSetService;

    /**
     * 查询用户设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:set:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserSet sysUserSet)
    {
        startPage();
        List<SysUserSet> list = sysUserSetService.selectSysUserSetList(sysUserSet);
        return getDataTable(list);
    }

    /**
     * 导出用户设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:set:export')")
    @Log(title = "用户设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysUserSet sysUserSet)
    {
        List<SysUserSet> list = sysUserSetService.selectSysUserSetList(sysUserSet);
        ExcelUtil<SysUserSet> util = new ExcelUtil<SysUserSet>(SysUserSet.class);
        return util.exportExcel(list, "用户设置数据");
    }

    /**
     * 获取用户设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:set:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(sysUserSetService.selectSysUserSetByUserId(userId));
    }

    /**
     * 新增用户设置
     */
    @PreAuthorize("@ss.hasPermi('system:set:add')")
    @Log(title = "用户设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserSet sysUserSet)
    {
        return toAjax(sysUserSetService.insertSysUserSet(sysUserSet));
    }

    /**
     * 修改用户设置
     */
    @PreAuthorize("@ss.hasPermi('system:set:edit')")
    @Log(title = "用户设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserSet sysUserSet)
    {
        return toAjax(sysUserSetService.updateSysUserSet(sysUserSet));
    }

    /**
     * 删除用户设置
     */
    @PreAuthorize("@ss.hasPermi('system:set:remove')")
    @Log(title = "用户设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysUserSetService.deleteSysUserSetByUserIds(userIds));
    }
}
