package com.ruoyi.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.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.system.domain.TbXnszzMember;
import com.ruoyi.system.service.ITbXnszzMemberService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小牛用户表Controller
 * 
 * @author Ashe
 * @date 2025-11-14
 */
@RestController
@RequestMapping("/system/xnMember")
public class TbXnszzMemberController extends BaseController
{
    @Autowired
    private ITbXnszzMemberService tbXnszzMemberService;

    /**
     * 查询小牛用户表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xnMember:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbXnszzMember tbXnszzMember)
    {
        startPage();
        List<TbXnszzMember> list = tbXnszzMemberService.selectTbXnszzMemberList(tbXnszzMember);
        return getDataTable(list);
    }

    /**
     * 导出小牛用户表列表
     */
    @PreAuthorize("@ss.hasPermi('system:xnMember:export')")
    @Log(title = "小牛用户表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbXnszzMember tbXnszzMember)
    {
        List<TbXnszzMember> list = tbXnszzMemberService.selectTbXnszzMemberList(tbXnszzMember);
        ExcelUtil<TbXnszzMember> util = new ExcelUtil<TbXnszzMember>(TbXnszzMember.class);
        return util.exportExcel(list, "小牛用户表数据");
    }

    /**
     * 获取小牛用户表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:xnMember:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbXnszzMemberService.selectTbXnszzMemberById(id));
    }

    /**
     * 新增小牛用户表
     */
    @PreAuthorize("@ss.hasPermi('system:xnMember:add')")
    @Log(title = "小牛用户表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbXnszzMember tbXnszzMember)
    {
        return toAjax(tbXnszzMemberService.insertTbXnszzMember(tbXnszzMember));
    }

    /**
     * 修改小牛用户表
     */
    @PreAuthorize("@ss.hasPermi('system:xnMember:edit')")
    @Log(title = "小牛用户表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbXnszzMember tbXnszzMember)
    {
        return toAjax(tbXnszzMemberService.updateTbXnszzMember(tbXnszzMember));
    }

    /**
     * 删除小牛用户表
     */
    @PreAuthorize("@ss.hasPermi('system:xnMember:remove')")
    @Log(title = "小牛用户表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbXnszzMemberService.deleteTbXnszzMemberByIds(ids));
    }


    @PostMapping("/addMember")
    public AjaxResult addMember(@RequestBody TbXnszzMember tbXnszzMember)
    {
        return toAjax(tbXnszzMemberService.insertTbXnszzMember(tbXnszzMember));
    }

}
