package com.xunmei.core.edu.controller;


import com.xunmei.common.core.domain.edu.domain.CoreEduTrainingTask;
import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingTaskEditDto;
import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingTaskPageDto;
import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingTaskReportDto;
import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingTaskSignDto;
import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingTaskPageVo;
import com.xunmei.common.core.web.controller.BaseController;
import com.xunmei.common.core.web.domain.AjaxResult;
import com.xunmei.common.core.web.page.TableDataInfo;
import com.xunmei.common.log.annotation.Log;
import com.xunmei.common.log.enums.BusinessType;
import com.xunmei.common.security.annotation.RequiresPermissions;
import com.xunmei.core.edu.service.ICoreEduTrainingTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 教育任务Controller
 *
 * @author xunmei
 * @date 2023-08-27
 */
@Api(tags = {"CoreEduTrainingTask"})
@RestController
@RequestMapping("/eduTask")
public class CoreEduTrainingTaskController extends BaseController {
    @Autowired
    private ICoreEduTrainingTaskService coreEduTrainingTaskService;

    /**
     * 查询教育任务列表
     */
    @ApiOperation(value = "查询CoreEduTrainingTask列表")
    @RequiresPermissions("core:eduTask:list")
    @GetMapping("/list")
    public TableDataInfo<CoreEduTrainingTaskPageVo> list(CoreEduTrainingTaskPageDto coreEduTrainingTask) {

        //return  new TableDataInfo<CoreEduTrainingTaskPageVo>();
        return coreEduTrainingTaskService.selectPage(coreEduTrainingTask);
    }


    /**
     * 获取教育任务详细信息
     */
    @ApiOperation(value = "获取CoreEduTrainingTask详细信息")
    @RequiresPermissions("core:eduTask:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(coreEduTrainingTaskService.selectCoreEduTrainingTaskById(id));
    }

    /**
     * 新增教育任务
     */
    @ApiOperation(value = "新增CoreEduTrainingTask")
    @RequiresPermissions("core:eduTask:add")
    @Log(title = "教育任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CoreEduTrainingTask coreEduTrainingTask) {
        return toAjax(coreEduTrainingTaskService.insertCoreEduTrainingTask(coreEduTrainingTask));
    }

    /**
     * 修改教育任务
     */
    @ApiOperation(value = "修改CoreEduTrainingTask")
    @RequiresPermissions("core:eduTask:edit")
    @Log(title = "教育任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Validated CoreEduTrainingTaskEditDto coreEduTrainingTask) {
        return toAjax(coreEduTrainingTaskService.updateCoreEduTrainingTask(coreEduTrainingTask));
    }

    /**
     * 删除教育任务
     */
    @ApiOperation(value = "删除CoreEduTrainingTask")
    @RequiresPermissions("core:eduTask:remove")
    @Log(title = "教育任务", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(coreEduTrainingTaskService.deleteCoreEduTrainingTaskByIds(ids));
    }

    /**
     * 导出教育任务
     */
    @ApiOperation(value = "导出CoreEduTrainingTask")
    @RequiresPermissions("core:eduTask:export")
    @Log(title = "教育任务", businessType = BusinessType.DELETE)
    @DeleteMapping("export")
    public AjaxResult export() {
        return null;
    }

    /**
     * 导出教育任务
     */
    @ApiOperation(value = "导出CoreEduTrainingTask")
    @RequiresPermissions("core:eduTask:report")
    @DeleteMapping("report")
    public AjaxResult report(@RequestBody @Validated CoreEduTrainingTaskReportDto request) {
        return success(coreEduTrainingTaskService.selectCoreEduTrainingTaskReport(request));
    }

    @ApiOperation(value = "教育培训签名")
    @RequiresPermissions("core:eduTask:sign")
    @Log(title = "教育任务签名", businessType = BusinessType.DELETE)
    @DeleteMapping("sign")
    public AjaxResult sign(@RequestBody @Validated CoreEduTrainingTaskSignDto request) {
        return success(coreEduTrainingTaskService.selectCoreEduTrainingTaskSign(request));
    }
}
