package com.tongran.system.controller;

import com.tongran.common.core.web.controller.BaseController;
import com.tongran.common.core.web.domain.AjaxResult;
import com.tongran.common.log.annotation.Log;
import com.tongran.common.log.enums.BusinessType;
import com.tongran.system.domain.UserTableColumnConfig;
import com.tongran.system.service.IUserTableColumnConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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


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

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


}
