|
|
|
@ -59,7 +59,7 @@ public class TopicActivityController {
|
|
|
|
|
private Integer duration;
|
|
|
|
|
@Schema(title = "封面")
|
|
|
|
|
private String cover;
|
|
|
|
|
@Schema(title = "是否首页显示",description = "0否;1是")
|
|
|
|
|
@Schema(title = "是否首页显示", description = "0否;1是")
|
|
|
|
|
private Integer showAtIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -70,7 +70,7 @@ public class TopicActivityController {
|
|
|
|
|
public Result add(@Validated @RequestBody AddTopicParam param) {
|
|
|
|
|
TopicActivity topicActivity = new TopicActivity().setTitle(param.getTitle()).setSubtitle(param.getSubtitle())
|
|
|
|
|
.setType(param.getType()).setContent(param.getContent()).setDuration(param.getDuration()).setCover(param.getCover()).setCreatAt(LocalDateTime.now());
|
|
|
|
|
if(param.getShowAtIndex() !=null && param.getShowAtIndex() == 1){
|
|
|
|
|
if (param.getShowAtIndex() != null && param.getShowAtIndex() == 1) {
|
|
|
|
|
topicActivity.setShowAtIndex(1);
|
|
|
|
|
}
|
|
|
|
|
topicActivityService.save(topicActivity);
|
|
|
|
@ -101,31 +101,55 @@ public class TopicActivityController {
|
|
|
|
|
private Integer id;
|
|
|
|
|
@Schema(title = "标题")
|
|
|
|
|
private String title;
|
|
|
|
|
@Schema(title = "副标题")
|
|
|
|
|
private String subtitle;
|
|
|
|
|
@Schema(title = "内容")
|
|
|
|
|
private String content;
|
|
|
|
|
@Schema(title = "类型", description = "1视频;2图片;3文章")
|
|
|
|
|
private Integer type;
|
|
|
|
|
@Schema(title = "封面")
|
|
|
|
|
private String cover;
|
|
|
|
|
@Schema(title = "时长", description = "视频文件请上传时长")
|
|
|
|
|
private Integer duration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "更新动态内容")
|
|
|
|
|
@PostMapping("/upd")
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public Result upd(@Validated @RequestBody UpdTopicParam param) {
|
|
|
|
|
return MybatisPlusUtil.sqlResult(topicActivityService.updateById(new TopicActivity().setId(param.getId()).setTitle(param.getTitle()).setType(param.getType()).setCover(param.getCover()).setContent(param.getContent()).setUpdateAt(LocalDateTime.now())), "修改");
|
|
|
|
|
UpdateWrapper<TopicActivity> qw = new UpdateWrapper<>();
|
|
|
|
|
qw.eq("id", param.getId())
|
|
|
|
|
.set(param.getTitle() != null, "title", param.getTitle())
|
|
|
|
|
.set(param.getSubtitle() != null, "title", param.getSubtitle())
|
|
|
|
|
.set(param.getType() != null, "title", param.getType())
|
|
|
|
|
.set(param.getCover() != null, "title", param.getCover())
|
|
|
|
|
.set(param.getDuration() != null, "title", param.getDuration())
|
|
|
|
|
.set(param.getContent() != null, "title", param.getContent())
|
|
|
|
|
.set("updateAt", LocalDateTime.now());
|
|
|
|
|
return MybatisPlusUtil.sqlResult(topicActivityService.update(qw), "修改");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
|
static class ListTopicParam {
|
|
|
|
|
private Integer pageNum;
|
|
|
|
|
private Integer pageSize;
|
|
|
|
|
@Schema(title = "标题")
|
|
|
|
|
private String keyword;
|
|
|
|
|
@Schema(title = "是否为首页展示", description = "1:是,2否")
|
|
|
|
|
private Boolean showAtIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "动态列表")
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public Result list(@RequestBody(required = false) JSONObject obj) {
|
|
|
|
|
public Result list(@Validated @RequestBody ListTopicParam param) {
|
|
|
|
|
QueryWrapper<TopicActivity> qw = new QueryWrapper<>();
|
|
|
|
|
qw.orderByDesc("updateAt","creatAt");
|
|
|
|
|
if(obj.getBoolean("showAtIndex") !=null && obj.getBoolean("showAtIndex") == true){
|
|
|
|
|
qw.eq("showAtIndex",1);
|
|
|
|
|
qw.like(param.getKeyword() != null, "title", param.getKeyword());
|
|
|
|
|
qw.orderByDesc("updateAt", "creatAt");
|
|
|
|
|
if (param.getShowAtIndex() != null && param.getShowAtIndex() == true) {
|
|
|
|
|
qw.eq("showAtIndex", 1);
|
|
|
|
|
}
|
|
|
|
|
return Result.success(topicActivityService.pageMaps(MybatisPlusUtil.SetPage(obj),qw));
|
|
|
|
|
return Result.success(topicActivityService.pageMaps(MybatisPlusUtil.SetNumPage(param.getPageNum(), param.getPageSize()), qw));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Data
|
|
|
|
@ -140,7 +164,7 @@ public class TopicActivityController {
|
|
|
|
|
@PostMapping("/detail")
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public Result detail(@Validated @RequestBody TaskController.DetTaskParam param) {
|
|
|
|
|
int id =param.getId();
|
|
|
|
|
int id = param.getId();
|
|
|
|
|
TopicActivity topicActivity = topicActivityService.getById(id);
|
|
|
|
|
return topicActivity != null ? Result.success(topicActivity) : Result.fail(HttpStatusEnum.NOT_FOUND);
|
|
|
|
|
}
|
|
|
|
@ -154,7 +178,7 @@ public class TopicActivityController {
|
|
|
|
|
@NotNull(message = "showAtIndex不能为空")
|
|
|
|
|
@Min(value = 0, message = "取值是:0否;1是")
|
|
|
|
|
@Max(value = 1, message = "取值是:0否;1是")
|
|
|
|
|
@Schema(title = "是否首页显示",description = "0否;1是")
|
|
|
|
|
@Schema(title = "是否首页显示", description = "0否;1是")
|
|
|
|
|
private Integer showAtIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -163,8 +187,8 @@ public class TopicActivityController {
|
|
|
|
|
@AdminTokenValid
|
|
|
|
|
public Result showAtIndex(@Validated @RequestBody showAtIndexParam param) {
|
|
|
|
|
UpdateWrapper<TopicActivity> updateWrapper = new UpdateWrapper<>();
|
|
|
|
|
updateWrapper.eq("id", param.getId()).set("showAtIndex",param.getShowAtIndex());
|
|
|
|
|
return MybatisPlusUtil.sqlResult(topicActivityService.update(updateWrapper),"编辑");
|
|
|
|
|
updateWrapper.eq("id", param.getId()).set("showAtIndex", param.getShowAtIndex());
|
|
|
|
|
return MybatisPlusUtil.sqlResult(topicActivityService.update(updateWrapper), "编辑");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|