コード例 #1
0
  @RequestMapping(value = "addBlogs.action", method = RequestMethod.POST)
  @ResponseBody
  public Object addBlogs(Blogs blogs, HttpServletRequest request) throws IOException {
    User_Ext_Personal user_Ext_Personal = PublicUtil.getUserOfSession(request);
    if (user_Ext_Personal == null) {
      return "needLogin";
    }
    blogs.setUserid(user_Ext_Personal.getUserId());

    MultipartHttpServletRequest httpServletRequest = (MultipartHttpServletRequest) request;
    MultipartFile file = httpServletRequest.getFile("image");
    String fileName = file.getOriginalFilename();
    byte[] b = file.getBytes();
    File dirFile =
        new File(PublicUtil.getRootFileDirectory(request) + "/media_upload/personal_upload");
    if (!dirFile.exists()) {
      dirFile.mkdirs();
    }
    String imagepath =
        "/media_upload/personal_upload/" + new Hanyu().getStringPinYin(blogs.getTitle()) + fileName;
    File files = new File(PublicUtil.getRootFileDirectory(request) + imagepath);
    if (!files.exists()) {
      dirFile.createNewFile();
    }

    FileCopyUtils.copy(b, files);

    boolean bool = blogsService.addBlogs(blogs, imagepath, null);

    return bool + "";
  }
コード例 #2
0
  @RequestMapping("getBlogsList.action")
  @ResponseBody
  public List<Blogs> getBlogsList(HttpServletRequest request) {

    List<Blogs> blogsList = blogsService.getBlogsByMethod(0, 0, null);
    return blogsList;
  }
コード例 #3
0
 @RequestMapping("getBlogsDetail.action")
 @ResponseBody
 public Blogs getBlogs(String blogid, HttpServletRequest request) {
   List<Blogs> blogsList = blogsService.getBlogsByMethod(1, 0, null, blogid);
   return blogsList.get(0);
 }