package com.ruoyi.hezhi.controller;

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.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.hezhi.domain.TbMemberJoin;
import com.ruoyi.hezhi.service.ITbMemberJoinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户参与Controller
 *
 * @author ruoyi
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/hezhi/memberJoin")
public class TbMemberJoinController extends BaseController
{
    @Autowired
    private ITbMemberJoinService tbMemberJoinService;

    /**
     * 查询用户参与列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberJoin:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMemberJoin tbMemberJoin)
    {
        startPage();
        List<TbMemberJoin> list = tbMemberJoinService.selectTbMemberJoinList(tbMemberJoin);
        return getDataTable(list);
    }

    /**
     * 导出用户参与列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberJoin:export')")
    @Log(title = "用户参与", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMemberJoin tbMemberJoin)
    {
        List<TbMemberJoin> list = tbMemberJoinService.selectTbMemberJoinList(tbMemberJoin);
        ExcelUtil<TbMemberJoin> util = new ExcelUtil<TbMemberJoin>(TbMemberJoin.class);
        util.exportExcel(response, list, "用户参与数据");
    }

    /**
     * 获取用户参与详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberJoin:query')")
    @GetMapping(value = "/{memberJoinId}")
    public AjaxResult getInfo(@PathVariable("memberJoinId") Long memberJoinId)
    {
        return success(tbMemberJoinService.selectTbMemberJoinByMemberJoinId(memberJoinId));
    }

    /**
     * 新增用户参与
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberJoin:add')")
    @Log(title = "用户参与", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMemberJoin tbMemberJoin)
    {
        return toAjax(tbMemberJoinService.insertTbMemberJoin(tbMemberJoin));
    }

    /**
     * 修改用户参与
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberJoin:edit')")
    @Log(title = "用户参与", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMemberJoin tbMemberJoin)
    {
        return toAjax(tbMemberJoinService.updateTbMemberJoin(tbMemberJoin));
    }

    /**
     * 删除用户参与
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberJoin:remove')")
    @Log(title = "用户参与", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberJoinIds}")
    public AjaxResult remove(@PathVariable Long[] memberJoinIds)
    {
        return toAjax(tbMemberJoinService.deleteTbMemberJoinByMemberJoinIds(memberJoinIds));
    }
}
