package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.UserTableColumnConfig;
import com.ruoyi.system.service.IUserTableColumnConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户自定义列配置Controller
 * 
 * @author gyt
 * @date 2025-10-30
 */
@RestController
@RequestMapping("/columnConfig")
public class UserTableColumnConfigController extends BaseController
{
    @Autowired
    private IUserTableColumnConfigService userTableColumnConfigService;


    /**
     * 根据获取用户id获取自定义列配置详细信息
     */
    @RequiresPermissions("system:columnConfig:query")
    @PostMapping(value = "/getColumnConfigByUserId")
    public AjaxResult getColumnConfigByUserId(@RequestBody UserTableColumnConfig userTableColumnConfig)
    {
        UserTableColumnConfig columnConfig = userTableColumnConfigService.getColumnConfigByUserId(userTableColumnConfig);
        return success(columnConfig);
    }

    /**
     * 新增用户自定义列配置
     */
    @RequiresPermissions("system:columnConfig:add")
    @Log(title = "用户自定义列配置", businessType = BusinessType.INSERT)
    @PostMapping("addColumnConfig")
    public AjaxResult add(@RequestBody UserTableColumnConfig userTableColumnConfig)
    {
        return toAjax(userTableColumnConfigService.insertUserTableColumnConfig(userTableColumnConfig));
    }


}
