Compare commits
6 Commits
639c5af6c1
...
0b216cc4a9
Author | SHA1 | Date |
---|---|---|
youhang20021127 | 0b216cc4a9 | 3 weeks ago |
youhang20021127 | 16070cf855 | 2 months ago |
小萌新 | aeadc75e7a | 2 months ago |
小萌新 | 6a95766592 | 2 months ago |
wenyu441069198 | f0b3b63527 | 2 months ago |
you hang | 8468b6de6a | 3 months ago |
94 changed files with 2830 additions and 1727 deletions
@ -1,80 +1,107 @@ |
||||
package com.teaching.backend.controller.chapter; |
||||
|
||||
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.model.dto.chapter.ChapterAndNodeTreeVO; |
||||
import com.teaching.backend.model.dto.chapter.ChapterDTO; |
||||
import com.teaching.backend.model.entity.chapter.Chapter; |
||||
import com.teaching.backend.model.vo.chapter.ChapterVo; |
||||
import com.teaching.backend.service.chapter.IChapterService; |
||||
import com.teaching.backend.service.impl.chapter.ChapterExcelServiceImpl; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.util.LinkedList; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
import java.io.IOException; |
||||
import java.math.BigDecimal; |
||||
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 = "课程章节管理接口") |
||||
@RestController |
||||
@RequestMapping("/chapter") |
||||
@RequestMapping("/api/chapter") |
||||
public class ChapterController { |
||||
|
||||
@Autowired |
||||
private IChapterService chapterService; |
||||
@ApiOperation("查看所有章节") |
||||
IChapterService chapterService; |
||||
@Autowired |
||||
ChapterExcelServiceImpl chapterExcelService; |
||||
|
||||
@ApiOperation("查询全部的章节") |
||||
@GetMapping("/list") |
||||
public BaseResponse<List<Chapter>> AllList(){ |
||||
List<Chapter> list = chapterService.list(); |
||||
return ResultUtils.success(list); |
||||
} |
||||
@ApiOperation("添加章节") |
||||
@PostMapping("/add") |
||||
public BaseResponse<Boolean> addChapter(@RequestBody Chapter chapter){ |
||||
chapter.setNumshow(chapterService.updateNumShow(chapter)); |
||||
System.out.println("-=-=--=-000"+chapter.getNumshow()); |
||||
boolean save = chapterService.save(chapter); |
||||
return ResultUtils.success(save); |
||||
} |
||||
@ApiOperation("删除章节信息") |
||||
@DeleteMapping("/{id}") |
||||
public BaseResponse<Boolean> delete(@PathVariable String id){ |
||||
Boolean chapter = chapterService.deleteAfterUpdate(id); |
||||
return ResultUtils.success(chapter); |
||||
public BaseResponse<Page<Chapter>> AllList(@RequestParam(value = "page",defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize",defaultValue = "5") int pageSize){ |
||||
return ResultUtils.success(chapterService.getAllChapters(page,pageSize)); |
||||
} |
||||
|
||||
|
||||
@ApiOperation("更新章节") |
||||
@PutMapping |
||||
public BaseResponse<Boolean> updateChapter(@RequestBody Chapter chapter){ |
||||
System.out.println(chapter); |
||||
boolean b = chapterService.updateById(chapter); |
||||
return ResultUtils.success(b); |
||||
// @ApiOperation("根据课程id查出对应的父子章节")
|
||||
// @GetMapping("/chapter")
|
||||
// public BaseResponse<List<Chapter>> getCourseChapters2(@RequestParam String courseId){
|
||||
// return ResultUtils.success(chapterService.getChapterTree(courseId));
|
||||
// }
|
||||
@ApiOperation("根据课程id查出对应的父子章节") |
||||
@GetMapping("/chapter2") |
||||
public BaseResponse<List<ChapterAndNodeTreeVO>> getCourseChapters3(@RequestParam String courseId){ |
||||
return ResultUtils.success(chapterService.getChapterTree2(courseId)); |
||||
} |
||||
@ApiOperation("查看所有章节linkedlist") |
||||
@GetMapping("/listall/{courseid}") |
||||
public BaseResponse<LinkedList<Chapter>> getAll(@PathVariable String courseid){ |
||||
LinkedList<Chapter> list =chapterService.getCourseChapter(courseid); |
||||
System.out.println(list); |
||||
return ResultUtils.success(list); |
||||
|
||||
@ApiOperation("根据课程id查出对应的详细章节信息") |
||||
@GetMapping("/select/chapter/{chapterId}") |
||||
public BaseResponse<Chapter>selectChapter(@PathVariable Long chapterId){ |
||||
return ResultUtils.success(chapterService.selectChapter(chapterId)); |
||||
|
||||
} |
||||
|
||||
@ApiOperation("添加章节") |
||||
@PostMapping("/add") |
||||
public BaseResponse<String> addChapter2(@Valid @RequestBody ChapterDTO chapterDTO) { |
||||
BigDecimal remainingHours = chapterService.saveChapter(chapterDTO); |
||||
if (remainingHours.compareTo(BigDecimal.ZERO) == 0) { |
||||
return ResultUtils.success("添加成功!所有学时分配完成"); |
||||
} else { |
||||
return ResultUtils.success("添加成功!还剩下" + remainingHours + "学时待分配"); |
||||
} |
||||
} |
||||
|
||||
@ApiOperation("章节顺序linkedlist") |
||||
@GetMapping("/aaa/{courseid}") |
||||
public BaseResponse<LinkedList<ChapterVo>> get(@PathVariable String courseid){ |
||||
LinkedList<ChapterVo> list =chapterService.getChapterSection(courseid); |
||||
System.out.println(list); |
||||
return ResultUtils.success(list); |
||||
@ApiOperation("插入章节") |
||||
@PostMapping("/insert") |
||||
public BaseResponse<String> addChapter3(@RequestBody ChapterDTO chapterDTO, Long chapterId1, Long chapterId2){ |
||||
chapterService.insertChapter(chapterId1,chapterId2,chapterDTO); |
||||
return ResultUtils.success("添加成功!!!!!!!!"); |
||||
} |
||||
@ApiOperation("删除章节") |
||||
@DeleteMapping("/delete/{id}") |
||||
public BaseResponse<String> dlChapter(@PathVariable Long id){ |
||||
chapterService.deleteChapter(id); |
||||
return ResultUtils.success("删除成功"); |
||||
} |
||||
|
||||
|
||||
@ApiOperation("计算章的个数") |
||||
@GetMapping("/count/{courseid}") |
||||
public BaseResponse<Long> getChapterCount(@PathVariable String courseid){ |
||||
LinkedList<Chapter> list =chapterService.getCourseChapter(courseid); |
||||
Long count=list.stream() |
||||
.filter( str -> !str.getNumshow().contains("-")) |
||||
.count(); |
||||
return ResultUtils.success(count); |
||||
@ApiOperation("修改章节") |
||||
@PutMapping("/update") |
||||
public BaseResponse<String> udChapter(@RequestBody Chapter chapter){ |
||||
|
||||
chapter.setUpdateTime(LocalDateTime.now()); |
||||
chapterService.updateById(chapter); |
||||
return ResultUtils.success("修改成功"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
@ -1,142 +0,0 @@ |
||||
package com.teaching.backend.controller.chapter; |
||||
|
||||
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.model.dto.chapter.ChapterDTO; |
||||
import com.teaching.backend.model.entity.chapter.Chapter; |
||||
import com.teaching.backend.service.chapter.IChapterService; |
||||
import com.teaching.backend.service.impl.chapter.ChapterExcelServiceImpl; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
import java.io.IOException; |
||||
import java.math.BigDecimal; |
||||
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("/api/chapter2") |
||||
public class ChapterController2 { |
||||
|
||||
@Autowired |
||||
IChapterService chapterService; |
||||
@Autowired |
||||
ChapterExcelServiceImpl chapterExcelService; |
||||
|
||||
@ApiOperation("查询全部的章节") |
||||
@GetMapping("/list") |
||||
public BaseResponse<Page<Chapter>> AllList(@RequestParam(value = "page",defaultValue = "1") int page, |
||||
@RequestParam(value = "pageSize",defaultValue = "5") int pageSize){ |
||||
return ResultUtils.success(chapterService.getAllChapters(page,pageSize)); |
||||
} |
||||
|
||||
|
||||
@ApiOperation("根据课程id查出对应的父子章节") |
||||
@GetMapping("/chapter") |
||||
public BaseResponse<List<Chapter>> getCourseChapters2(@RequestParam String courseId){ |
||||
return ResultUtils.success(chapterService.getChapterTree(courseId)); |
||||
} |
||||
|
||||
@ApiOperation("根据课程id查出对应的详细章节信息") |
||||
@GetMapping("/select/chapter/{chapterId}") |
||||
public BaseResponse<Chapter>selectChapter(@PathVariable Long chapterId){ |
||||
return ResultUtils.success(chapterService.selectChapter(chapterId)); |
||||
|
||||
} |
||||
|
||||
@ApiOperation("添加章节") |
||||
@PostMapping("/add") |
||||
public BaseResponse<String> addChapter2(@Valid @RequestBody ChapterDTO chapterDTO) { |
||||
BigDecimal remainingHours = chapterService.saveChapter(chapterDTO); |
||||
if (remainingHours.compareTo(BigDecimal.ZERO) == 0) { |
||||
return ResultUtils.success("添加成功!所有学时分配完成"); |
||||
} else { |
||||
return ResultUtils.success("添加成功!还剩下" + remainingHours + "学时待分配"); |
||||
} |
||||
} |
||||
|
||||
@ApiOperation("插入章节") |
||||
@PostMapping("/insert") |
||||
public BaseResponse<String> addChapter3(@RequestBody ChapterDTO chapterDTO, Long chapterId1, Long chapterId2){ |
||||
chapterService.insertChapter(chapterId1,chapterId2,chapterDTO); |
||||
return ResultUtils.success("添加成功!!!!!!!!"); |
||||
} |
||||
@ApiOperation("删除章节") |
||||
@DeleteMapping("/delete/{id}") |
||||
public BaseResponse<String> dlChapter(@PathVariable Long id){ |
||||
chapterService.deleteChapter(id); |
||||
return ResultUtils.success("删除成功"); |
||||
} |
||||
|
||||
@ApiOperation("下载Excel模版") |
||||
@GetMapping("/downExcel") |
||||
public void downExcel2(HttpServletResponse response) throws IOException { |
||||
chapterService.downExcel(response); |
||||
} |
||||
|
||||
|
||||
@ApiOperation("导入excel") |
||||
@PostMapping("/uploadExcel") |
||||
public BaseResponse<String> addChapter3(MultipartFile file, String courseId) { |
||||
try { |
||||
List<String> validationErrors = chapterExcelService.uploadExcel(file, courseId); |
||||
if (!validationErrors.isEmpty()) { |
||||
StringBuilder errorMessage = new StringBuilder(); |
||||
for (String error : validationErrors) { |
||||
errorMessage.append(error).append("\n"); |
||||
} |
||||
return ResultUtils.error(ErrorCode.OPERATION_ERROR, errorMessage.toString()); |
||||
} else { |
||||
return ResultUtils.success("添加成功!!!!!!!!"); |
||||
} |
||||
} catch (Exception e) { |
||||
return ResultUtils.error(ErrorCode.SYSTEM_ERROR, "系统错误: " + e.getMessage()); |
||||
} |
||||
} |
||||
@ApiOperation("导出数据") |
||||
@GetMapping(value = "/downLoadExcel") |
||||
public void downLoadXlsx(HttpServletResponse response,String courseId) throws Exception{ |
||||
chapterService.downLoadXlsx(response,courseId); |
||||
} |
||||
@ApiOperation("修改章节") |
||||
@PutMapping("/update") |
||||
public BaseResponse<String> udChapter(@RequestBody Chapter chapter){ |
||||
|
||||
chapter.setUpdateTime(LocalDateTime.now()); |
||||
chapterService.updateById(chapter); |
||||
return ResultUtils.success("修改成功"); |
||||
} |
||||
@ApiOperation("将章节上移") |
||||
@PostMapping("/upper") |
||||
public BaseResponse<String> increase(@RequestParam Long chapterId){ |
||||
chapterService.upChapter(chapterId); |
||||
return ResultUtils.success("上移成功"); |
||||
} |
||||
|
||||
@ApiOperation("将章节下移") |
||||
@PostMapping("/down") |
||||
public BaseResponse<String> decrease(@RequestParam Long chapterId){ |
||||
chapterService.downChapter(chapterId); |
||||
return ResultUtils.success("下移成功"); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
@ -0,0 +1,35 @@ |
||||
package com.teaching.backend.controller.chapter; |
||||
|
||||
import java.util.Iterator; |
||||
import java.util.LinkedHashMap; |
||||
import java.util.Map; |
||||
|
||||
class LRUCache { |
||||
public static Map<Integer,Integer> map; |
||||
|
||||
public static Map<Integer,Integer> nums; |
||||
|
||||
private int capacity; |
||||
private int res; |
||||
|
||||
|
||||
public LRUCache(int capacity) { |
||||
map = new LinkedHashMap<>(); |
||||
this.capacity = capacity; |
||||
res = 0; |
||||
} |
||||
|
||||
public int get(int key) { |
||||
return map.get(key); |
||||
} |
||||
|
||||
public void put(int key, int value) { |
||||
capacity++; |
||||
if(capacity > res){ |
||||
|
||||
} |
||||
map.put(key,value); |
||||
int counts = nums.get(key); |
||||
|
||||
} |
||||
} |
@ -1,96 +0,0 @@ |
||||
//package com.teaching.backend.controller.courseResource;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
//import com.teaching.backend.common.BaseResponse;
|
||||
//import com.teaching.backend.common.ResultUtils;
|
||||
//
|
||||
//import com.teaching.backend.model.entity.resource.CourseResources;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@RestController
|
||||
//@RequestMapping("/api/courses")
|
||||
//public class CourseResourceController {
|
||||
// @Autowired
|
||||
// private CourseResourcesServiceImpl courseResourcesService;
|
||||
// @ApiOperation("查询全部课程资源记录")
|
||||
// @GetMapping("/all")
|
||||
// public BaseResponse<List<CourseResources>> All(){
|
||||
// System.out.println("学习记录:"+courseResourcesService.list());
|
||||
// return ResultUtils.success(courseResourcesService.list());
|
||||
// }
|
||||
//
|
||||
// @ApiOperation("按type查询课程资源")
|
||||
// @GetMapping("/getall")
|
||||
// public BaseResponse<Page> getAll(@RequestParam(value = "pagenum", defaultValue = "1") int pagenum,
|
||||
// @RequestParam(value = "pagesize", defaultValue = "10") int pagesize,
|
||||
// String type) {
|
||||
//
|
||||
// List<CourseResources> cs = courseResourcesService.getByType(type);
|
||||
// List<CourseResources> pageCs = new ArrayList<>();
|
||||
// //当前页面
|
||||
// for(int i = (pagenum - 1) * pagesize; i < cs.size() && i < (pagenum) * pagesize; i++){
|
||||
// pageCs.add(cs.get(i));
|
||||
// }
|
||||
// long total = cs.size(); // 总记录数
|
||||
// Page<CourseResources> pageInfo = new Page<>(pagenum,pagesize,total);
|
||||
// pageInfo.setRecords(pageCs);
|
||||
// pageInfo.setPages((int)(Math.ceil((double) total / pagesize)));//设置总页数
|
||||
// return ResultUtils.success(pageInfo);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据ids删除
|
||||
// * @param ids
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation("根据ids删除")
|
||||
// @DeleteMapping("/delete")
|
||||
// public BaseResponse<String> deleteRecords(@RequestParam List<Long> ids){
|
||||
// courseResourcesService.removeCourseResources(ids);
|
||||
//// courseResourcesService.removeBatchByIds(ids);
|
||||
// return ResultUtils.success("删除成功!!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增
|
||||
// * @param courseResources
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation("新增课程资源")
|
||||
// @PostMapping("/save")
|
||||
// public BaseResponse<String> saveCourseResource(@RequestBody CourseResources courseResources){
|
||||
// System.out.println(courseResources);
|
||||
// courseResourcesService.saveCourseResource(courseResources);
|
||||
// return ResultUtils.success("添加成功!");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 编辑
|
||||
// * @param resources
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation("编辑课程资源")
|
||||
// @PutMapping("/edit")
|
||||
// public BaseResponse<String> editCourseResource(@RequestBody CourseResources resources){
|
||||
// System.out.println(resources);
|
||||
// courseResourcesService.updateById(resources);
|
||||
// return ResultUtils.success("编辑成功");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据id查询课程资源
|
||||
// * @param resourceId
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation("根据id查询课程资源")
|
||||
// @PostMapping("/getone")
|
||||
// public BaseResponse<CourseResources> getOne(@RequestParam String resourceId){
|
||||
// System.out.println(resourceId);
|
||||
// return ResultUtils.success(courseResourcesService.getById(resourceId));
|
||||
// }
|
||||
//}
|
@ -1,84 +0,0 @@ |
||||
//package com.teaching.backend.controller.courses;
|
||||
//
|
||||
//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.model.dto.courses.CoursesDTO;
|
||||
//import com.teaching.backend.model.entity.courses.Courses;
|
||||
//import com.teaching.backend.service.courses.ICoursesService;
|
||||
//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;
|
||||
//
|
||||
// @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);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
@ -1,50 +0,0 @@ |
||||
package com.teaching.backend.controller.courses; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.filter.ValidateParams; |
||||
import com.teaching.backend.model.dto.courses.CoursesDTO; |
||||
import com.teaching.backend.model.dto.courses.ObjectiveContentKnowDTO; |
||||
import com.teaching.backend.model.vo.courses.ObjectiveContentKnowVO; |
||||
import com.teaching.backend.service.courses.IObjectiveContentKnowService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import org.springframework.stereotype.Controller; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author zjh |
||||
* @since 2024-06-13 |
||||
*/ |
||||
@Api(tags = "目标-内容 关联的知识点接口") |
||||
@RestController |
||||
@RequestMapping("/api/objective_content_know") |
||||
public class ObjectiveContentKnowController { |
||||
@Autowired |
||||
IObjectiveContentKnowService objectiveContentKnowService; |
||||
|
||||
|
||||
@ApiOperation("给知识点关联--目标内容") |
||||
@ValidateParams({"objectiveContentId","knowId"}) |
||||
@PostMapping("/addknows") |
||||
public BaseResponse<String> saveKnowsWithObjectiveContent(@RequestBody ObjectiveContentKnowDTO objectiveContentKnowDTO){ |
||||
String data = objectiveContentKnowService.saveKnowsWithObjectiveContent(objectiveContentKnowDTO); |
||||
return ResultUtils.success(data); |
||||
} |
||||
|
||||
@ApiOperation("针对分项目标统计,支撑分项目标知识点的个数、学时合计、占比") |
||||
@ValidateParams({"objectiveId"}) |
||||
@GetMapping("/{objectiveId}") |
||||
public BaseResponse<ObjectiveContentKnowVO> getCountData(@PathVariable String objectiveId){ |
||||
ObjectiveContentKnowVO objectiveContentKnowVO= objectiveContentKnowService.getCountData(objectiveId); |
||||
return ResultUtils.success(objectiveContentKnowVO); |
||||
} |
||||
|
||||
} |
@ -1,62 +0,0 @@ |
||||
package com.teaching.backend.controller.courses; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.filter.ValidateParams; |
||||
import com.teaching.backend.model.entity.courses.ObjectiveContents; |
||||
import com.teaching.backend.service.courses.IObjectiveContentsService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author zjh |
||||
* @since 2024-06-05 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/api/objective_contents") |
||||
@Api(tags = "目标内容接口") |
||||
public class ObjectiveContentsController { |
||||
|
||||
@Autowired |
||||
IObjectiveContentsService objectiveContentsService; |
||||
|
||||
@ApiOperation("添加目标内容") |
||||
@ValidateParams({"objectiveId"}) |
||||
@PostMapping("/addcontent") |
||||
public BaseResponse<String> saveContent(@RequestBody ObjectiveContents objectiveContents){ |
||||
String data = objectiveContentsService.saveWithCheck(objectiveContents); |
||||
return ResultUtils.success(data); |
||||
} |
||||
|
||||
@ApiOperation("删除目标内容") |
||||
@ValidateParams({"id"}) |
||||
@DeleteMapping("/{id}") |
||||
public BaseResponse<String> deleteContent(@PathVariable String id){ |
||||
String data = objectiveContentsService.deleteById(id); |
||||
return ResultUtils.success(data); |
||||
} |
||||
|
||||
@ApiOperation("修改目标内容") |
||||
@ValidateParams({"id","objectiveId"}) |
||||
@PutMapping("/update") |
||||
public BaseResponse<String> updateContent(@RequestBody ObjectiveContents objectiveContents){ |
||||
objectiveContentsService.updateById(objectiveContents); |
||||
return ResultUtils.success("修改成功"); |
||||
} |
||||
|
||||
@ApiOperation("根据id查询目标内容") |
||||
@ValidateParams({"id"}) |
||||
@GetMapping("/{id}") |
||||
public BaseResponse<ObjectiveContents> updateContent(@PathVariable String id){ |
||||
ObjectiveContents objectiveContent = objectiveContentsService.getById(id); |
||||
return ResultUtils.success(objectiveContent); |
||||
} |
||||
|
||||
} |
@ -1,78 +0,0 @@ |
||||
package com.teaching.backend.controller.resource; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-06-09-9:55 |
||||
* @Description: |
||||
*/ |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.model.entity.resource.Resources; |
||||
import com.teaching.backend.service.resource.ResourceGraphService; |
||||
import com.teaching.backend.service.resource.ResourceService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.core.io.InputStreamResource; |
||||
import org.springframework.http.ResponseEntity; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping("/api/resource/graph") |
||||
@Api(tags= "资源与图管理") |
||||
public class ResourceGraphController { |
||||
|
||||
@Autowired |
||||
private ResourceGraphService resourceGraphService; |
||||
|
||||
|
||||
@GetMapping("/addRelationship/BetweenKnowAndResources") |
||||
@ApiOperation(value = "添加知识点资源关系") |
||||
public BaseResponse<String> addResourcesByIdAndResourcesId(@RequestParam Long id,@RequestParam Long resourcesId){ |
||||
return resourceGraphService.addResourcesByIdAndResourcesId(id,resourcesId); |
||||
} |
||||
|
||||
@GetMapping("/deleteRelationship/BetweenKnowAndResources") |
||||
@ApiOperation(value = "删除知识点资源关系") |
||||
public BaseResponse<String> deleteResourcesAndKnowById(@RequestParam Long id, @RequestParam Long resourcesId){ |
||||
return resourceGraphService.deleteResourcesAndKnowById(id,resourcesId); |
||||
} |
||||
|
||||
//查询课程下资源
|
||||
@GetMapping("/queryByCourseId") |
||||
@ApiOperation(value = "查询课程下资源") |
||||
BaseResponse<Set<Resources>> queryResourcesByCourseId(@RequestParam String courseId){ |
||||
return resourceGraphService.queryResourcesByCourseId(courseId); |
||||
} |
||||
|
||||
//查询章节下资源
|
||||
@GetMapping("/queryByChapterId") |
||||
@ApiOperation(value = "查询章节下资源") |
||||
BaseResponse<Set<Resources>> queryResourcesByChapterId(@RequestParam Long chapterId){ |
||||
return resourceGraphService.queryResourcesByChapterId(chapterId); |
||||
} |
||||
|
||||
//查询二级节点下资源
|
||||
@ApiOperation(value = "查询二级节点下资源") |
||||
@GetMapping("/queryBesidesKnow") |
||||
BaseResponse<Set<Resources>> queryBesidesKnowToResources(@RequestParam Long knowId){ |
||||
return resourceGraphService.queryBesidesKnowToResources(knowId); |
||||
} |
||||
|
||||
//查询知识点下资源
|
||||
@GetMapping("/queryResourcesByKnowId") |
||||
@ApiOperation(value = "查询知识点下资源") |
||||
BaseResponse<Set<Resources>> queryResourcesByKnowId(@RequestParam Long knowId){ |
||||
return resourceGraphService.queryResourcesByKnowId(knowId); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -1,43 +0,0 @@ |
||||
package com.teaching.backend.controller.resource; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import com.teaching.backend.service.impl.resource.ResourceMysqlServiceImpl; |
||||
import com.teaching.backend.service.impl.resource.ResourceServiceImpl; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
/** |
||||
* <p> |
||||
* 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/resourcemysql") |
||||
@Api(tags= "数据库资源管理") |
||||
public class ResourceMysqlController { |
||||
private ResourceMysqlServiceImpl resourceMysqlService; |
||||
|
||||
private ResourceServiceImpl resourceService; |
||||
|
||||
//添加资源
|
||||
@PostMapping("/add") |
||||
@ApiOperation(value = "添加资源") |
||||
public BaseResponse<String> addFile(@RequestPart("file") MultipartFile file, ResourceMysql resourceMysql) { |
||||
System.out.println("资源:"+ resourceMysql); |
||||
System.out.println(file); |
||||
String url = resourceService.upload(file).getData().getUrl(); |
||||
System.out.println(url); |
||||
//return ResultUtils.success("添加xx");
|
||||
return resourceMysqlService.resourceUpload(file, resourceMysql); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,21 @@ |
||||
package com.teaching.backend.mapper.resource; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import com.teaching.backend.model.entity.resource.Resources; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
/** |
||||
* <p> |
||||
* Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-09-02 |
||||
*/ |
||||
|
||||
public interface ResourceMapper extends BaseMapper<ResourceMysql> { |
||||
|
||||
|
||||
} |
@ -0,0 +1,26 @@ |
||||
package com.teaching.backend.model.dto.Knowtmp; |
||||
|
||||
import lombok.Data; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-05-31 |
||||
*/ |
||||
@Data |
||||
public class KnowObjective implements Serializable { |
||||
|
||||
|
||||
private List<String> objectiveIds; |
||||
|
||||
private Long knowId; |
||||
|
||||
|
||||
} |
@ -0,0 +1,54 @@ |
||||
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 com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.teaching.backend.model.entity.knowtmp.Knowtmp; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
import javax.validation.constraints.Digits; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-05-31 |
||||
*/ |
||||
@Data |
||||
public class ChapterAndNodeTreeVO implements Serializable { |
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
|
||||
@ApiModelProperty(value = "序号") |
||||
private Double orderNum; |
||||
|
||||
@ApiModelProperty(value = "名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "简介") |
||||
private String content; |
||||
|
||||
@ApiModelProperty(value = "父级节点") |
||||
private Long pid; |
||||
|
||||
|
||||
@ApiModelProperty(value = "总学时") |
||||
@Digits(integer = 10, fraction = 1, message = "总学时只能保留一位小数") |
||||
private double totalClassHours; |
||||
|
||||
@ApiModelProperty(value = "子章节") |
||||
private List<ChapterAndNodeTreeVO> children; // 用于存储子章节
|
||||
|
||||
} |
@ -0,0 +1,86 @@ |
||||
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 com.teaching.backend.model.entity.knowtmp.Knowtmp; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.Digits; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* |
||||
* </p> |
||||
* |
||||
* @author author |
||||
* @since 2024-05-31 |
||||
*/ |
||||
@Data |
||||
public class ChapterChildreenVO implements Serializable { |
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
@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 Double orderNum; |
||||
|
||||
@ApiModelProperty(value = "名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "简介") |
||||
private String content; |
||||
|
||||
@ApiModelProperty(value = "父级节点") |
||||
private Long pid; |
||||
|
||||
@ApiModelProperty(value = "课程") |
||||
|
||||
private String courseId; |
||||
|
||||
@ApiModelProperty(value = "课程目标") |
||||
private String courseObjectivesId; |
||||
|
||||
@ApiModelProperty(value = "总学时") |
||||
@Digits(integer = 10, fraction = 1, message = "总学时只能保留一位小数") |
||||
private double totalClassHours; |
||||
|
||||
@ApiModelProperty(value = "要求") |
||||
private String requirement; |
||||
|
||||
@ApiModelProperty(value = "线上学时") |
||||
private String onlineClassHours; |
||||
|
||||
@ApiModelProperty(value = "周次") |
||||
private String zc; |
||||
|
||||
@ApiModelProperty(value = "内部序号显示") |
||||
private String numshow; |
||||
|
||||
@ApiModelProperty(value = "子章节") |
||||
@TableField(exist = false) |
||||
private List<Knowtmp> children; // 用于存储子章节
|
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
package com.teaching.backend.model.dto.courses; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@Data |
||||
@ApiModel(description = "分项目标参数实体") |
||||
public class CourseObjectivesUpdateDTO implements Serializable { |
||||
|
||||
@ApiModelProperty(value = "目标id") |
||||
private String Id; |
||||
|
||||
@ApiModelProperty(value = "课程id") |
||||
private String courseId; |
||||
|
||||
@ApiModelProperty(value = "目标类型") |
||||
private Integer type; |
||||
|
||||
@ApiModelProperty(value = "目标名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "总目标id") |
||||
private String pid; |
||||
|
||||
@ApiModelProperty(value = "目标内容") |
||||
private String content; |
||||
|
||||
} |
@ -0,0 +1,103 @@ |
||||
package com.teaching.backend.model.dto.courses; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.time.LocalDateTime; |
||||
|
||||
@Data |
||||
@ApiModel(description = "教师创建课程参数实体") |
||||
public class CoursesUpdateDTO { |
||||
|
||||
/** |
||||
* 内部编号 |
||||
*/ |
||||
@ApiModelProperty("id") |
||||
private String id; |
||||
|
||||
/** |
||||
* 创建人 教师id |
||||
*/ |
||||
@ApiModelProperty(value = "负责教师",required = true) |
||||
private String teacher; |
||||
|
||||
/** |
||||
* 创建日期 |
||||
*/ |
||||
@ApiModelProperty("创建日期") |
||||
private LocalDateTime createTime; |
||||
/** |
||||
* 课程封面 |
||||
*/ |
||||
@ApiModelProperty(value = "图片",required = true) |
||||
private String img; |
||||
|
||||
/** |
||||
* 课程类别 专业教育 通识教育 |
||||
*/ |
||||
@ApiModelProperty(value = "课程类别:专业教育1 通识教育2",required = true) |
||||
private String category; |
||||
|
||||
/** |
||||
* 课程性质 必修选修任修 |
||||
*/ |
||||
@ApiModelProperty(value = "课程性质:必修1 选修2 任修3",required = true) |
||||
private String nature; |
||||
|
||||
/** |
||||
* 课程名称 |
||||
*/ |
||||
@ApiModelProperty(value = "课程名称",required = true) |
||||
private String name; |
||||
|
||||
/** |
||||
* 课程编码 |
||||
*/ |
||||
@ApiModelProperty(value = "课程编码",required = true) |
||||
private String code; |
||||
|
||||
|
||||
/** |
||||
* 课程学分 |
||||
*/ |
||||
@ApiModelProperty(value = "课程学分",required = true) |
||||
private BigDecimal credit; |
||||
|
||||
/** |
||||
* 课程学时 |
||||
*/ |
||||
@ApiModelProperty(value = "课程学时",required = true) |
||||
private Integer classhours; |
||||
|
||||
/** |
||||
* 考核类型 考试 考查 |
||||
*/ |
||||
@ApiModelProperty(value = "考核类型:考试1 考查2",required = true) |
||||
private String assessmenttype; |
||||
|
||||
/** |
||||
* 考核方式 开卷 闭卷 其他 |
||||
*/ |
||||
@ApiModelProperty(value = "考核方式:开卷1 闭卷2 其他3",required = true) |
||||
private String assessmentway; |
||||
|
||||
/** |
||||
* 教学方法 |
||||
*/ |
||||
@ApiModelProperty("教学方法") |
||||
private String teachermethod; |
||||
|
||||
/** |
||||
* 教学方式 |
||||
*/ |
||||
@ApiModelProperty("教学方式") |
||||
private String teacherway; |
||||
|
||||
/** |
||||
* 课程简介 |
||||
*/ |
||||
@ApiModelProperty("课程简介") |
||||
private String description; |
||||
} |
@ -0,0 +1,31 @@ |
||||
package com.teaching.backend.model.dto.resource; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-10-21-15:53 |
||||
* @Description: |
||||
*/ |
||||
|
||||
@Data |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class ResourceRelationshipDto { |
||||
|
||||
@ApiModelProperty(value = "知识点Id") |
||||
private Long knowId; |
||||
|
||||
@ApiModelProperty(value = "资源Id") |
||||
private Long resourceId; |
||||
|
||||
@ApiModelProperty(value = "课程Id") |
||||
private String courseId; |
||||
} |
@ -1,29 +0,0 @@ |
||||
package com.teaching.backend.model.entity; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import lombok.ToString; |
||||
|
||||
/** |
||||
* ClassName: ResourcesRelationship |
||||
* Package: com.teaching.backend.model.entity |
||||
* Description: |
||||
* |
||||
* @Author 姜钧瀚 |
||||
* @Create 2024/6/12 21:03 |
||||
* @Version 1.0 |
||||
*/ |
||||
@Data |
||||
@ToString |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class ResourceRelationship { |
||||
private String Id; |
||||
private String courseid; |
||||
private String chapterid; |
||||
private String knowid; |
||||
private String resourceid; |
||||
|
||||
|
||||
} |
@ -0,0 +1,52 @@ |
||||
package com.teaching.backend.model.entity.courses; |
||||
|
||||
import java.util.Scanner; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-10-08-19:10 |
||||
* @Description: |
||||
*/ |
||||
public class Testrr { |
||||
public static void main(String[] args) { |
||||
System.out.println("jj"); |
||||
Scanner sc = new Scanner(System.in); |
||||
while (sc.hasNext()){ |
||||
String s = sc.nextLine(); |
||||
String t = reverse2(s); |
||||
System.out.println(t); |
||||
} |
||||
|
||||
} |
||||
// toCharArray
|
||||
public static String reverse2(String str) { |
||||
char[] chars = str.toCharArray(); |
||||
int[] arr = new int[100]; |
||||
String reverse = ""; |
||||
int k = 0; |
||||
for(int i = 0; i < chars.length; i++){ |
||||
if(chars[i] == 'a' && chars[i+1] == 'l' && chars[i+2] == 'l'){ |
||||
arr[k++] = i+2; |
||||
} |
||||
} |
||||
int f = 1; |
||||
for (int i = chars.length - 1; i >= 0; i--) { |
||||
for (int j = 0; j < k; j++) { |
||||
if(i == arr[j]){ |
||||
reverse += Character.toLowerCase(chars[i-2]) ; |
||||
reverse += Character.toLowerCase(chars[i-1]); |
||||
reverse += Character.toLowerCase(chars[i]); |
||||
f = 0; |
||||
i--; |
||||
i--; |
||||
break; |
||||
} |
||||
} |
||||
if(f == 1){ |
||||
reverse += chars[i]; |
||||
} |
||||
f = 1; |
||||
} |
||||
return reverse; |
||||
} |
||||
} |
@ -1,4 +1,4 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
package com.teaching.backend.model.entity.know; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
@ -0,0 +1,37 @@ |
||||
package com.teaching.backend.model.entity.resource; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-10-21-15:53 |
||||
* @Description: |
||||
*/ |
||||
|
||||
@Data |
||||
@TableName("resource_relationship") |
||||
@ApiModel(value="resource_relationship对象", description="") |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class ResourceRelationship { |
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Long id; |
||||
|
||||
@ApiModelProperty(value = "知识点Id") |
||||
private Long knowId; |
||||
|
||||
@ApiModelProperty(value = "资源Id") |
||||
private Long resourceId; |
||||
|
||||
@ApiModelProperty(value = "课程Id") |
||||
private String courseId; |
||||
} |
@ -1,26 +0,0 @@ |
||||
package com.teaching.backend.model.vo.courses; |
||||
|
||||
import com.teaching.backend.model.entity.courses.CourseObjectives; |
||||
import com.teaching.backend.model.entity.courses.ObjectiveContents; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
@ApiModel(description = "课程目标参数实体") |
||||
public class CourseObjectivesTreeVO extends CourseObjectives implements Serializable { |
||||
|
||||
|
||||
@ApiModelProperty(value = "目标名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "目标内容列表") |
||||
private List<ObjectiveContents> contents; |
||||
|
||||
@ApiModelProperty(value = "课程目标") |
||||
private List<CourseObjectivesTreeVO> courseObjectivesTrees; |
||||
|
||||
} |
@ -1,4 +1,4 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
package com.teaching.backend.model.vo.knowGraph; |
||||
|
||||
import lombok.Data; |
||||
|
@ -1,4 +1,4 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
package com.teaching.backend.model.vo.knowGraph; |
||||
|
||||
import lombok.Data; |
||||
|
@ -1,8 +1,6 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
package com.teaching.backend.model.vo.knowGraph; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
import com.teaching.backend.model.entity.know.KnowJson; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
@ -1,4 +1,4 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
package com.teaching.backend.model.vo.knowGraph; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
@ -1,25 +0,0 @@ |
||||
package com.teaching.backend.model.vo.knowGraph; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
|
||||
@Data |
||||
public class KnowVO1 implements Serializable { |
||||
|
||||
|
||||
/** |
||||
* id |
||||
*/ |
||||
private Long id; |
||||
|
||||
|
||||
/** |
||||
* 知识点名称 |
||||
*/ |
||||
private String label; |
||||
|
||||
|
||||
} |
||||
|
@ -1,4 +1,4 @@ |
||||
package com.teaching.backend.controller.Know; |
||||
package com.teaching.backend.model.vo.knowGraph; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Data; |
@ -1,21 +0,0 @@ |
||||
package com.teaching.backend.service.courses; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.teaching.backend.model.dto.courses.ObjectiveContentKnowDTO; |
||||
import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; |
||||
import com.teaching.backend.model.vo.courses.ObjectiveContentKnowVO; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务类 |
||||
* </p> |
||||
* |
||||
* @author zjh |
||||
* @since 2024-06-13 |
||||
*/ |
||||
public interface IObjectiveContentKnowService extends IService<ObjectiveContentKnow> { |
||||
|
||||
String saveKnowsWithObjectiveContent(ObjectiveContentKnowDTO objectiveContentKnowDTO); |
||||
|
||||
ObjectiveContentKnowVO getCountData(String objectiveId); |
||||
} |
@ -1,195 +0,0 @@ |
||||
package com.teaching.backend.service.impl.courses; |
||||
|
||||
import cn.hutool.core.lang.generator.SnowflakeGenerator; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.teaching.backend.common.ErrorCode; |
||||
import com.teaching.backend.exception.BusinessException; |
||||
import com.teaching.backend.mapper.Knowtemp.KnowtmpMapper; |
||||
import com.teaching.backend.mapper.courses.CourseObjectivesMapper; |
||||
import com.teaching.backend.mapper.courses.CoursesMapper; |
||||
import com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper; |
||||
import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; |
||||
import com.teaching.backend.model.dto.courses.ObjectiveContentKnowDTO; |
||||
import com.teaching.backend.model.entity.courses.CourseObjectives; |
||||
import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; |
||||
import com.teaching.backend.model.entity.courses.ObjectiveContents; |
||||
import com.teaching.backend.model.entity.knowtmp.Knowtmp; |
||||
import com.teaching.backend.model.vo.courses.ObjectiveContentKnowVO; |
||||
import com.teaching.backend.model.vo.knowtmp.KnowTmpVO; |
||||
import com.teaching.backend.service.courses.IObjectiveContentKnowService; |
||||
import com.teaching.backend.utils.CourseCode; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.neo4j.driver.internal.value.StringValue; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
import org.springframework.util.CollectionUtils; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.math.RoundingMode; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author zjh |
||||
* @since 2024-06-13 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
public class ObjectiveContentKnowServiceImpl extends ServiceImpl<ObjectiveContentKnowMapper, ObjectiveContentKnow> implements IObjectiveContentKnowService { |
||||
|
||||
@Autowired |
||||
ObjectiveContentKnowMapper objectiveContentKnowMapper; |
||||
@Autowired |
||||
KnowtmpMapper knowtmpMapper; |
||||
@Autowired |
||||
CourseObjectivesMapper courseObjectivesMapper; |
||||
@Autowired |
||||
CoursesMapper coursesMapper; |
||||
@Autowired |
||||
ObjectiveContentsMapper objectiveContentsMapper; |
||||
@Autowired |
||||
SnowflakeGenerator snowflakeGenerator; |
||||
|
||||
@Override |
||||
@Transactional |
||||
public String saveKnowsWithObjectiveContent(ObjectiveContentKnowDTO objectiveContentKnowDTO) { |
||||
//暂时约定前端传过来的的knows是“1,2,3” 用 , 隔开的
|
||||
// String knows = objectiveContentKnowDTO.getKnow();
|
||||
// if (knows == null || knows.equals("")){
|
||||
// throw new BusinessException(ErrorCode.KONWID_NOT_EXIT);
|
||||
// }
|
||||
// List<String> knowIds = new ArrayList<>(Arrays.asList(knows.split(",")));
|
||||
// List<ObjectiveContentKnow> objectiveContentKnowList = new ArrayList<>();
|
||||
// for (String knowId : knowIds) {
|
||||
// ObjectiveContentKnow objectiveContentKnow = new ObjectiveContentKnow();
|
||||
//// objectiveContentKnow.setId(snowflakeGenerator.next());
|
||||
// objectiveContentKnow.setObjectiveOrContent(objectiveOrContent);
|
||||
// objectiveContentKnow.setKnow(knowId);
|
||||
// objectiveContentKnowList.add(objectiveContentKnow);
|
||||
// }
|
||||
// try {
|
||||
// objectiveContentKnowMapper.insertBatchSomeColumn(objectiveContentKnowList);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// throw new BusinessException(ErrorCode.OBJECTIVE_OR_CONTENT_EXIT);
|
||||
// }
|
||||
|
||||
//添加逻辑变了 变成了给知识点添加关联的--课程目标
|
||||
ObjectiveContents objectiveContents = objectiveContentsMapper.selectById(objectiveContentKnowDTO.getObjectiveContentId()); |
||||
if (objectiveContents == null) { |
||||
throw new BusinessException(ErrorCode.OBJECTIVE_CONTENT_NOT_EXIT); |
||||
} |
||||
int insert = objectiveContentKnowMapper.insert(objectiveContentKnowDTO); |
||||
|
||||
return insert > 0 ? "添加成功" : "添加失败"; |
||||
} |
||||
|
||||
@Override |
||||
public ObjectiveContentKnowVO getCountData(String objectiveContentId) { |
||||
// 创建ObjectiveContentKnowVO对象,用于存储和返回计算结果
|
||||
ObjectiveContentKnowVO objectiveContentKnowVO = new ObjectiveContentKnowVO(); |
||||
|
||||
// 根据传入的目标内容ID找到课程ID和总学时
|
||||
String objectiveID = objectiveContentsMapper.selectById(objectiveContentId).getObjectiveId(); |
||||
CourseObjectives courseObjective = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>() |
||||
.eq(CourseObjectives::getId, objectiveID)); |
||||
String pid = courseObjective.getPid(); |
||||
//当前内容属于总目标类型的
|
||||
String courseId; |
||||
if(pid.equals(String.valueOf(CourseCode.CONTENT_BELONGS_TO_TOTAL_OBJECTIVE.getValue()))){ |
||||
courseId = courseObjective.getCourseId(); |
||||
} |
||||
else { |
||||
courseId = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<CourseObjectives>() |
||||
.eq(CourseObjectives::getId, pid)).getCourseId(); |
||||
} |
||||
Integer classhours = coursesMapper.selectById(courseId).getClasshours(); |
||||
|
||||
// 获取当前目标内容下关联的知识点数据
|
||||
List<ObjectiveContentKnow> objectiveContentKnows = objectiveContentKnowMapper.selectList( |
||||
new LambdaQueryWrapper<ObjectiveContentKnow>() |
||||
.eq(ObjectiveContentKnow::getObjectiveContentId, objectiveContentId) |
||||
); |
||||
if(objectiveContentKnows.isEmpty()){ |
||||
log.warn("当前课程目标下面没有关联的知识点contentId:{}",objectiveContentId); |
||||
throw new BusinessException(ErrorCode.CONTENT_HAS_NO_KNOWS); |
||||
} |
||||
|
||||
// 创建并设置ObjectiveContentKnowVO对象的属性
|
||||
objectiveContentKnowVO = createObjectiveContentKnowVO(objectiveContentId, objectiveContentKnows); |
||||
|
||||
// 计算并设置该内容的知识点总学时的比例(百分比)
|
||||
Double contentPercentage = calculatePercentage(objectiveContentKnowVO.getKnowsTime(), classhours); |
||||
objectiveContentKnowVO.setPersent(contentPercentage); |
||||
|
||||
// 返回最终结果
|
||||
return objectiveContentKnowVO; |
||||
} |
||||
|
||||
// 创建ObjectiveContentKnowVO对象,并计算知识点数量、总时间和关联的知识点部分数据
|
||||
private ObjectiveContentKnowVO createObjectiveContentKnowVO(String objectiveOrContentId, List<ObjectiveContentKnow> objectiveContentKnows) { |
||||
ObjectiveContentKnowVO vo = new ObjectiveContentKnowVO(); |
||||
vo.setObjectiveOrContent(objectiveOrContentId); |
||||
vo.setKnowsNumber(objectiveContentKnows.size()); |
||||
|
||||
// 提取所有的 Know IDs
|
||||
List<Long> knowIds = objectiveContentKnows.stream() |
||||
.map(ObjectiveContentKnow::getKnowId) |
||||
.collect(Collectors.toList()); |
||||
|
||||
// 一次性查询所有需要的 Knowtmp 数据
|
||||
List<Knowtmp> knows = knowtmpMapper.selectList(new LambdaQueryWrapper<Knowtmp>() |
||||
.in(Knowtmp::getId, knowIds)); |
||||
|
||||
// 使用 Map 来存储 Knowtmp 数据,以便快速查找
|
||||
Map<Long, Knowtmp> knowMap = knows.stream() |
||||
.collect(Collectors.toMap(Knowtmp::getId, know -> know)); |
||||
|
||||
Double knowsTime = 0.0; |
||||
List<KnowTmpVO> knowTmpVOList = new ArrayList<>(); |
||||
|
||||
for (ObjectiveContentKnow contentKnow : objectiveContentKnows) { |
||||
Knowtmp know = knowMap.get(contentKnow.getKnowId()); |
||||
if (know == null) { |
||||
log.warn("知识点不存在,id:{}", contentKnow.getKnowId()); |
||||
// throw new BusinessException(ErrorCode.KNOW_NOT_EXIT);
|
||||
continue; // 知识点不存在时跳过
|
||||
} |
||||
|
||||
knowsTime += know.getHour(); |
||||
|
||||
// 将当前知识点数据添加到knowTmpVOList中
|
||||
KnowTmpVO knowTmpVO = new KnowTmpVO(); |
||||
knowTmpVO.setId(know.getId()); |
||||
knowTmpVO.setName(know.getName()); |
||||
knowTmpVO.setHour(know.getHour()); |
||||
knowTmpVOList.add(knowTmpVO); |
||||
} |
||||
|
||||
vo.setKnowsTime(knowsTime); |
||||
vo.setKnowTmpVOList(knowTmpVOList); // 设置知识点的部分数据列表
|
||||
return vo; |
||||
} |
||||
|
||||
|
||||
// 计算知识点学时占总学时的比例,并返回百分比形式的结果
|
||||
private Double calculatePercentage(Double knowsTime, Integer classhours) { |
||||
if (classhours == null || classhours == 0) { |
||||
return 0.0; |
||||
} |
||||
return new BigDecimal(knowsTime) |
||||
.divide(new BigDecimal(classhours), 4, RoundingMode.HALF_UP) |
||||
.multiply(new BigDecimal(100)) |
||||
.setScale(2, RoundingMode.HALF_UP) |
||||
.doubleValue(); |
||||
} |
||||
} |
@ -1,83 +0,0 @@ |
||||
package com.teaching.backend.service.impl.courses; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.teaching.backend.common.ErrorCode; |
||||
import com.teaching.backend.exception.BusinessException; |
||||
import com.teaching.backend.mapper.courses.CourseObjectivesMapper; |
||||
import com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper; |
||||
import com.teaching.backend.mapper.courses.ObjectiveContentsMapper; |
||||
import com.teaching.backend.model.entity.courses.CourseObjectives; |
||||
import com.teaching.backend.model.entity.courses.ObjectiveContentKnow; |
||||
import com.teaching.backend.model.entity.courses.ObjectiveContents; |
||||
import com.teaching.backend.service.courses.IObjectiveContentsService; |
||||
import com.teaching.backend.utils.CourseCode; |
||||
import io.swagger.annotations.Api; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import static com.teaching.backend.utils.CourseCode.*; |
||||
|
||||
/** |
||||
* <p> |
||||
* 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author zjh |
||||
* @since 2024-06-05 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
public class ObjectiveContentsServiceImpl extends ServiceImpl<ObjectiveContentsMapper, ObjectiveContents> implements IObjectiveContentsService { |
||||
|
||||
@Autowired |
||||
ObjectiveContentKnowMapper objectiveContentKnowMapper; |
||||
@Autowired |
||||
ObjectiveContentsMapper objectiveContentsMapper; |
||||
@Autowired |
||||
CourseObjectivesMapper courseObjectivesMapper; |
||||
@Override |
||||
public String deleteById(String id) { |
||||
if (id == null){ |
||||
throw new BusinessException(ErrorCode.CONTENT_NOT_EXIT); |
||||
} |
||||
Long count = objectiveContentKnowMapper.selectCount(new LambdaQueryWrapper<ObjectiveContentKnow>() |
||||
.eq(ObjectiveContentKnow::getObjectiveContentId, id)); |
||||
if(count > CourseCode.KNOWS_EXIT.getValue()){ |
||||
throw new BusinessException(ErrorCode.KNOWS_EXIT); |
||||
} |
||||
String objectiveId = objectiveContentsMapper.selectById(id).getObjectiveId(); |
||||
Integer type = courseObjectivesMapper.selectById(objectiveId).getType(); |
||||
if (type == TOTAL_OBJECTIVE_TYPE.getValue()){ |
||||
throw new BusinessException(ErrorCode.TOTOAL_OBJECTIVE_CANT_DELETE); |
||||
} |
||||
int delete = objectiveContentsMapper.deleteById(id); |
||||
return delete > 0 ? "删除成功!" : "删除失败!"; |
||||
} |
||||
|
||||
/** |
||||
* 在添加内容的时候需要校验,总目标和思政目标只有一个内容 |
||||
* @param objectiveContents |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public String saveWithCheck(ObjectiveContents objectiveContents) { |
||||
CourseObjectives courseObjective = courseObjectivesMapper.selectOne(new LambdaQueryWrapper<>(CourseObjectives.class) |
||||
.eq(CourseObjectives::getId, objectiveContents.getObjectiveId())); |
||||
if (courseObjective == null){ |
||||
log.error("课程目标数据不存在:{}",objectiveContents.getObjectiveId()); |
||||
throw new BusinessException(ErrorCode.NOT_FOUND_ERROR); |
||||
} |
||||
if (courseObjective.getType() == SI_ZHENG_TYPE.getValue() || courseObjective.getType() == TOTAL_OBJECTIVE_TYPE.getValue()){ |
||||
Long count = objectiveContentsMapper.selectCount(new LambdaQueryWrapper<>(ObjectiveContents.class) |
||||
.eq(ObjectiveContents::getObjectiveId, objectiveContents.getObjectiveId())); |
||||
if (count>CONTENT_EXIT.getValue()){ |
||||
throw new BusinessException(ErrorCode.CONTENT_EXISTS,"该目标下面已存在一条内容,无需再次添加"); |
||||
} |
||||
} |
||||
int insert = objectiveContentsMapper.insert(objectiveContents); |
||||
return insert > 0 ? "添加内容成功" : "添加内容失败"; |
||||
} |
||||
} |
@ -0,0 +1,93 @@ |
||||
package com.teaching.backend.service.impl.resource; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.common.ErrorCode; |
||||
import com.teaching.backend.common.ResultUtils; |
||||
import com.teaching.backend.mapper.Knowtemp.KnowtmpMapper; |
||||
import com.teaching.backend.mapper.know.KnowRepository; |
||||
import com.teaching.backend.mapper.resource.ResourceMapper; |
||||
import com.teaching.backend.mapper.resource.ResourceRelationshipMapper; |
||||
import com.teaching.backend.mapper.resource.ResourcesRepository; |
||||
import com.teaching.backend.model.dto.resource.ResourceRelationshipDto; |
||||
import com.teaching.backend.model.entity.know.KnowChapter; |
||||
import com.teaching.backend.model.entity.know.KnowCourse; |
||||
import com.teaching.backend.model.entity.knowtmp.Knowtmp; |
||||
import com.teaching.backend.model.entity.resource.ResourceMysql; |
||||
import com.teaching.backend.model.entity.resource.ResourceRelationship; |
||||
import com.teaching.backend.model.entity.resource.Resources; |
||||
import com.teaching.backend.service.resource.ResourceGraphService; |
||||
import com.teaching.backend.service.resource.ResourceRelationshipService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
import java.util.Set; |
||||
|
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-07-26-13:58 |
||||
* @Description: |
||||
*/ |
||||
@Service |
||||
public class ResourceRelationshipServiceImpl implements ResourceRelationshipService { |
||||
|
||||
@Autowired |
||||
private ResourceMapper resourceMapper; |
||||
|
||||
@Autowired |
||||
private ResourceRelationshipMapper resourceRelationshipMapper; |
||||
|
||||
@Autowired |
||||
private KnowtmpMapper knowtmpMapper; |
||||
|
||||
@Override |
||||
public BaseResponse<String> addResourcesRel(ResourceRelationshipDto resourceRelationshipDto) { |
||||
Long knowId = resourceRelationshipDto.getKnowId(); |
||||
Long resourceId = resourceRelationshipDto.getResourceId(); |
||||
String coursesId = resourceRelationshipDto.getCourseId(); |
||||
//判空
|
||||
if(knowId <= 0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"knowId字段不能为空"); |
||||
} |
||||
if(resourceId <= 0){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"resourceId字段不能为空"); |
||||
} |
||||
if("".equals(coursesId) || coursesId == null){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"coursesId字段不能为空"); |
||||
} |
||||
//查询知识点是否存在
|
||||
Knowtmp knowtmp = knowtmpMapper.selectById(knowId); |
||||
if(knowtmp == null) |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"知识点不存在"); |
||||
ResourceMysql resourceMysql = resourceMapper.selectById(resourceId); |
||||
if(resourceMysql == null){ |
||||
return ResultUtils.error(ErrorCode.PARAMS_ERROR,"资源不存在"); |
||||
} |
||||
|
||||
ResourceRelationship resourceRelationship = new ResourceRelationship(); |
||||
resourceRelationship.setResourceId(resourceId); |
||||
resourceRelationship.setCourseId(coursesId); |
||||
resourceRelationship.setKnowId(knowId); |
||||
int ans = resourceRelationshipMapper.insert(resourceRelationship); |
||||
if(ans > 0){ |
||||
return ResultUtils.success("添加成功"); |
||||
} |
||||
return ResultUtils.error(ErrorCode.SYSTEM_ERROR,"添加失败"); |
||||
} |
||||
|
||||
@Override |
||||
public BaseResponse<String> deleteResourcesRel(Long knowId, Long resourceId) { |
||||
QueryWrapper<ResourceRelationship> resourceRelationshipQueryWrapper = new QueryWrapper<>(); |
||||
resourceRelationshipQueryWrapper.eq("know_id",knowId).eq("resource_id",resourceId); |
||||
int ans = resourceRelationshipMapper.delete(resourceRelationshipQueryWrapper); |
||||
if(ans > 0){ |
||||
return ResultUtils.success("删除成功"); |
||||
} |
||||
return ResultUtils.error(ErrorCode.SYSTEM_ERROR,"删除失败"); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
package com.teaching.backend.service.resource; |
||||
|
||||
|
||||
import com.teaching.backend.common.BaseResponse; |
||||
import com.teaching.backend.model.dto.resource.ResourceRelationshipDto; |
||||
import com.teaching.backend.model.entity.resource.Resources; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-07-26-13:55 |
||||
* @Description: |
||||
*/ |
||||
|
||||
public interface ResourceRelationshipService { |
||||
|
||||
BaseResponse<String> addResourcesRel(ResourceRelationshipDto resourceRelationshipDto); |
||||
|
||||
BaseResponse<String> deleteResourcesRel(Long knowId, Long resourceId); |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,339 @@ |
||||
package com.teaching.backend.utils; |
||||
|
||||
|
||||
import cn.hutool.core.date.DateTime; |
||||
import com.aliyun.oss.*; |
||||
import com.aliyun.oss.model.*; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import java.io.ByteArrayInputStream; |
||||
import java.io.File; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.InputStream; |
||||
import java.net.URL; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
|
||||
public class AliyunOSSClientUtil { |
||||
// log日志
|
||||
private static Logger logger = LoggerFactory.getLogger(AliyunOSSClientUtil.class); |
||||
//oss客户端连接
|
||||
private static OSS ossclient = null; |
||||
|
||||
|
||||
public static String getFileName(String filename){ |
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
||||
// 字符串截取
|
||||
int dotIndex = filename.lastIndexOf('.'); |
||||
String prefix = filename.substring(0,dotIndex); |
||||
String suffix = filename.substring(dotIndex+1,filename.length()); |
||||
if(prefix.length() > 10){ |
||||
prefix = prefix.substring(0,10); |
||||
} |
||||
filename = prefix+"-"+sdf.format(new DateTime())+"."+suffix; |
||||
sdf = new SimpleDateFormat("yyyyMMdd"); |
||||
// 设置存储对象名称
|
||||
String objectName = sdf.format(new Date()) + "/" + suffix + "/" + filename; |
||||
return objectName; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获得阿里云OSS客户端对象 |
||||
* 备注:阿里云OSS SDK中提供了自动重连的功能,以确保应用程序在遇到网络问题时仍能与OSS有效通信。 |
||||
* |
||||
* @param ossEndpoint |
||||
* @param accessId |
||||
* @param accessKey |
||||
* @return |
||||
*/ |
||||
public static OSS getOssClient(String ossEndpoint, String accessId, String accessKey) { |
||||
if (ossclient == null) { |
||||
ClientBuilderConfiguration conf = new ClientBuilderConfiguration(); |
||||
// 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。
|
||||
conf.setMaxConnections(500); |
||||
// 设置Socket层传输数据的超时时间,默认为50000毫秒。
|
||||
conf.setSocketTimeout(10000); |
||||
// 设置建立连接的超时时间,默认为50000毫秒。
|
||||
conf.setConnectionTimeout(10000); |
||||
// 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。
|
||||
conf.setConnectionRequestTimeout(10000); |
||||
// 设置连接空闲超时时间。超时则关闭连接,默认为60000毫秒。
|
||||
conf.setIdleConnectionTime(10000); |
||||
// 设置失败请求重试次数,默认为3次。
|
||||
conf.setMaxErrorRetry(5); |
||||
ossclient = new OSSClientBuilder().build(ossEndpoint, accessId, accessKey, conf); |
||||
} |
||||
return ossclient; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 创建存储空间 |
||||
* |
||||
* @param ossClient OSS连接 |
||||
* @param bucketName 存储空间 |
||||
* @return |
||||
*/ |
||||
public static String createBucketName(OSS ossClient, String bucketName) { |
||||
// 存储空间
|
||||
final String bucketNames = bucketName; |
||||
if (!ossClient.doesBucketExist(bucketName)) { |
||||
// 创建存储空间
|
||||
Bucket bucket = ossClient.createBucket(bucketName); |
||||
logger.info("创建存储空间成功"); |
||||
return bucket.getName(); |
||||
} |
||||
|
||||
return bucketNames; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除存储空间bucketName |
||||
* |
||||
* @param ossClient oss对象 |
||||
* @param bucketName 存储空间 |
||||
*/ |
||||
public static void deleteBucket(OSS ossClient, String bucketName) { |
||||
ossClient.deleteBucket(bucketName); |
||||
logger.info("删除" + bucketName + "Bucket成功"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 创建模拟文件夹:多级目录 |
||||
* |
||||
* @param ossClient oss连接 |
||||
* @param bucketName 存储空间 |
||||
* @param folder 模拟文件夹名如"upload/2023/01/11/" |
||||
* @return 文件夹名 |
||||
*/ |
||||
public static String createFolder(OSS ossClient, String bucketName, String folder) { |
||||
// 文件夹名
|
||||
final String keySuffixWithSlash = folder; |
||||
// 判断文件夹是否存在,不存在则创建
|
||||
if (!ossClient.doesObjectExist(bucketName, keySuffixWithSlash)) { |
||||
// 创建文件夹
|
||||
ossClient.putObject(bucketName, keySuffixWithSlash, new ByteArrayInputStream(new byte[0])); |
||||
logger.info("创建文件夹成功"); |
||||
// 得到文件夹名
|
||||
OSSObject object = ossClient.getObject(bucketName, keySuffixWithSlash); |
||||
|
||||
String fileDir = object.getKey(); |
||||
return fileDir; |
||||
} |
||||
return keySuffixWithSlash; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据key删除OSS服务器上的文件 |
||||
* |
||||
* @param ossClient oss连接 |
||||
* @param bucketName 存储空间 |
||||
* @param key Bucket下的文件的路径名+文件名 如:"upload/2023/01/11/cake.jpg" |
||||
*/ |
||||
public static void deleteObject(OSS ossClient, String bucketName, String key) { |
||||
ossClient.deleteObject(bucketName, key); |
||||
logger.info("删除" + bucketName + "下的文件" + key + "成功"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 上传文件 |
||||
* |
||||
* @param ossClient oss连接 |
||||
* @param bucketName 存储空间 |
||||
* @param ossPath 上传文件相对路径+文件名如"upload/2023/01/11/cake.jpg" |
||||
* @param is 以输入流的形式上传文件 |
||||
* @param fileName 上传文件后新文件名 |
||||
* @return String 返回的唯一MD5数字签名 |
||||
*/ |
||||
public static String uploadFileOss(OSS ossClient, String bucketName, String ossPath, InputStream is, String fileName) { |
||||
try { |
||||
// 文件大小
|
||||
long fileSize = is.available(); |
||||
// 创建上传Object的Metadata
|
||||
ObjectMetadata metadata = new ObjectMetadata(); |
||||
// 上传的文件的长度
|
||||
metadata.setContentLength(is.available()); |
||||
// 指定该Object被下载时的网页的缓存行为
|
||||
metadata.setCacheControl("no-cache"); |
||||
// 指定该Object下设置Header
|
||||
metadata.setHeader("Pragma", "no-cache"); |
||||
// 指定该Object被下载时的内容编码格式
|
||||
metadata.setContentEncoding("utf-8"); |
||||
// 文件的MIME,定义文件的类型及网页编码,决定浏览器将以什么形式、什么编码读取文件。如果用户没有指定则根据Key或文件名的扩展名生成,
|
||||
// 如果没有扩展名则填默认值application/octet-stream
|
||||
metadata.setContentType(getContentType(fileName)); |
||||
// 指定该Object被下载时的名称(指示MINME用户代理如何显示附加的文件,打开或下载,及文件名称)
|
||||
metadata.setContentDisposition("filename/filesize=" + fileName + "/" + fileSize + "Byte"); |
||||
//上传文件到OSS时需要指定包含文件后缀在内的完整路径如ossPath="upload/2023/01/11/cake.jpg"
|
||||
// PutObjectResult putResult = ossClient.putObject(bucketName, ossPath, is, metadata);
|
||||
PutObjectResult putResult = ossClient.putObject(bucketName, ossPath, is, metadata); |
||||
|
||||
// 解析结果
|
||||
String resultStr = putResult.getETag(); |
||||
logger.info("唯一MD5数字签名:" + resultStr); |
||||
//上传文件后相对路径如"upload/2023/01/11/cake.jpg"
|
||||
String path = ossPath; |
||||
return path; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
logger.error("上传阿里云OSS服务器异常." + e.getMessage(), e); |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 下载文件到本地 |
||||
* |
||||
* @param ossClient oss连接 |
||||
* @param bucketName 存储空间 |
||||
* @param key Bucket下的文件的路径名+文件名 如:"upload/2023/01/11/cake.jpg" |
||||
* @param localFilePath 下载本地文件绝对路径如"C:\Users\Administrator\Desktop\oss-download\xxx.pdf" |
||||
*/ |
||||
public static void downloadFileOss(OSS ossClient, String bucketName, String key, String localFilePath) { |
||||
try { |
||||
//创建本地文件
|
||||
File file = new File(localFilePath); |
||||
GetObjectRequest objectRequest = new GetObjectRequest(bucketName, key); |
||||
//下载OSS文件到本地文件,若指定的本地文件存在则覆盖,否则新建
|
||||
ossClient.getObject(objectRequest, file); |
||||
logger.info("下载文件到本地成功"); |
||||
} catch (OSSException e) { |
||||
e.printStackTrace(); |
||||
} catch (ClientException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取上传文件对象 |
||||
* 备注:最重要的是获取上传文件的输出流InputStream |
||||
* |
||||
* @param ossClient oss连接 |
||||
* @param bucketName 存储空间 |
||||
* @param key Bucket下的文件的路径名+文件名 如:"upload/2023/01/11/cake.jpg" |
||||
* @return |
||||
*/ |
||||
public static OSSObject getObject(OSS ossClient, String bucketName, String key) { |
||||
OSSObject object = null; |
||||
try { |
||||
object = ossClient.getObject(bucketName, key); |
||||
//文件大小
|
||||
long fileSize = object.getObjectMetadata().getContentLength(); |
||||
//文件相对路径
|
||||
String ossPath = object.getKey(); |
||||
//文件输入流
|
||||
InputStream is = object.getObjectContent(); |
||||
logger.info("success to getObject,fileSize:" + fileSize + "\nossPath:" + ossPath + "\ninputStream:" + is); |
||||
|
||||
} catch (OSSException e) { |
||||
e.printStackTrace(); |
||||
} catch (ClientException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
return object; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 获取上传文件url |
||||
* |
||||
* @param ossClient |
||||
* @param bucketName |
||||
* @param key |
||||
* @return |
||||
*/ |
||||
public static String getUrl(OSS ossClient, String bucketName, String key) { |
||||
//设置URl过期时间为99年:3600L*1000*24*365*99
|
||||
Date expiration = new Date(new Date().getTime() + 3600l * 1000 * 24 * 365 * 99); |
||||
GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, key); |
||||
generatePresignedUrlRequest.setExpiration(expiration); |
||||
URL url = ossClient.generatePresignedUrl(generatePresignedUrlRequest); |
||||
String returnUrl = url.toString(); |
||||
|
||||
return returnUrl; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 通过文件名判断并获取OSS服务文件上传时文件的contentType |
||||
* |
||||
* @param fileName 文件名 |
||||
* @return 文件的contentType |
||||
*/ |
||||
public static String getContentType(String fileName) { |
||||
// 文件的后缀名
|
||||
String fileExtension = fileName.substring(fileName.lastIndexOf(".")); |
||||
logger.info("getContentType->fileName={},fileExtension={}", fileName, fileExtension); |
||||
for (AliyunOssFileTypeEnum e : AliyunOssFileTypeEnum.values()) { |
||||
if (e.getCode().equalsIgnoreCase(fileExtension)) { |
||||
return e.getText(); |
||||
} |
||||
} |
||||
// 默认返回类型
|
||||
return AliyunOssFileTypeEnum.TXT.getText(); |
||||
} |
||||
|
||||
|
||||
// 测试
|
||||
public static void main(String[] args) throws FileNotFoundException { |
||||
//阿里云OSS账号自行到阿里云官网申请
|
||||
String ossEndpoint = "XXX"; |
||||
String accessId = "XXX"; |
||||
String accessKey = "XXX"; |
||||
String bucketName = "test"; |
||||
// 初始化OSSClient
|
||||
OSS ossClient = AliyunOSSClientUtil.getOssClient(ossEndpoint, accessId, accessKey); |
||||
|
||||
|
||||
//测试创建多级目录
|
||||
/*String tmpDir = "upload/2023/01/11/"; |
||||
String folder = createFolder(ossClient, bucketName, tmpDir); |
||||
System.out.println("folder:"+folder);*/ |
||||
|
||||
|
||||
//测试删除文件
|
||||
/*String key="upload/2023/01/11/xxx.pdf"; |
||||
deleteObject(ossClient,bucketName,key);*/ |
||||
|
||||
|
||||
//测试上传文件
|
||||
/*String pathAndname = "C:\\Users\\Administrator\\Desktop\\测试文件上传\\xxx.pdf"; |
||||
File file = new File(pathAndname); |
||||
//原始文件名:带后缀
|
||||
String oldfilename = file.getName(); |
||||
//新文件名:带后缀
|
||||
String newfilename = "9065df0f3ab72419b36d2dec088e11d6.pdf";//可以自行生成随机唯一文件名
|
||||
String newpath = "C:\\Users\\Administrator\\Desktop\\upload\\2023\\01\\11\\"; |
||||
String ossPath = newpath + newfilename; |
||||
InputStream is = new FileInputStream(file); |
||||
String absolutePath = uploadFileOss(ossClient, bucketName, ossPath, is, newfilename); |
||||
System.out.println("absolutePath:"+absolutePath);*/ |
||||
|
||||
|
||||
//测试获取文件url
|
||||
/*String key="upload/2023/01/11/9065df0f3ab72419b36d2dec088e11d6.pdf"; |
||||
String url = getUrl(ossClient, bucketName, key); |
||||
System.out.println("url:"+url);*/ |
||||
|
||||
|
||||
//测试获取上传对象
|
||||
/*String key = "upload/2023/01/11/9065df0f3ab72419b36d2dec088e11d6.pdf"; |
||||
getObject(ossClient, bucketName, key);*/ |
||||
|
||||
|
||||
//测试下载文件到本地
|
||||
/*String key = "upload/2023/01/11/9065df0f3ab72419b36d2dec088e11d6.pdf"; |
||||
String localFilePath = "C:\\Users\\Administrator\\Desktop\\oss-download\\xxx.pdf"; |
||||
downloadFileOss(ossClient, bucketName, key, localFilePath);*/ |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
package com.teaching.backend.utils; |
||||
|
||||
public enum AliyunOssFileTypeEnum { |
||||
BMP(".bmp","image/bmp"), |
||||
GIF(".gif","image/gif"), |
||||
JPEG(".jpeg","image/jpeg"), |
||||
JPG(".jpg","image/jpeg"), |
||||
PNG(".png","image/jpeg"), |
||||
HTML(".html","text/html"), |
||||
XML(".xml","text/xml"), |
||||
TXT(".txt","application/octet-stream"), |
||||
SQL(".sql","application/octet-stream"), |
||||
VSD(".vsd","application/vnd.visio"), |
||||
PDF(".pdf","application/pdf"), |
||||
PPT(".ppt","application/vnd.ms-powerpoint"), |
||||
PPTX(".pptx","application/vnd.ms-powerpoint"), |
||||
DOC(".doc","application/msword"), |
||||
DOCX(".docx","application/msword"), |
||||
XLS(".xls","application/vnd.ms-excel"), |
||||
XLSX(".xlsx","application/vnd.ms-excel"), |
||||
CSV(".csv","application/vnd.ms-excel"); |
||||
|
||||
|
||||
String code; |
||||
|
||||
|
||||
String text; |
||||
|
||||
|
||||
AliyunOssFileTypeEnum() { |
||||
} |
||||
|
||||
|
||||
AliyunOssFileTypeEnum(String code, String text) { |
||||
this.code = code; |
||||
this.text = text; |
||||
} |
||||
|
||||
|
||||
public String getCode() { |
||||
return code; |
||||
} |
||||
|
||||
|
||||
public void setCode(String code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
|
||||
public String getText() { |
||||
return text; |
||||
} |
||||
|
||||
|
||||
public void setText(String text) { |
||||
this.text = text; |
||||
} |
||||
} |
@ -0,0 +1,83 @@ |
||||
server: |
||||
port: 8080 |
||||
spring: |
||||
application: |
||||
name: teaching-backend |
||||
servlet: |
||||
multipart: |
||||
enabled: true |
||||
max-file-size: 10MB |
||||
max-request-size: 10MB |
||||
neo4j: |
||||
uri: bolt://10.121.12.242:7687 |
||||
authentication: |
||||
username: neo4j # 连接Neo4j数据P库的用户名 |
||||
password: neo4j123456 # 连接Neo4j数据库的密码 |
||||
mvc: |
||||
pathmatch: |
||||
matching-strategy: ant_path_matcher |
||||
datasource: |
||||
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
url: jdbc:mysql://10.121.12.242:3306/teaching_db2 |
||||
username: root |
||||
password: root |
||||
|
||||
mybatis: |
||||
configuration: |
||||
map-underscore-to-camel-case: true |
||||
mapper-locations: |
||||
- classpath:mapper/*.xml |
||||
- classpath*:com/**/mapper/*.xml |
||||
jwt: |
||||
tokenHeader: Authorization |
||||
secret: mySecret |
||||
expiration: 604800 |
||||
tokenHead: Bearer |
||||
knife4j: |
||||
enable: true |
||||
openapi: |
||||
title: 111 |
||||
description: "123" |
||||
concat: zjh |
||||
version: v1.0.0 |
||||
group: |
||||
default: |
||||
group-name: default |
||||
api-rule: package |
||||
api-rule-resources: |
||||
- com.teaching.backend.controller |
||||
secure: |
||||
ignored: |
||||
urls: |
||||
# - /swagger-ui/ |
||||
# - /swagger-resources/** |
||||
# - /**/v2/api-docs |
||||
# - /**/*.html |
||||
# - /**/*.js |
||||
# - /**/*.css |
||||
# - /**/*.png |
||||
# - /**/*.map |
||||
# - /favicon.ico |
||||
# - /actuator/** |
||||
# - /druid/** |
||||
# - /user/** |
||||
# - /user/login |
||||
# - /user/register |
||||
# - /user/info |
||||
# - /user/logout |
||||
# - /minio/upload |
||||
- /** |
||||
aliyun: |
||||
oss: |
||||
endpoint: oss-cn-wuhan-lr.aliyuncs.com |
||||
accessKeyId: LTAI5tFkdu3y5WddxbjgaG2F |
||||
accessKeySecret: 1xUchxUTlmUBoTV5JQIrKsVjSkmsLF |
||||
bucketName: ceshi132132 |
||||
minio: |
||||
endpoint: http://39.106.16.162:9090 #MinIO服务所在地址 |
||||
bucketName: teaching # 存储桶名称 |
||||
accessKey: minioadmin # 访问的key |
||||
secretKey: minioadmin # 访问的秘钥 |
||||
filename: |
||||
maxlength: 10 |
||||
|
@ -0,0 +1,22 @@ |
||||
${AnsiColor.BRIGHT_RED}_ooOoo_ ${AnsiColor.BRIGHT_YELLOW} |
||||
${AnsiColor.BRIGHT_RED}o8888888o ${AnsiColor.BRIGHT_YELLOW} |
||||
${AnsiColor.BRIGHT_RED}88${AnsiColor.BRIGHT_YELLOW}" . "${AnsiColor.BRIGHT_RED}88 ${AnsiColor.BRIGHT_YELLOW} |
||||
(| -_- |) ${AnsiColor.BRIGHT_YELLOW} |
||||
${AnsiColor.BLUE}O${AnsiColor.BRIGHT_YELLOW}\ = /${AnsiColor.BLUE}O ${AnsiColor.BRIGHT_YELLOW} |
||||
____/`---'\____ ${AnsiColor.BRIGHT_YELLOW} |
||||
.' \\| |// `. ${AnsiColor.BRIGHT_YELLOW} |
||||
/ \\||| : |||// \ ${AnsiColor.BRIGHT_YELLOW} |
||||
/ _||||| -:- |||||- \ ${AnsiColor.BRIGHT_YELLOW} |
||||
| | \\\ - /// | | ${AnsiColor.BRIGHT_YELLOW} |
||||
| \_| ''\---/'' | | ${AnsiColor.BRIGHT_YELLOW} |
||||
\ .-\__ `-` ___/-. / ${AnsiColor.BRIGHT_YELLOW} |
||||
___`. .' /--.--\ `. . __ ${AnsiColor.BRIGHT_YELLOW} |
||||
."" '< `.___\_<|>_/___.' >'"". ${AnsiColor.BRIGHT_YELLOW} |
||||
| | : `- \`.;`\ _ /`;.`/ - ` : | | ${AnsiColor.BRIGHT_YELLOW} |
||||
\ \ `-. \_ __\ /__ _/ .-` / / ${AnsiColor.BRIGHT_YELLOW} |
||||
${AnsiColor.BRIGHT_MAGENTA}======${AnsiColor.BRIGHT_YELLOW}`-.____`-.___\_____/___.-`____.-'${AnsiColor.BRIGHT_MAGENTA}====== |
||||
`=---=' |
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
||||
^ 佛祖保佑 永无BUG ^ |
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
||||
|
@ -1,13 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.teaching.backend.mapper.courses.ObjectiveContentKnowMapper"> |
||||
|
||||
<insert id="insertBatchSomeColumn" parameterType="java.util.List"> |
||||
INSERT INTO objective_content_know (objective_or_content, know) |
||||
VALUES |
||||
<foreach collection="list" item="item" index="index" separator=","> |
||||
(#{item.objectiveOrContent}, #{item.know}) |
||||
</foreach> |
||||
</insert> |
||||
|
||||
</mapper> |
@ -1,5 +0,0 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.teaching.backend.mapper.courses.ObjectiveContentsMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,29 @@ |
||||
package com.teaching.yh; |
||||
|
||||
/** |
||||
* @Author:youhang |
||||
* @Date:2024-10-12-7:31 |
||||
* @Description: |
||||
*/ |
||||
public class testTryCatch { |
||||
} |
||||
|
||||
class Test04 { |
||||
public static void main(String[] args) { |
||||
System.out.println(test()); |
||||
} |
||||
private static int test() { |
||||
int temp = 1; |
||||
try { |
||||
System.out.println(temp); |
||||
} catch (Exception e) { |
||||
System.out.println(temp); |
||||
return ++temp; |
||||
} finally { |
||||
++temp; |
||||
System.out.println(temp); |
||||
} |
||||
return ++temp; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue