Update CourseController.java

master
pria8sljn 2 years ago
parent ee90e49032
commit b286e87fa2

@ -4,28 +4,46 @@ 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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("/course")
public class CourseController {
public class CourserController {
@Resource
private CourseService courseService;
/** 分页条件查询课程*/
@GetMapping("/selectPage")
public Result selectPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam String name) {
PageInfo<Course> pageInfo = courseService.selectPage(pageNum, pageSize, name);
Course course) { // ?name=xx&no=xx
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();
}
}

Loading…
Cancel
Save