コード例 #1
0
ファイル: Photo.java プロジェクト: huayuxian/focus-sns
 @Transient
 public Long getRealFileId() {
   if (realFileId == null && realFile != null) {
     realFileId = realFile.getId();
   }
   return realFileId;
 }
コード例 #2
0
ファイル: LogoWidget.java プロジェクト: huayuxian/focus-sns
 @RequestMapping(value = "/form-action", method = RequestMethod.POST)
 @Permission(
     value = {"profile-add", "profile-edit"},
     userRequired = true)
 public @ResponseBody Object doFormAction(
     @RequestParam MultipartFile file, @RequestParam Long profileId) throws IOException {
   Attachment attachment = AttachmentUtil.parse(file);
   attachmentService.createAttachment(attachment);
   // write attachment content to local file
   AttachmentUtil.write(attachment);
   Profile profile = profileService.getProfile(profileId);
   Attachment logo = profile.getLogo();
   // delete logo
   if (logo != null) {
     // delete from disk
     AttachmentUtil.delete(logo);
     // delete from database
     attachmentService.deleteAttachment(logo.getId());
   }
   profile.setLogo(attachment);
   profileService.updateProfile(profile);
   return Collections.singletonMap("id", profile.getId());
 }
コード例 #3
0
ファイル: Photo.java プロジェクト: huayuxian/focus-sns
 public String getName() {
   if (StringUtils.isBlank(name) && realFile != null) {
     this.name = realFile.getName();
   }
   return name;
 }