forked from pyia8e6p9/student_system
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
53 lines
1.4 KiB
package com.example.controller;
|
|
|
|
import com.example.common.Result;
|
|
import com.example.entity.Course;
|
|
import com.example.service.CourseService;
|
|
import com.github.pagehelper.PageInfo;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@RestController
|
|
@RequestMapping("/course")
|
|
public class CourseController {
|
|
|
|
@Resource
|
|
private CourseService courseService;
|
|
/**
|
|
* 分页条件查询课程
|
|
*/
|
|
@GetMapping("/selectPage")
|
|
public Result selectPage(@RequestParam(defaultValue = "1") Integer pageNum,
|
|
@RequestParam(defaultValue = "5") Integer pageSize,
|
|
Course course){
|
|
PageInfo<Course> pageInfo = courseService.selectPage(pageNum, pageSize,course);
|
|
return Result.success(pageInfo);
|
|
}
|
|
/**
|
|
* 新增课程
|
|
*/
|
|
@PostMapping("/add")
|
|
public Result add(@RequestBody Course course){
|
|
courseService.add(course);
|
|
return Result.success();
|
|
}
|
|
/**
|
|
* 更新课程
|
|
*/
|
|
@PutMapping("/update")
|
|
public Result update(@RequestBody Course course){
|
|
courseService.updateById(course);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 删除课程
|
|
*/
|
|
@DeleteMapping("/delete/{id}")
|
|
public Result delete(@PathVariable Integer id){
|
|
courseService.deleteById(id);
|
|
return Result.success();
|
|
}
|
|
}
|