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.DriveSchoolTeachingJournal;
import cn.iocoder.yudao.module.jx.service.IDriveSchoolTeachingJournalService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 教学日志Controller
 *
 * @author ruoyi
 * @date 2024-05-19
 */
@RestController
@RequestMapping("/drivingSchool/system/journal")
public class DriveSchoolTeachingJournalController extends BaseController
{
    @Autowired
    private IDriveSchoolTeachingJournalService driveSchoolTeachingJournalService;

    /**
     * 查询教学日志列表
     */
    @GetMapping("/list")
    public CommonResult<IPage<?>> list(DriveSchoolTeachingJournal driveSchoolTeachingJournal)
    {
        Page<DriveSchoolTeachingJournal> page = new Page<>(driveSchoolTeachingJournal.getPageNum(), driveSchoolTeachingJournal.getPageSize());
        return success(driveSchoolTeachingJournalService.selectDriveSchoolTeachingJournalList(driveSchoolTeachingJournal,page));
    }

    /**
     * 导出教学日志列表
     */
    //@Log(title = "教学日志", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, DriveSchoolTeachingJournal driveSchoolTeachingJournal)
//    {
//        Page<DriveSchoolTeachingJournal> page = new Page<>(driveSchoolTeachingJournal.getPageNum(), driveSchoolTeachingJournal.getPageSize());
//        List<DriveSchoolTeachingJournal> list = driveSchoolTeachingJournalService.selectDriveSchoolTeachingJournalList(driveSchoolTeachingJournal,page);
//        ExcelUtil<DriveSchoolTeachingJournal> util = new ExcelUtil<DriveSchoolTeachingJournal>(DriveSchoolTeachingJournal.class);
//        util.exportExcel(response, list, "教学日志数据");
//    }

    /**
     * 获取教学日志详细信息
     */
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(driveSchoolTeachingJournalService.selectDriveSchoolTeachingJournalById(id));
    }

    /**
     * 新增教学日志
     */
    //@Log(title = "教学日志", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody DriveSchoolTeachingJournal driveSchoolTeachingJournal)
    {
        return toAjax(driveSchoolTeachingJournalService.insertDriveSchoolTeachingJournal(driveSchoolTeachingJournal));
    }

    /**
     * 修改教学日志
     */
    //@Log(title = "教学日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody DriveSchoolTeachingJournal driveSchoolTeachingJournal)
    {
        return toAjax(driveSchoolTeachingJournalService.updateDriveSchoolTeachingJournal(driveSchoolTeachingJournal));
    }

    /**
     * 删除教学日志
     */
    //@Log(title = "教学日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(driveSchoolTeachingJournalService.deleteDriveSchoolTeachingJournalByIds(ids));
    }
}
