Browse Source

feat: 重新生产保存草稿的逻辑

shc 3 years ago
parent
commit
6432d9499a

+ 10 - 6
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/controller/ApiController.java

@@ -819,13 +819,13 @@ public class ApiController {
 	@SysLog("新增任务内容表")
 	@SysLog("新增任务内容表")
 	@PostMapping("/saveTaskContent")
 	@PostMapping("/saveTaskContent")
 	public R saveTaskContent(@RequestBody WmTaskContent wmTaskContent) {
 	public R saveTaskContent(@RequestBody WmTaskContent wmTaskContent) {
-
+		String draftKey = wmTaskContent.getDraftKey();
 		R r = wmTaskContentService.saveTaskContent(wmTaskContent);
 		R r = wmTaskContentService.saveTaskContent(wmTaskContent);
 
 
-		log.info("结果:{}",r);
-		if (r.getCode() == 0) {
+		log.info("结果:{}, 草稿key:{}",r, draftKey);
+		if (r.getCode() == CommonConstants.SUCCESS && StrUtil.isNotEmpty(draftKey)) {
 			HnqzUser user = SecurityUtils.getUser();
 			HnqzUser user = SecurityUtils.getUser();
-			String key = String.format(CacheConstants.TASK_CONTENT_DRAFT, wmTaskContent.getTemp30(), user.getId());
+			String key = String.format(CacheConstants.TASK_CONTENT_DRAFT, draftKey, user.getId());
 			log.info("删除草稿:{}", key);
 			log.info("删除草稿:{}", key);
 			redisTemplate.delete(key);
 			redisTemplate.delete(key);
 		}
 		}
@@ -886,9 +886,13 @@ public class ApiController {
 	@PostMapping("/task-content/draft")
 	@PostMapping("/task-content/draft")
 	public R taskContentDraft(@RequestBody WmTaskContent wmTaskContent) {
 	public R taskContentDraft(@RequestBody WmTaskContent wmTaskContent) {
 
 
-		HnqzUser user = SecurityUtils.getUser();
+		// 生成草稿key
+		String draftKey = IdUtil.fastSimpleUUID();
+		log.info("草稿key:{}",draftKey);
+		wmTaskContent.setDraftKey(draftKey);
 
 
-		String key = String.format(CacheConstants.TASK_CONTENT_DRAFT, wmTaskContent.getTemp30(), user.getId());
+		HnqzUser user = SecurityUtils.getUser();
+		String key = String.format(CacheConstants.TASK_CONTENT_DRAFT, draftKey, user.getId());
 
 
 		redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(wmTaskContent));
 		redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(wmTaskContent));
 
 

+ 3 - 0
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/entity/WmTaskContent.java

@@ -240,4 +240,7 @@ public class WmTaskContent extends Model<WmTaskContent> {
 	@TableField(exist = false)
 	@TableField(exist = false)
 	private String temp32label;
 	private String temp32label;
 
 
+	@TableField(exist = false)
+	private String draftKey;
+
 }
 }