瀏覽代碼

作者:张哲
时间:2023/08/29
类型:开发
描述:问题6:知识地图对接考试系统

zizg 1 年之前
父節點
當前提交
7eedecdbe9

+ 4 - 1
src/main/java/com/redxun/knowledge/album/service/AlbumCategoryServiceImpl.java

@@ -193,7 +193,10 @@ public class AlbumCategoryServiceImpl extends SuperServiceImpl<AlbumCategoryMapp
             albumCategoryVo.setCreateByName(userService.queryUser(albumCategory.getCreateBy()).getFullName());
         }
         if (StringUtils.isNotEmpty(albumCategory.getMaintainer())){
-            albumCategoryVo.setMaintainerName(userService.queryUser(albumCategory.getMaintainer()).getFullName());
+            String maintainerName = Arrays.stream(albumCategory.getMaintainer().split(",")).
+                    map(maintainer -> userService.queryOsUserDto(maintainer).getFullName()).
+                    collect(Collectors.joining(","));
+            albumCategoryVo.setMaintainerName(maintainerName);
         }
         return albumCategoryVo;
     }

+ 15 - 0
src/main/java/com/redxun/knowledge/map/controller/MapController.java

@@ -14,6 +14,7 @@ import com.redxun.common.base.search.QueryFilterBuilder;
 import com.redxun.common.constant.HttpMethodConstants;
 import com.redxun.common.utils.ContextUtil;
 import com.redxun.common.utils.ExceptionUtil;
+import com.redxun.knowledge.map.entity.dto.PkIdDto;
 import com.redxun.knowledge.map.entity.vo.KnowledgeVo;
 import com.redxun.knowledge.map.entity.vo.OsUserVo;
 import com.redxun.knowledge.map.entity.dao.Map;
@@ -28,6 +29,8 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
@@ -171,6 +174,18 @@ public class MapController extends BaseController<Map> {
         return jsonResult.setData(knowledgeVo);
     }
 
+    @ApiOperation("设置地图学习内容学习状态")
+    @PostMapping("updateLearningStateV2")
+    public JsonResult updateLearningStateV2(@Validated @RequestBody PkIdDto pkIdDto, BindingResult validResult) {
+        JsonResult jsonResult = JsonResult.getSuccessResult("");
+        if (validResult.hasErrors()) {
+            return jsonResult.setMessage("参数错误");
+        }
+        mapService.updateLearningStateV2(pkIdDto.getPkId(),pkIdDto.getUserId());
+        //jsonResult.setMessage("考试完成!");
+        return jsonResult.setData("");
+    }
+
 
 }
 

+ 25 - 0
src/main/java/com/redxun/knowledge/map/entity/dto/PkIdDto.java

@@ -0,0 +1,25 @@
+package com.redxun.knowledge.map.entity.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import java.io.Serializable;
+
+/**
+ * 文件名: PkIdDto
+ * 作者: zizg
+ * 时间: 2023/8/29
+ * 描述:
+ * 修改人:
+ * 修改时间:
+ * 修改内容:
+ */
+@Data
+public class PkIdDto implements Serializable {
+
+    @NotEmpty(message = "内容id不能为空")
+    private String pkId;
+
+    @NotEmpty(message = "用户id不能为空")
+    private String userId;
+}

+ 18 - 0
src/main/java/com/redxun/knowledge/map/service/MapServiceImpl.java

@@ -345,6 +345,24 @@ public class MapServiceImpl extends SuperServiceImpl<MapMapper, Map> implements
         }
     }
 
+    /**
+     * 设置地图学习内容学习状态-PC端
+     *
+     * @param pkId
+     */
+    public void updateLearningStateV2(String pkId,String userId) {
+        String mapId = mapContentMapper.selectById(pkId).getMapId();
+        if (mapContentMapper.selectById(pkId) != null) {
+            MapLearning mapLearning = new MapLearning();
+            mapLearning.setPkId(IdGenerator.getIdStr());
+            mapLearning.setMapId(mapId);
+            mapLearning.setRouteId(mapContentMapper.selectById(pkId).getRouteId());
+            mapLearning.setContentId(pkId);
+            mapLearning.setUserId(userId);
+            mapLearningMapper.insert(mapLearning);
+        }
+    }
+
     /**
      * PC端根据知识地图ID获取知识地图详情数据
      *