parent
79a8fd2444
commit
3b2394b77d
16 changed files with 519 additions and 42 deletions
@ -0,0 +1,74 @@ |
||||
package com.teaching.backend.controller.chapter; |
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.model.dto.chapter.ChapterDTO; |
||||
import com.teaching.backend.model.entity.chapter.Chapter; |
||||
import com.teaching.backend.service.chapter.IChapterService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* ClassName: ChapterController2 |
||||
* Package: com.teaching.backend.controller.chapter |
||||
* Description: |
||||
* |
||||
* @Author 姜钧瀚 |
||||
* @Create 2024/7/23 17:16 |
||||
* @Version 1.0 |
||||
*/ |
||||
@Api(tags = "课程章节管理接口2") |
||||
@RestController |
||||
@RequestMapping("/chapter2") |
||||
public class ChapterController2 { |
||||
|
||||
@Autowired |
||||
IChapterService chapterService; |
||||
|
||||
@ApiOperation("查询全部的章节") |
||||
@GetMapping("/list") |
||||
public BaseResponse<List<Chapter>> AllList(){ |
||||
List<Chapter> list= chapterService.list(); |
||||
return ResultUtils.success(list); |
||||
} |
||||
|
||||
@ApiOperation("根据课程id查出对应的父子章节") |
||||
@GetMapping("/chapter") |
||||
public BaseResponse<List<Chapter>> getCourseChapters2(@RequestParam String courseId){ |
||||
return ResultUtils.success(chapterService.getChapterTree(courseId)); |
||||
|
||||
} |
||||
|
||||
|
||||
@ApiOperation("添加章节") |
||||
@PostMapping("/add") |
||||
public BaseResponse<String> addChapter2(@RequestBody ChapterDTO chapterDTO){ |
||||
chapterService.saveChapter(chapterDTO); |
||||
return ResultUtils.success("添加成功!!!!!!!!"); |
||||
} |
||||
|
||||
@ApiOperation("删除章节") |
||||
@DeleteMapping("/delete/{id}") |
||||
public BaseResponse<String> dlChapter(@PathVariable String id){ |
||||
chapterService.deleteChapter(id); |
||||
return ResultUtils.success("删除成功"); |
||||
} |
||||
|
||||
|
||||
@ApiOperation("修改章节") |
||||
@PutMapping("/update") |
||||
public BaseResponse<String> udChapter(@RequestBody Chapter chapter){ |
||||
|
||||
chapter.setUpdateTime(LocalDateTime.now()); |
||||
chapterService.updateById(chapter); |
||||
return ResultUtils.success("修改成功"); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
@ -0,0 +1,91 @@ |
||||
package com.teaching.backend.controller.courses; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ErrorCode; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.exception.BusinessException; |
||||
import com.teaching.backend.filter.ValidateParams; |
||||
import com.teaching.backend.mapper.courses.CoursesMapper; |
||||
import com.teaching.backend.model.dto.courses.CoursesDTO; |
||||
import com.teaching.backend.model.entity.CourseResources; |
||||
import com.teaching.backend.model.entity.ResourceRelationship; |
||||
import com.teaching.backend.model.entity.courses.Courses; |
||||
import com.teaching.backend.model.vo.courses.CoursesVO; |
||||
import com.teaching.backend.service.courses.ICoursesService; |
||||
import com.teaching.backend.service.resource.ResourcesRelationshipService; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* ClassName: CoursesController2 |
||||
* Package: com.teaching.backend.controller.courses |
||||
* Description: |
||||
* |
||||
* @Author 姜钧瀚 |
||||
* @Create 2024/7/22 17:52 |
||||
* @Version 1.0 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/api/coursesteacher2") |
||||
public class CoursesController2 { |
||||
@Autowired |
||||
ICoursesService coursesService; |
||||
@Autowired |
||||
ResourcesRelationshipService resourcesRelationshipService; |
||||
|
||||
@ApiOperation("网站首页2") |
||||
@GetMapping("/index2") |
||||
public BaseResponse<Map<String,Object>> getData(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize) { |
||||
Map<String, Object> result = coursesService.getPagePageSize2(page, pageSize); |
||||
|
||||
// 将结果放入新的Map对象中返回
|
||||
Map<String, Object> objectMap = new HashMap<>(); |
||||
objectMap.put("content", result.get("courses")); |
||||
objectMap.put("totalcount", result.get("totalcount")); |
||||
objectMap.put("totalPages", result.get("totalPages")); |
||||
objectMap.put("currentPage", result.get("currentPage")); |
||||
|
||||
return ResultUtils.success(objectMap); |
||||
} |
||||
|
||||
|
||||
@ApiOperation("根据id查询课程") |
||||
@ValidateParams({"id"}) |
||||
@GetMapping("/{id}") |
||||
public BaseResponse<CoursesDTO> getByIdCourse(@PathVariable String id){ |
||||
if(id==null){ |
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR,"课程id为空"); |
||||
} |
||||
Courses course = coursesService.getById(id); |
||||
CoursesDTO coursesDTO = new CoursesDTO(); |
||||
BeanUtils.copyProperties(course,coursesDTO); |
||||
return ResultUtils.success(coursesDTO); |
||||
} |
||||
|
||||
@ApiOperation("点击详情课程根据id查询对应课程的资源") |
||||
@GetMapping("/resource/{id}") |
||||
public BaseResponse<List<CourseResources>> getResource(@PathVariable String id) { |
||||
List<CourseResources> relatedResources = resourcesRelationshipService.getResource(id); |
||||
return ResultUtils.success(relatedResources); |
||||
} |
||||
|
||||
@ApiOperation("点击详情课程根据id和type查询对应课程的资源") |
||||
@GetMapping("/resource/list") |
||||
public BaseResponse<List<CourseResources>> getResource2(@RequestParam String id,@RequestParam Integer type) { |
||||
List<CourseResources> relatedResources = resourcesRelationshipService.getResource2(id,type); |
||||
return ResultUtils.success(relatedResources); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,89 @@ |
||||
package com.teaching.backend.model.dto.chapter; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import javax.xml.soap.Text; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* ClassName: ChapterDTO |
||||
* Package: com.teaching.backend.model.dto.chapter |
||||
* Description: |
||||
* |
||||
* @Author 姜钧瀚 |
||||
* @Create 2024/7/23 23:16 |
||||
* @Version 1.0 |
||||
*/ |
||||
@Data |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class ChapterDTO implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "创建人") |
||||
private String createBy; |
||||
|
||||
|
||||
@ApiModelProperty(value = "创建日期") |
||||
private LocalDateTime createTime; |
||||
|
||||
@ApiModelProperty(value = "更新人") |
||||
private String updateBy; |
||||
|
||||
@ApiModelProperty(value = "更新日期") |
||||
private LocalDateTime updateTime; |
||||
|
||||
@ApiModelProperty(value = "所属部门") |
||||
private String sysOrgCode; |
||||
|
||||
@ApiModelProperty(value = "序号") |
||||
private int orderNum; |
||||
|
||||
@ApiModelProperty(value = "章节名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "简介") |
||||
private String content; |
||||
|
||||
@ApiModelProperty(value = "父章节") |
||||
private String pid; |
||||
|
||||
@ApiModelProperty(value = "课程id") |
||||
private String courseId; |
||||
|
||||
@ApiModelProperty(value = "课程目标") |
||||
private String courseObjectivesId; |
||||
|
||||
@ApiModelProperty(value = "总学时") |
||||
private String totalClassHours; |
||||
|
||||
@ApiModelProperty(value = "要求") |
||||
private String requirement; |
||||
|
||||
|
||||
@ApiModelProperty(value = "线上学时") |
||||
private String onlineClassHours; |
||||
|
||||
@ApiModelProperty(value = "周次") |
||||
private String zc; |
||||
|
||||
@ApiModelProperty(value = "资源") |
||||
private String ziyuan; |
||||
|
||||
@ApiModelProperty(value = "资源文件") |
||||
private String zywj; |
||||
|
||||
@ApiModelProperty(value = "内部序号显示") |
||||
private String numshow; |
||||
|
||||
|
||||
|
||||
|
||||
} |
Loading…
Reference in new issue