package com.ruoyi.kaohe.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kaohe.domain.KhUidRecard;
import com.ruoyi.kaohe.service.IKhUidRecardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * uid管理Controller
 * 
 * @author hs
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/kaohe/uid")
public class KhUidRecardController extends BaseController
{
    @Autowired
    private IKhUidRecardService khUidRecardService;

    /**
     * 查询uid管理列表
     */
    @PreAuthorize("@ss.hasPermi('kaohe:uid:list')")
    @GetMapping("/list")
    public TableDataInfo list(KhUidRecard khUidRecard)
    {
        startPage();
        List<KhUidRecard> list = khUidRecardService.selectKhUidRecardList(khUidRecard);
        return getDataTable(list);
    }

    /**
     * 导出uid管理列表
     */
    @PreAuthorize("@ss.hasPermi('kaohe:uid:export')")
    @Log(title = "uid管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KhUidRecard khUidRecard)
    {
        List<KhUidRecard> list = khUidRecardService.selectKhUidRecardList(khUidRecard);
        ExcelUtil<KhUidRecard> util = new ExcelUtil<KhUidRecard>(KhUidRecard.class);
        util.exportExcel(response, list, "uid管理数据");
    }

    /**
     * 获取uid管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('kaohe:uid:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(khUidRecardService.selectKhUidRecardById(id));
    }

    /**
     * 新增uid管理
     */
    @PreAuthorize("@ss.hasPermi('kaohe:uid:add')")
    @Log(title = "uid管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KhUidRecard khUidRecard)
    {
        return toAjax(khUidRecardService.insertKhUidRecard(khUidRecard));
    }

    /**
     * 修改uid管理
     */
    @PreAuthorize("@ss.hasPermi('kaohe:uid:edit')")
    @Log(title = "uid管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KhUidRecard khUidRecard)
    {
        return toAjax(khUidRecardService.updateKhUidRecard(khUidRecard));
    }

    /**
     * 删除uid管理
     */
    @PreAuthorize("@ss.hasPermi('kaohe:uid:remove')")
    @Log(title = "uid管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(khUidRecardService.deleteKhUidRecardByIds(ids));
    }
}
