package top.awin_x.learn.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.awin_x.learn.pojo.CourseInfo;
import top.awin_x.learn.pojo.Result;
import top.awin_x.learn.service.CourseService;
import top.awin_x.learn.service.impl.CourseServiceImpl;

import java.util.ArrayList;

@RestController
public class CourseController {
    @Autowired
    private CourseService courseService;

    @RequestMapping("/courseAction/list")
    public Result listCourse(Integer page, Integer pageSize, String keyword, Integer type) {
        ArrayList<CourseInfo> list = courseService.listCourses(page, pageSize, keyword, type);
        return Result.success(list);
    }
    @RequestMapping("/courseAction/edit")
    public Result editCourse(CourseInfo course) {
        return Result.success(new CourseServiceImpl().editCourse(course));
    }
}
