package com.ruoyi.web.controller.care;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.care.domain.CareScores;
import com.ruoyi.care.service.ICareScoresService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务评分Controller
 * 
 * @author qy
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/care/scores")
public class CareScoresController extends BaseController
{
    @Autowired
    private ICareScoresService careScoresService;

    /**
     * 查询业务评分列表
     */
    @PreAuthorize("@ss.hasPermi('care:scores:list')")
    @GetMapping("/list")
    public TableDataInfo list(CareScores careScores)
    {
        startPage();
        List<CareScores> list = careScoresService.selectCareScoresList(careScores);
        return getDataTable(list);
    }

    /**
     * 导出业务评分列表
     */
    @PreAuthorize("@ss.hasPermi('care:scores:export')")
    @Log(title = "业务评分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CareScores careScores)
    {
        List<CareScores> list = careScoresService.selectCareScoresList(careScores);
        ExcelUtil<CareScores> util = new ExcelUtil<CareScores>(CareScores.class);
        util.exportExcel(response, list, "业务评分数据");
    }

    /**
     * 获取业务评分详细信息
     */
    @PreAuthorize("@ss.hasPermi('care:scores:query')")
    @GetMapping(value = "/{scoreId}")
    public AjaxResult getInfo(@PathVariable("scoreId") Long scoreId)
    {
        return success(careScoresService.selectCareScoresByScoreId(scoreId));
    }

    /**
     * 新增业务评分
     */
    @PreAuthorize("@ss.hasPermi('care:scores:add')")
    @Log(title = "业务评分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CareScores careScores)
    {
        return toAjax(careScoresService.insertCareScores(careScores));
    }

    /**
     * 修改业务评分
     */
    @PreAuthorize("@ss.hasPermi('care:scores:edit')")
    @Log(title = "业务评分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CareScores careScores)
    {
        return toAjax(careScoresService.updateCareScores(careScores));
    }

    /**
     * 删除业务评分
     */
    @PreAuthorize("@ss.hasPermi('care:scores:remove')")
    @Log(title = "业务评分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scoreIds}")
    public AjaxResult remove(@PathVariable Long[] scoreIds)
    {
        return toAjax(careScoresService.deleteCareScoresByScoreIds(scoreIds));
    }
}
