feat(manuscript): 稿件正文增加 content_format 格式标记
- cms_manuscript 新增 content_format(html/markdown/text),默认 html - Manuscript 实体加 contentFormat;保存与修改时缺省按 html 落库,下游不再靠猜 - 迁移脚本幂等,并把明显是 markdown 的历史行标出来
This commit is contained in:
@@ -19,6 +19,7 @@ import com.gxwebsoft.gxmu.service.ReviewListService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -67,6 +68,7 @@ public class ManuscriptController extends BaseController {
|
||||
@ApiOperation("添加稿件")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Manuscript manuscript) {
|
||||
normalizeContentFormat(manuscript);
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
@@ -98,6 +100,7 @@ public class ManuscriptController extends BaseController {
|
||||
@ApiOperation("修改稿件")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Manuscript manuscript) {
|
||||
normalizeContentFormat(manuscript);
|
||||
if (manuscriptService.updateById(manuscript)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
@@ -113,6 +116,17 @@ public class ManuscriptController extends BaseController {
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 正文格式兜底:客户端没带 contentFormat 时按 html 存,
|
||||
* 避免下游(小程序、后台列表)拿到空值又得靠内容猜格式。
|
||||
* 实际上写库前正文应已统一成 HTML(后台编辑器保存时转换)。
|
||||
*/
|
||||
private void normalizeContentFormat(Manuscript manuscript) {
|
||||
if (!StringUtils.hasText(manuscript.getContentFormat())) {
|
||||
manuscript.setContentFormat("html");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加稿件")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Manuscript> list) {
|
||||
|
||||
@@ -32,6 +32,9 @@ public class Manuscript implements Serializable {
|
||||
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "正文格式:html/markdown/text")
|
||||
private String contentFormat;
|
||||
|
||||
private String cover;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
|
||||
Reference in New Issue
Block a user