|
|
@ -61,7 +61,7 @@ public class TeachingRefeController {
|
|
|
|
if (fileUrl.lastIndexOf(".") == -1) {
|
|
|
|
if (fileUrl.lastIndexOf(".") == -1) {
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "文件错误");
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "文件错误");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
teachingRefeService.save(new TeachingRefe().setFileUrl(fileUrl).setType(FileTypeUtil.getcontentTypeNum(fileUrl.substring(fileUrl.lastIndexOf("."))))
|
|
|
|
teachingRefeService.addTeachingRefe(new TeachingRefe().setFileUrl(fileUrl).setType(FileTypeUtil.getcontentTypeNum(fileUrl.substring(fileUrl.lastIndexOf("."))))
|
|
|
|
.setTitle(param.getTitle()).setCreatAt(LocalDateTime.now()));
|
|
|
|
.setTitle(param.getTitle()).setCreatAt(LocalDateTime.now()));
|
|
|
|
return Result.success("添加完成");
|
|
|
|
return Result.success("添加完成");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -74,11 +74,11 @@ public class TeachingRefeController {
|
|
|
|
private Integer id;
|
|
|
|
private Integer id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
@Operation(summary = "删除(软删除)")
|
|
|
|
@PostMapping("/del")
|
|
|
|
@PostMapping("/del")
|
|
|
|
@adminTokenValid
|
|
|
|
@adminTokenValid
|
|
|
|
public Result del(@Validated @RequestBody DelTCRParam param) {
|
|
|
|
public Result del(@Validated @RequestBody DelTCRParam param) {
|
|
|
|
return MybatisPlusUtil.sqlResult(teachingRefeService.removeById(param.getId()), "删除");
|
|
|
|
return MybatisPlusUtil.sqlResult(teachingRefeService.update(new UpdateWrapper<TeachingRefe>().eq("id", param.getId()).set("sortWeight",0).set("isDeleted", 1)), "删除");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
@Data
|
|
|
@ -93,7 +93,7 @@ public class TeachingRefeController {
|
|
|
|
private String fileUrl;
|
|
|
|
private String fileUrl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "更新标签名称")
|
|
|
|
@Operation(summary = "更新教程")
|
|
|
|
@PostMapping("/upd")
|
|
|
|
@PostMapping("/upd")
|
|
|
|
@adminTokenValid
|
|
|
|
@adminTokenValid
|
|
|
|
public Result upd(@Validated @RequestBody UpdTCRParam param) {
|
|
|
|
public Result upd(@Validated @RequestBody UpdTCRParam param) {
|
|
|
@ -122,8 +122,37 @@ public class TeachingRefeController {
|
|
|
|
@adminTokenValid
|
|
|
|
@adminTokenValid
|
|
|
|
public Result list(@Validated @RequestBody listTCRParam param) {
|
|
|
|
public Result list(@Validated @RequestBody listTCRParam param) {
|
|
|
|
QueryWrapper<TeachingRefe> qw = new QueryWrapper<>();
|
|
|
|
QueryWrapper<TeachingRefe> qw = new QueryWrapper<>();
|
|
|
|
qw.orderByDesc("updateAt", "creatAt").like(param.getTitle() != null, "title", param.getTitle());
|
|
|
|
qw.eq("isDeleted",0).orderByDesc("updateAt", "creatAt").like(param.getTitle() != null, "title", param.getTitle());
|
|
|
|
return Result.success(teachingRefeService.pageMaps(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw));
|
|
|
|
return Result.success(teachingRefeService.pageMaps(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
|
|
|
static class UpdTRSParam {
|
|
|
|
|
|
|
|
@NotNull(message = "id不能为空")
|
|
|
|
|
|
|
|
@Min(value = 1, message = "id最小值为1")
|
|
|
|
|
|
|
|
@Schema(title = "教程id")
|
|
|
|
|
|
|
|
private Integer id;
|
|
|
|
|
|
|
|
@NotNull(message = "排序权重不能为空")
|
|
|
|
|
|
|
|
@Min(value = 1, message = "排序权重最小值为1")
|
|
|
|
|
|
|
|
@Schema(title = "排序权重:数字越小排序靠前")
|
|
|
|
|
|
|
|
private Integer sortWeight;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "修改排序")
|
|
|
|
|
|
|
|
@PostMapping("/updSort")
|
|
|
|
|
|
|
|
@adminTokenValid
|
|
|
|
|
|
|
|
public Result updSort(@Validated @RequestBody UpdTRSParam param) {
|
|
|
|
|
|
|
|
TeachingRefe teachingRefe = teachingRefeService.getById(param.getId());
|
|
|
|
|
|
|
|
if(teachingRefe.getIsDeleted() == 1){
|
|
|
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION,"该标签已被删除");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int origin = teachingRefe.getSortWeight();
|
|
|
|
|
|
|
|
int current = param.getSortWeight();
|
|
|
|
|
|
|
|
if (origin == current) {
|
|
|
|
|
|
|
|
return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "权重无变化");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
teachingRefeService.updSort(origin, current, origin > current);
|
|
|
|
|
|
|
|
return Result.success("修改完成");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|