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.TbCourseEvaluate;
import com.ruoyi.hezhi.service.ITbCourseEvaluateService;
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-09-14
 */
@RestController
@RequestMapping("/hezhi/courseEvaluate")
public class TbCourseEvaluateController extends BaseController
{
    @Autowired
    private ITbCourseEvaluateService tbCourseEvaluateService;

    /**
     * 查询课程评价列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:courseEvaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbCourseEvaluate tbCourseEvaluate)
    {
        startPage();
        List<TbCourseEvaluate> list = tbCourseEvaluateService.selectTbCourseEvaluateList(tbCourseEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出课程评价列表
     */
    @PreAuthorize("@ss.hasPermi('hezhi:courseEvaluate:export')")
    @Log(title = "课程评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbCourseEvaluate tbCourseEvaluate)
    {
        List<TbCourseEvaluate> list = tbCourseEvaluateService.selectTbCourseEvaluateList(tbCourseEvaluate);
        ExcelUtil<TbCourseEvaluate> util = new ExcelUtil<TbCourseEvaluate>(TbCourseEvaluate.class);
        util.exportExcel(response, list, "课程评价数据");
    }

    /**
     * 获取课程评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('hezhi:courseEvaluate:query')")
    @GetMapping(value = "/{courseEvaluateId}")
    public AjaxResult getInfo(@PathVariable("courseEvaluateId") Long courseEvaluateId)
    {
        return success(tbCourseEvaluateService.selectTbCourseEvaluateByCourseEvaluateId(courseEvaluateId));
    }

    /**
     * 新增课程评价
     */
    @PreAuthorize("@ss.hasPermi('hezhi:courseEvaluate:add')")
    @Log(title = "课程评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbCourseEvaluate tbCourseEvaluate)
    {
        return toAjax(tbCourseEvaluateService.insertTbCourseEvaluate(tbCourseEvaluate));
    }

    /**
     * 修改课程评价
     */
    @PreAuthorize("@ss.hasPermi('hezhi:courseEvaluate:edit')")
    @Log(title = "课程评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbCourseEvaluate tbCourseEvaluate)
    {
        return toAjax(tbCourseEvaluateService.updateTbCourseEvaluate(tbCourseEvaluate));
    }

    /**
     * 删除课程评价
     */
    @PreAuthorize("@ss.hasPermi('hezhi:courseEvaluate:remove')")
    @Log(title = "课程评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courseEvaluateIds}")
    public AjaxResult remove(@PathVariable Long[] courseEvaluateIds)
    {
        return toAjax(tbCourseEvaluateService.deleteTbCourseEvaluateByCourseEvaluateIds(courseEvaluateIds));
    }
}
