Commit 0ebf5a9a3391878bf244c9c1c74c491f4286e74f

Authored by gaohan
1 parent e6ce99750f
Exists in dev

修改获取未读数量的代码bug

Showing 2 changed files with 43 additions and 6 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CourseController.java View file @ 0ebf5a9
... ... @@ -8,8 +8,10 @@
8 8 import com.lyms.platform.common.result.BaseResponse;
9 9 import com.lyms.platform.operate.web.facade.CourseFacade;
10 10 import com.lyms.platform.operate.web.request.CourseRequest;
  11 +import com.lyms.platform.operate.web.utils.UploadResult;
11 12 import com.lyms.platform.pojo.CourseEvaluateModel;
12 13 import com.lyms.platform.pojo.MsgModel;
  14 +import org.apache.commons.lang.StringUtils;
13 15 import org.springframework.beans.factory.annotation.Autowired;
14 16  
15 17 import org.springframework.stereotype.Controller;
16 18  
17 19  
... ... @@ -18,14 +20,17 @@
18 20 import javax.servlet.http.HttpServletRequest;
19 21 import java.io.File;
20 22 import java.io.IOException;
  23 +import java.util.HashMap;
  24 +import java.util.Map;
21 25  
22 26  
23   -
24 27 /**
25 28 * 课程
26 29 */
27 30 @Controller
28 31 public class CourseController extends BaseController {
  32 + // 允许上传的格式 图片形式
  33 + private static final String[] IMAGE_TYPE = new String[]{".bmp", ".jpg", ".jpeg", ".png"};
29 34  
30 35 @Autowired
31 36 private CourseFacade courseFacade;
32 37  
... ... @@ -386,9 +391,35 @@
386 391 */
387 392 @RequestMapping(method = RequestMethod.GET, value = "/getMsgCountById")
388 393 @ResponseBody
389   - public String getMsgCountById(@RequestParam(required = false) String parentId,
  394 + public BaseResponse getMsgCountById(@RequestParam(required = false) String parentId,
390 395 HttpServletRequest request) {
391 396 return courseFacade.getMsgCountById(parentId);
392 397 }
  398 +
  399 + @RequestMapping(method = RequestMethod.POST, value = "/uploadFile",produces = "application/json;charset=utf-8")
  400 + @ResponseBody
  401 + public String uploadImage(@RequestParam("file") MultipartFile file,
  402 + HttpServletRequest request){
  403 + try {
  404 + //请求参数
  405 + Map<String,String[]> parameterMap = request.getParameterMap();
  406 + // 文件名
  407 + String fileName = file.getOriginalFilename();
  408 + //文件类型
  409 + String contentType = file.getContentType();
  410 + //上传路径
  411 + String filePath = "f://" + fileName;
  412 +
  413 + File demoFile = new File(filePath);
  414 +
  415 + //上传
  416 + file.transferTo(demoFile);
  417 + return "上传成功";
  418 + } catch (Exception e) {
  419 + e.printStackTrace();
  420 + return "上传失败";
  421 + }
  422 + }
  423 +
393 424 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/CourseFacade.java View file @ 0ebf5a9
... ... @@ -29,6 +29,7 @@
29 29 import org.springframework.data.mongodb.core.MongoTemplate;
30 30 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
31 31 import org.springframework.stereotype.Component;
  32 +import org.springframework.web.multipart.MultipartFile;
32 33  
33 34  
34 35 import java.text.DecimalFormat;
35 36  
36 37  
... ... @@ -1266,14 +1267,15 @@
1266 1267 return objectResponse;
1267 1268 }
1268 1269  
1269   - public String getMsgCountById(String parentId) {
  1270 + public BaseResponse getMsgCountById(String parentId) {
  1271 + BaseListResponse baseResponse = new BaseListResponse();
1270 1272 MsgQuery msgQuery = new MsgQuery();
1271 1273 msgQuery.setYn(YnEnums.YES.getId());
1272 1274 msgQuery.setNeed("true");
1273 1275 List<MsgModel> models = courseEvalService.queryMsgList(msgQuery);
1274   -// 初始化计数器
  1276 + // 初始化计数器
1275 1277 int notContainCount = 0;
1276   -// 遍历 models 列表
  1278 + // 遍历 models 列表
1277 1279 for (MsgModel model : models) {
1278 1280 // 获取当前消息的 readCount
1279 1281 String readCount = model.getReadCount();
1280 1282  
... ... @@ -1283,7 +1285,11 @@
1283 1285 notContainCount++;
1284 1286 }
1285 1287 }
1286   - return String.valueOf(notContainCount);
  1288 + baseResponse.setData(Collections.singletonList(notContainCount));
  1289 + baseResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  1290 + baseResponse.setErrormsg("成功");
  1291 + return baseResponse;
1287 1292 }
  1293 +
1288 1294 }