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.TbMemberSubjectAll;
import com.ruoyi.hezhi.service.ITbMemberSubjectAllService;
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-06
 */
@RestController
@RequestMapping("/hezhi/memberSubjectAll")
public class TbMemberSubjectAllController extends BaseController
{
    @Autowired
    private ITbMemberSubjectAllService tbMemberSubjectAllService;

    /**
     * 查询我的题目列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberSubjectAll:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMemberSubjectAll tbMemberSubjectAll)
    {
        startPage();
        List<TbMemberSubjectAll> list = tbMemberSubjectAllService.selectTbMemberSubjectAllList(tbMemberSubjectAll);
        return getDataTable(list);
    }

    /**
     * 导出我的题目列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberSubjectAll:export')")
    @Log(title = "我的题目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMemberSubjectAll tbMemberSubjectAll)
    {
        List<TbMemberSubjectAll> list = tbMemberSubjectAllService.selectTbMemberSubjectAllList(tbMemberSubjectAll);
        ExcelUtil<TbMemberSubjectAll> util = new ExcelUtil<TbMemberSubjectAll>(TbMemberSubjectAll.class);
        util.exportExcel(response, list, "我的题目数据");
    }

    /**
     * 获取我的题目详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberSubjectAll:query')")
    @GetMapping(value = "/{memberSubjectAllId}")
    public AjaxResult getInfo(@PathVariable("memberSubjectAllId") Long memberSubjectAllId)
    {
        return success(tbMemberSubjectAllService.selectTbMemberSubjectAllByMemberSubjectAllId(memberSubjectAllId));
    }

    /**
     * 新增我的题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberSubjectAll:add')")
    @Log(title = "我的题目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMemberSubjectAll tbMemberSubjectAll)
    {
        return toAjax(tbMemberSubjectAllService.insertTbMemberSubjectAll(tbMemberSubjectAll));
    }

    /**
     * 修改我的题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberSubjectAll:edit')")
    @Log(title = "我的题目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMemberSubjectAll tbMemberSubjectAll)
    {
        return toAjax(tbMemberSubjectAllService.updateTbMemberSubjectAll(tbMemberSubjectAll));
    }

    /**
     * 删除我的题目
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberSubjectAll:remove')")
    @Log(title = "我的题目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberSubjectAllIds}")
    public AjaxResult remove(@PathVariable Long[] memberSubjectAllIds)
    {
        return toAjax(tbMemberSubjectAllService.deleteTbMemberSubjectAllByMemberSubjectAllIds(memberSubjectAllIds));
    }
}
