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.TbMemberScore;
import com.ruoyi.hezhi.service.ITbMemberScoreService;
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-10-31
 */
@RestController
@RequestMapping("/hezhi/memberScore")
public class TbMemberScoreController extends BaseController
{
    @Autowired
    private ITbMemberScoreService tbMemberScoreService;

    /**
     * 查询用户积分详情列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberScore:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMemberScore tbMemberScore)
    {
        startPage();
        List<TbMemberScore> list = tbMemberScoreService.selectTbMemberScoreList(tbMemberScore);
        return getDataTable(list);
    }

    /**
     * 导出用户积分详情列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberScore:export')")
    @Log(title = "用户积分详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMemberScore tbMemberScore)
    {
        List<TbMemberScore> list = tbMemberScoreService.selectTbMemberScoreList(tbMemberScore);
        ExcelUtil<TbMemberScore> util = new ExcelUtil<TbMemberScore>(TbMemberScore.class);
        util.exportExcel(response, list, "用户积分详情数据");
    }

    /**
     * 获取用户积分详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberScore:query')")
    @GetMapping(value = "/{memberScoreId}")
    public AjaxResult getInfo(@PathVariable("memberScoreId") Long memberScoreId)
    {
        return success(tbMemberScoreService.selectTbMemberScoreByMemberScoreId(memberScoreId));
    }

    /**
     * 新增用户积分详情
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberScore:add')")
    @Log(title = "用户积分详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMemberScore tbMemberScore)
    {
        return toAjax(tbMemberScoreService.insertTbMemberScore(tbMemberScore));
    }

    /**
     * 修改用户积分详情
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberScore:edit')")
    @Log(title = "用户积分详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMemberScore tbMemberScore)
    {
        return toAjax(tbMemberScoreService.updateTbMemberScore(tbMemberScore));
    }

    /**
     * 删除用户积分详情
     */
    @PreAuthorize("@ss.hasPermi('hezhi:memberScore:remove')")
    @Log(title = "用户积分详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{memberScoreIds}")
    public AjaxResult remove(@PathVariable Long[] memberScoreIds)
    {
        return toAjax(tbMemberScoreService.deleteTbMemberScoreByMemberScoreIds(memberScoreIds));
    }
}
