package com.ruoyi.web.controller.learn;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.learn.domain.LearnKnowledgeCourse;
import com.ruoyi.learn.service.ILearnKnowledgeCourseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 同步知识点树Controller
 * 
 * @author ruoyi
 * @date 2025-11-04
 */
@RestController
@RequestMapping("/learn/learnKnowledgeCourse")
public class LearnKnowledgeCourseController extends BaseController
{
    @Autowired
    private ILearnKnowledgeCourseService learnKnowledgeCourseService;

    /**
     * 查询同步知识点树列表
     */
    @PreAuthorize("@ss.hasPermi('learn:learnKnowledgeCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(LearnKnowledgeCourse learnKnowledgeCourse)
    {
        startPage();
        List<LearnKnowledgeCourse> list = learnKnowledgeCourseService.selectLearnKnowledgeCourseList(learnKnowledgeCourse);
        return getDataTable(list);
    }

    /**
     * 导出同步知识点树列表
     */
    @PreAuthorize("@ss.hasPermi('learn:learnKnowledgeCourse:export')")
    @Log(title = "同步知识点树", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LearnKnowledgeCourse learnKnowledgeCourse)
    {
        List<LearnKnowledgeCourse> list = learnKnowledgeCourseService.selectLearnKnowledgeCourseList(learnKnowledgeCourse);
        ExcelUtil<LearnKnowledgeCourse> util = new ExcelUtil<LearnKnowledgeCourse>(LearnKnowledgeCourse.class);
        util.exportExcel(response, list, "同步知识点树数据");
    }

    /**
     * 获取同步知识点树详细信息
     */
    @PreAuthorize("@ss.hasPermi('learn:learnKnowledgeCourse:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(learnKnowledgeCourseService.selectLearnKnowledgeCourseById(id));
    }

    /**
     * 新增同步知识点树
     */
    @PreAuthorize("@ss.hasPermi('learn:learnKnowledgeCourse:add')")
    @Log(title = "同步知识点树", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LearnKnowledgeCourse learnKnowledgeCourse)
    {
        return toAjax(learnKnowledgeCourseService.insertLearnKnowledgeCourse(learnKnowledgeCourse));
    }

    /**
     * 修改同步知识点树
     */
    @PreAuthorize("@ss.hasPermi('learn:learnKnowledgeCourse:edit')")
    @Log(title = "同步知识点树", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LearnKnowledgeCourse learnKnowledgeCourse)
    {
        return toAjax(learnKnowledgeCourseService.updateLearnKnowledgeCourse(learnKnowledgeCourse));
    }

    /**
     * 删除同步知识点树
     */
    @PreAuthorize("@ss.hasPermi('learn:learnKnowledgeCourse:remove')")
    @Log(title = "同步知识点树", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(learnKnowledgeCourseService.deleteLearnKnowledgeCourseByIds(ids));
    }
}
