Commit 5b499553 authored by liming's avatar liming

课程列表

parent d494f1d2
......@@ -5,10 +5,7 @@ import com.antai.sport.http.server.management.api.business.course.dto.CoursePage
import com.antai.sport.http.server.management.api.business.course.service.CourseService;
import com.antai.sport.http.server.management.api.business.course.vo.CoursePageVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -25,4 +22,17 @@ public class CourseController {
public ResponseEntity<Result<CoursePageVO>> getCoursePage(@RequestBody CoursePageDTO dto) {
return success(courseService.getCoursePage(dto));
}
@PutMapping("/{id}")
public ResponseEntity<Result> changeCourseStatus(@PathVariable Long id) {
courseService.changeCourseStatus(id);
return success();
}
@DeleteMapping("/{id}")
public ResponseEntity<Result> deleteCourse(@PathVariable Long id) {
courseService.deleteCourse(id);
return success();
}
}
......@@ -4,6 +4,7 @@ import com.antai.sport.http.server.management.api.business.course.dto.CoursePage
import com.antai.sport.http.server.management.api.business.course.mapper.CourseBusinessMapper;
import com.antai.sport.http.server.management.api.business.course.vo.CoursePageVO;
import com.antai.sport.http.server.repository.course.entity.Course;
import com.antai.sport.http.server.repository.course.mapper.CourseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -13,19 +14,37 @@ import javax.annotation.Resource;
@Service
public class CourseService {
@Resource
private CourseMapper courseMapper;
@Resource
private CourseBusinessMapper courseBusinessMapper;
public CoursePageVO getCoursePage(CoursePageDTO dto){
public CoursePageVO getCoursePage(CoursePageDTO dto) {
CoursePageVO result = new CoursePageVO();
result.setPageNo(dto.getPageNo());
Page<Course> pageParam = new Page<>(dto.getPageNo(),dto.getPageSize());
pageParam.addOrder(new OrderItem("id",false));
Page<Course> pageParam = new Page<>(dto.getPageNo(), dto.getPageSize());
pageParam.addOrder(new OrderItem("id", false));
IPage<Course> coursePage = courseBusinessMapper.getCoursePage(pageParam);
result.setData(coursePage.getRecords());
result.setTotalCount(coursePage.getTotal());
return result;
}
public void changeCourseStatus(Long id) {
Course course = courseMapper.selectById(id);
if (course.getStatus() == 10) {
course.setStatus(20);
} else {
course.setStatus(10);
}
courseMapper.updateById(course);
}
public void deleteCourse(Long id) {
Course course = courseMapper.selectById(id);
course.setDeleted(1);
courseMapper.updateById(course);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment