|
@@ -37,48 +37,7 @@ public class QuestionCollectionController extends BaseController {
|
|
|
@Autowired
|
|
|
private IQuestionCollectionService questionCollectionService;
|
|
|
|
|
|
- /**
|
|
|
- * 查询collection列表
|
|
|
- */
|
|
|
-
|
|
|
- @GetMapping("/list")
|
|
|
- @ApiOperation("查询collection列表")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
|
|
|
- @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
|
|
|
- })
|
|
|
- public ResponsePageInfo<QuestionCollection> list(@ModelAttribute QuestionCollectionListDTO dto) {
|
|
|
- dto.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
|
|
|
- startPage();
|
|
|
- List<QuestionCollection> list = questionCollectionService.selectQuestionCollectionList(dto);
|
|
|
- return toResponsePageInfo(list);
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 导出collection列表
|
|
|
- */
|
|
|
-// @PreAuthorize("@ss.hasPermi('question:collection:export')")
|
|
|
-// @Log(title = "collection", businessType = BusinessTypeEnum.EXPORT)
|
|
|
-// @GetMapping("/export")
|
|
|
-// @ApiOperation("导出collection列表Excel")
|
|
|
-// public Response<String> export(@ModelAttribute QuestionCollection questionCollection){
|
|
|
-// List<QuestionCollection> list = questionCollectionService.selectQuestionCollectionList(questionCollection);
|
|
|
-// ExcelUtil<QuestionCollection> util = new ExcelUtil<QuestionCollection>(QuestionCollection.class);
|
|
|
-// return util.exportExcel(list, "collection");
|
|
|
-// }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取collection详细信息
|
|
|
- */
|
|
|
-// @PreAuthorize("@ss.hasPermi('question:collection:query')")
|
|
|
- @GetMapping(value = "/{id}")
|
|
|
- @ApiOperation("获取collection详细信息")
|
|
|
- public Response<QuestionCollection> getInfo(
|
|
|
- @ApiParam(name = "id", value = "collection参数", required = true)
|
|
|
- @PathVariable("id") Long id
|
|
|
- ) {
|
|
|
- return Response.success(questionCollectionService.getById(id));
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 新增collection
|
|
@@ -102,7 +61,7 @@ public class QuestionCollectionController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("collections")
|
|
|
- @ApiOperation("批量新增collection")
|
|
|
+ @ApiOperation("合并本机和云端收藏")
|
|
|
public Response<Integer> collections(@RequestBody List<QuestionCollectionDTO> list) {
|
|
|
//查询该用户已收藏的题目列表
|
|
|
QuestionCollectionListDTO dto = new QuestionCollectionListDTO();
|
|
@@ -110,7 +69,6 @@ public class QuestionCollectionController extends BaseController {
|
|
|
List<QuestionCollection> dblist = questionCollectionService.selectQuestionCollectionList(dto);
|
|
|
List<String> questionIds = dblist.stream().map(o -> (o.getQuestionId()+","+o.getKm())).collect(Collectors.toList());
|
|
|
|
|
|
-
|
|
|
List<QuestionCollection> qlist = new ArrayList<QuestionCollection>();
|
|
|
for (QuestionCollectionDTO questionCollectionDTO : list) {
|
|
|
if (questionIds.contains(questionCollectionDTO.getQuestionId()+","+questionCollectionDTO.getKm())) {
|
|
@@ -128,34 +86,31 @@ public class QuestionCollectionController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 修改collection
|
|
|
- */
|
|
|
- @Log(title = "collection", businessType = BusinessTypeEnum.UPDATE)
|
|
|
- @PutMapping
|
|
|
- @ApiOperation("修改collection")
|
|
|
- public Response<Integer> edit(@RequestBody QuestionCollectionDTO questionCollectionDTO) {
|
|
|
- QuestionCollection questionCollection = new QuestionCollection();
|
|
|
- BeanUtils.copyProperties(questionCollectionDTO, questionCollection);
|
|
|
- questionCollection.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
|
|
|
- return toResponse(questionCollectionService.updateById(questionCollection) ? 1 : 0);
|
|
|
- }
|
|
|
+ @PostMapping("bakCollections")
|
|
|
+ @ApiOperation("备份本机收藏到云端")
|
|
|
+ public Response<Integer> bakCollections(@RequestBody List<QuestionCollectionDTO> list,Integer km) {
|
|
|
+ //首先删除云端数据
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getStudent().getId();
|
|
|
+ QueryWrapper<QuestionCollection> queryWrapper = new QueryWrapper<QuestionCollection>();
|
|
|
+ queryWrapper.eq("user_id",userId);
|
|
|
+ queryWrapper.eq("km",km);
|
|
|
+ questionCollectionService.remove(queryWrapper);
|
|
|
|
|
|
- /**
|
|
|
- * 删除collection
|
|
|
- */
|
|
|
- @Log(title = "collection", businessType = BusinessTypeEnum.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
- @ApiOperation("删除collection")
|
|
|
- public Response<Integer> remove(
|
|
|
- @ApiParam(name = "ids", value = "collectionids参数", required = true)
|
|
|
- @PathVariable Long[] ids
|
|
|
- ) {
|
|
|
- return toResponse(questionCollectionService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
|
|
+ //保存上传的收藏题
|
|
|
+ List<QuestionCollection> qlist = new ArrayList<QuestionCollection>();
|
|
|
+ for (QuestionCollectionDTO questionCollectionDTO : list) {
|
|
|
+ QuestionCollection questionCollection = new QuestionCollection();
|
|
|
+ BeanUtils.copyProperties(questionCollectionDTO, questionCollection);
|
|
|
+ questionCollection.setUserId(userId);
|
|
|
+ qlist.add(questionCollection);
|
|
|
+ }
|
|
|
+ if (qlist.isEmpty()) {
|
|
|
+ throw new CustomException("请先收藏题目。");
|
|
|
+ }
|
|
|
+ return toResponse(questionCollectionService.saveBatch(qlist) ? 1 : 0);
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Log(title = "collectionQuestion", businessType = BusinessTypeEnum.DELETE)
|
|
|
@DeleteMapping("/cancel/{questionId}")
|
|
|
@ApiOperation("取消收藏")
|
|
|
public Response<Integer> remove(
|
|
@@ -171,7 +126,6 @@ public class QuestionCollectionController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Log(title = "collectionQuestion", businessType = BusinessTypeEnum.DELETE)
|
|
|
@DeleteMapping("/cancelAll")
|
|
|
@ApiOperation("清空收藏")
|
|
|
public Response<Integer> removeAll(@RequestBody QuestionCollectionDelDTO questionCollectionDelDTO){
|
|
@@ -179,14 +133,13 @@ public class QuestionCollectionController extends BaseController {
|
|
|
QueryWrapper<QuestionCollection> queryWrapper = new QueryWrapper<QuestionCollection>();
|
|
|
queryWrapper.eq("user_id",userId);
|
|
|
queryWrapper.eq("km",questionCollectionDelDTO.getKm());
|
|
|
- queryWrapper.eq("car_type",questionCollectionDelDTO.getCarType());
|
|
|
questionCollectionService.remove(queryWrapper);
|
|
|
return Response.success();
|
|
|
}
|
|
|
|
|
|
|
|
|
@GetMapping("/collectionByUser")
|
|
|
- @ApiOperation("根据用户获取收藏列表")
|
|
|
+ @ApiOperation("恢复云端收藏到本机(根据用户获取收藏题)")
|
|
|
public Response<List<QuestionInfo>> collectionByUser(@ModelAttribute QuestionCollectionListDTO dto){
|
|
|
dto.setUserId(SecurityUtils.getLoginUser().getStudent().getId());
|
|
|
List<QuestionInfo> list = questionCollectionService.selectCollectionByUserId(dto);
|