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.CourseProjectTypeVo;
import com.zhongzheng.modules.course.bo.CourseProjectTypeQueryBo;
import com.zhongzheng.modules.course.bo.CourseProjectTypeAddBo;
import com.zhongzheng.modules.course.bo.CourseProjectTypeEditBo;
import com.zhongzheng.modules.course.service.ICourseProjectTypeService;
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/projectType")
public class CourseProjectTypeController extends BaseController {

    private final ICourseProjectTypeService iCourseProjectTypeService;

    /**
     * 查询项目类型列表
     */
    @ApiOperation("查询项目类型列表")
    @PreAuthorize("@ss.hasPermi('course:type:list')")
    @GetMapping("/list")
    public TableDataInfo<CourseProjectTypeVo> list(CourseProjectTypeQueryBo bo) {
        startPage();
        List<CourseProjectTypeVo> list = iCourseProjectTypeService.queryList(bo);
        return getDataTable(list);
    }

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

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

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

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

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