package com.ruoyi.web.controller.member;

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

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.member.MemberAssessmentInfo;
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.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.service.IMemberAssessmentInfoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 委员考核分数Controller
 *
 * @author boman
 * @date 2024-03-20
 */
@RestController
@RequestMapping("/zx/assessmentInfo")
public class MemberAssessmentInfoController extends BaseController
{
    @Autowired
    private IMemberAssessmentInfoService memberAssessmentInfoService;

/**
 * 查询委员考核分数列表
 */
@PreAuthorize("@ss.hasPermi('zx:assessmentInfo:list')")
@GetMapping("/list")
    public TableDataInfo list(MemberAssessmentInfo memberAssessmentInfo)
    {
        startPage();
        List<MemberAssessmentInfo> list = memberAssessmentInfoService.selectMemberAssessmentInfoList(memberAssessmentInfo);
        return getDataTable(list);
    }

    /**
     * 导出委员考核分数列表
     */
    @PreAuthorize("@ss.hasPermi('zx:assessmentInfo:export')")
    @Log(title = "委员考核分数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberAssessmentInfo memberAssessmentInfo)
    {
        List<MemberAssessmentInfo> list = memberAssessmentInfoService.selectMemberAssessmentInfoList(memberAssessmentInfo);
        ExcelUtil<MemberAssessmentInfo> util = new ExcelUtil<MemberAssessmentInfo>(MemberAssessmentInfo.class);
        util.exportExcel(response, list, "委员考核分数数据");
    }

    /**
     * 获取委员考核分数详细信息
     */
    @PreAuthorize("@ss.hasPermi('zx:assessmentInfo:query')")
    @GetMapping(value = "/{memberAssessmentId}")
    public AjaxResult getInfo(@PathVariable("memberAssessmentId") Long memberAssessmentId)
    {
        return success(memberAssessmentInfoService.selectMemberAssessmentInfoByMemberAssessmentId(memberAssessmentId));
    }

    /**
     * 新增委员考核分数
     */
    @PreAuthorize("@ss.hasPermi('zx:assessmentInfo:add')")
    @Log(title = "委员考核分数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberAssessmentInfo memberAssessmentInfo)
    {
        return toAjax(memberAssessmentInfoService.insertMemberAssessmentInfo(memberAssessmentInfo));
    }

    /**
     * 修改委员考核分数
     */
    @PreAuthorize("@ss.hasPermi('zx:assessmentInfo:edit')")
    @Log(title = "委员考核分数", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody MemberAssessmentInfo memberAssessmentInfo)
    {
        return toAjax(memberAssessmentInfoService.updateMemberAssessmentInfo(memberAssessmentInfo));
    }

    /**
     * 删除委员考核分数
     */
    @PreAuthorize("@ss.hasPermi('zx:assessmentInfo:remove')")
    @Log(title = "委员考核分数", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{memberAssessmentIds}")
    public AjaxResult remove(@PathVariable Long[] memberAssessmentIds)
    {
        return toAjax(memberAssessmentInfoService.deleteMemberAssessmentInfoByMemberAssessmentIds(memberAssessmentIds));
    }
}
