package com.zhongzheng.controller.course;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
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.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.course.vo.CourseEducationTypeVo;
import com.zhongzheng.modules.course.bo.CourseEducationTypeQueryBo;
import com.zhongzheng.modules.course.bo.CourseEducationTypeAddBo;
import com.zhongzheng.modules.course.bo.CourseEducationTypeEditBo;
import com.zhongzheng.modules.course.service.ICourseEducationTypeService;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 教育类型Controller
 * 
 * @author ruoyi
 * @date 2021-10-08
 */
@Api(value = "教育类型控制器", tags = {"教育类型管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/course/educationType")
public class CourseEducationTypeController extends BaseController {

    private final ICourseEducationTypeService iCourseEducationTypeService;

    /**
     * 查询教育类型列表
     */
    @ApiOperation("查询教育类型列表")
    @PreAuthorize("@ss.hasPermi('course:type:list')")
    @GetMapping("/list")
    public TableDataInfo<CourseEducationTypeVo> list(CourseEducationTypeQueryBo bo) {
        startPage();
        List<CourseEducationTypeVo> list = iCourseEducationTypeService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出教育类型列表
     */
/*    @ApiOperation("导出教育类型列表")
    @PreAuthorize("@ss.hasPermi('course:type:export')")
    @Log(title = "教育类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<CourseEducationTypeVo> export(CourseEducationTypeQueryBo bo) {
        List<CourseEducationTypeVo> list = iCourseEducationTypeService.queryList(bo);
        ExcelUtil<CourseEducationTypeVo> util = new ExcelUtil<CourseEducationTypeVo>(CourseEducationTypeVo.class);
        return util.exportExcel(list, "教育类型");
    }*/

    /**
     * 获取教育类型详细信息
     */
    @ApiOperation("获取教育类型详细信息")
    @PreAuthorize("@ss.hasPermi('course:type:query')")
    @GetMapping("/{id}")
    public AjaxResult<CourseEducationTypeVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iCourseEducationTypeService.queryById(id));
    }

    /**
     * 新增教育类型
     */
    @ApiOperation("新增教育类型")
    @PreAuthorize("@ss.hasPermi('course:type:add')")
    @Log(title = "教育类型", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody CourseEducationTypeAddBo bo) {
        return toAjax(iCourseEducationTypeService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改教育类型
     */
    @ApiOperation("修改教育类型")
    @PreAuthorize("@ss.hasPermi('course:type:edit')")
    @Log(title = "教育类型", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody CourseEducationTypeEditBo bo) {
        return toAjax(iCourseEducationTypeService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除教育类型
     */
/*    @ApiOperation("删除教育类型")
    @PreAuthorize("@ss.hasPermi('course:type:remove')")
    @Log(title = "教育类型" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@PathVariable Long[] ids) {
        return toAjax(iCourseEducationTypeService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }*/
}
