package com.ruoyi.web.bst;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.realName.domain.RealNameQuery;
import com.ruoyi.bst.realName.domain.RealNameVO;
import com.ruoyi.bst.realName.service.RealNameService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.vo.UserVO;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.LogBizType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.user.service.UserService;

/**
 * 实名认证信息Controller
 *
 * @author ruoyi
 * @date 2025-03-29
 */
@RestController
@RequestMapping("/bst/realName")
public class RealNameController extends BaseController
{
    @Autowired
    private RealNameService realNameService;

    @Autowired
    private UserService userService;

    /**
     * 查询实名认证信息列表
     */
    @PreAuthorize("@ss.hasPermi('bst:realName:list')")
    @GetMapping("/list")
    public TableDataInfo list(RealNameQuery query)
    {
        startPage();
        startOrderBy();
        List<RealNameVO> list = realNameService.selectRealNameList(query);
        return getDataTable(list);
    }

    /**
     * 导出实名认证信息列表
     */
    @PreAuthorize("@ss.hasPermi('bst:realName:export')")
    @Log(title = "实名认证信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RealNameQuery query)
    {
        List<RealNameVO> list = realNameService.selectRealNameList(query);
        ExcelUtil<RealNameVO> util = new ExcelUtil<RealNameVO>(RealNameVO.class);
        util.exportExcel(response, list, "实名认证信息数据");
    }

    /**
     * 获取实名认证信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bst:realName:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(realNameService.selectRealNameById(id));
    }

    /**
     * 删除实名认证信息
     */
    @PreAuthorize("@ss.hasPermi('bst:realName:remove')")
    @Log(title = "删除实名认证信息", businessType = BusinessType.DELETE, bizIdName = "arg0", bizType = LogBizType.REAL_NAME)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable List<Long> id)
    {
        return toAjax(realNameService.deleteRealNameByIds(id));
    }
}
