发表于: 2017-12-21 23:20:45
1 620
今天完成的事
完成通用的上传图片的接口
// 上传图片
@RequestMapping(value = "/a/u/student/img",method = RequestMethod.POST)
public String uploadUserImg(HttpServletRequest request,
HttpServletResponse response, ModelMap model, @RequestParam("file") MultipartFile file,
Long uid)
throws Exception{
String suffix=file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
String fileName=(uid+"-"+new Date().getTime()+"."+suffix);
String accessKeyId = "LTAIEuiSVY1K2l2K";
String accessKeySecret = "Yt5fRAleL5oUBKFcZ2E5xeD7uGhqc9";
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
byte[] content = file.getBytes();
ossClient.putObject("manatsu123", fileName, new ByteArrayInputStream(content));
ossClient.shutdown();
model.addAttribute("img",imgURL);
return "/user/json/userUploadHeadJson";
}
完成了用户的收藏列表接口
// 收藏列表
@RequestMapping(value = "/a/u/student/collection/list",method = RequestMethod.GET)
public String getArticleList(HttpServletRequest request,HttpServletResponse response,ModelMap model,
@RequestParam("uid")Long uid,
@RequestParam("type")Long type,
@RequestParam("nowPage")Integer nowPage
) throws Exception{
String str=null;
Integer start=(nowPage-1)*10;
List<Long> idList=new ArrayList<>();
Map<String, Object> map = DynamicUtil.getCollectionIDs(uid,type);
idList= collectionService.getIdsByDynamicCondition(Collection.class, map, start, 10);
if (type.equals(1)){
List<Article> articleList=articleService.getObjectsByIds(idList);
model.addAttribute("code",0);
model.addAttribute("articleList",articleList);
str="/user/json/userCollectionArticle";
}
if (type.equals(0)){
List<Video> videoList=videoService.getObjectsByIds(idList);
model.addAttribute("code",0);
model.addAttribute("videoList",videoList);
str="/user/json/userCollectionVideo";
}
return str;
明天计划的事
写定时任务
遇到的问题
无
收获
无
评论