package com.fs.course.controller;

import java.util.List;

import com.fs.common.core.domain.R;
import com.fs.course.vo.FsUserCourseComplaintRecordPageListVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.course.domain.FsUserCourseComplaintRecord;
import com.fs.course.service.IFsUserCourseComplaintRecordService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 看课投诉记录Controller
 *
 * @author fs
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/course/userCourseComplaintRecord")
public class FsUserCourseComplaintRecordController extends BaseController
{
    @Autowired
    private IFsUserCourseComplaintRecordService fsUserCourseComplaintRecordService;

    /**
     * 查询看课投诉记录列表
     */
    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:list')")
    @GetMapping("/list")
    public R list(FsUserCourseComplaintRecord fsUserCourseComplaintRecord)
    {
//        startPage();
        PageHelper.startPage(fsUserCourseComplaintRecord.getPageNum(), fsUserCourseComplaintRecord.getPageSize());
        List<FsUserCourseComplaintRecordPageListVO> list = fsUserCourseComplaintRecordService.selectFsUserCourseComplaintRecordList(fsUserCourseComplaintRecord);
        PageInfo<FsUserCourseComplaintRecordPageListVO> pageInfo = new PageInfo<>(list);
        return R.ok().put("rows", pageInfo);
    }

    /**
     * 导出看课投诉记录列表
     */
    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:export')")
    @Log(title = "看课投诉记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserCourseComplaintRecord fsUserCourseComplaintRecord)
    {
        List<FsUserCourseComplaintRecordPageListVO> list = fsUserCourseComplaintRecordService.selectFsUserCourseComplaintRecordList(fsUserCourseComplaintRecord);
        ExcelUtil<FsUserCourseComplaintRecordPageListVO> util = new ExcelUtil<>(FsUserCourseComplaintRecordPageListVO.class);
        return util.exportExcel(list, "看课投诉记录");
    }

    /**
     * 获取看课投诉记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(fsUserCourseComplaintRecordService.selectFsUserCourseComplaintRecordByRecordId(recordId));
    }

    /**
    * 获取 看课投诉记录详细信息-客户所属关系
    */
    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:queryQw')")
    @GetMapping(value = "/getInfoByUserId/{userId}")
    public AjaxResult getInfoByUserId(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(fsUserCourseComplaintRecordService.selectFsUserCourseComplaintRecordByUserId(userId));
    }

    /**
     * 新增看课投诉记录
     */
    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:add')")
    @Log(title = "看课投诉记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserCourseComplaintRecord fsUserCourseComplaintRecord)
    {
        return toAjax(fsUserCourseComplaintRecordService.insertFsUserCourseComplaintRecord(fsUserCourseComplaintRecord));
    }

    /**
     * 修改看课投诉记录
     */
    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:edit')")
    @Log(title = "看课投诉记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserCourseComplaintRecord fsUserCourseComplaintRecord)
    {
        return toAjax(fsUserCourseComplaintRecordService.updateFsUserCourseComplaintRecord(fsUserCourseComplaintRecord));
    }

    /**
     * 删除看课投诉记录
     */
    @PreAuthorize("@ss.hasPermi('course:userCourseComplaintRecord:remove')")
    @Log(title = "看课投诉记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(fsUserCourseComplaintRecordService.deleteFsUserCourseComplaintRecordByRecordIds(recordIds));
    }
}
