package cn.iocoder.yudao.module.jx.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.jx.core.controller.BaseController;
import cn.iocoder.yudao.module.jx.domain.DriveSchoolFeedback;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolFeedbackService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 反馈Controller
 *
 * @author ruoyi
 * @date 2024-04-27
 */
@RestController
@RequestMapping("/system/feedback")
public class DriveSchoolFeedbackController extends BaseController
{
    @Resource
    private IDriveSchoolFeedbackService driveSchoolFeedbackService;

    @GetMapping("/insertData/{content}")
    public void insertData(@PathVariable("content") String content) {
        driveSchoolFeedbackService.insertData(content);
    }

    /**
     * 查询反馈列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolFeedback driveSchoolFeedback)
    {
        Page<DriveSchoolFeedback> page = new Page<>(driveSchoolFeedback.getPageNum(), driveSchoolFeedback.getPageSize());
        IPage<DriveSchoolFeedback> driveSchoolFeedbackIPage = driveSchoolFeedbackService.selectDriveSchoolFeedbackList(driveSchoolFeedback, page);
        return CommonResult.success(driveSchoolFeedbackIPage);
    }

    /**
     * 查询反馈列表
     */
    @GetMapping("/like")
    public CommonResult like(DriveSchoolFeedback driveSchoolFeedback)
    {
        return CommonResult.success(driveSchoolFeedbackService.selectDriveSchoolFeedbackListAll(driveSchoolFeedback));
    }


    /**
     * 导出反馈列表
     */
//    @Log(title = "反馈", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolFeedback driveSchoolFeedback)
//    {
//        List<DriveSchoolFeedback> list = driveSchoolFeedbackService.selectDriveSchoolFeedbackList(driveSchoolFeedback);
//        ExcelUtil<DriveSchoolFeedback> util = new ExcelUtil<DriveSchoolFeedback>(DriveSchoolFeedback.class);
//        util.exportExcel(response, list, "反馈数据");
//    }

    /**
     * 获取反馈详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolFeedbackService.selectDriveSchoolFeedbackById(id));
    }

    /**
     * 新增反馈
     */
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolFeedback driveSchoolFeedback) throws Exception {
        return toAjax(driveSchoolFeedbackService.insertDriveSchoolFeedback(driveSchoolFeedback));
    }

    /**
     * 修改反馈
     */
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolFeedback driveSchoolFeedback)
    {
        return toAjax(driveSchoolFeedbackService.updateDriveSchoolFeedback(driveSchoolFeedback));
    }

    /**
     * 删除反馈
     */
    @DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolFeedbackService.deleteDriveSchoolFeedbackByIds(ids));
    }
}
