Ver código fonte

社区默认头像

夏文涛 2 anos atrás
pai
commit
949457fae9

+ 14 - 6
mhotel/src/com/happy/action/articleTweetAction.java

@@ -8,6 +8,7 @@ import com.happy.Model.*;
 import com.happy.Model.weixin.Users;
 import com.happy.Until.*;
 import com.happy.common.controller.BaseController;
+import com.happy.constant.ConstDefault;
 import com.happy.constant.ResultStatusCode;
 import com.happy.dto.ArticleCommentDto;
 import com.happy.dto.ArticleTweetDto;
@@ -115,7 +116,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             data.setApprove(1);//正在审批
             data.setStatus(1);
             data.setUserName(user.getUser_name());
-            data.setUserPhoto(user.getHeadPhoto());
+            data.setUserPhoto(user.getHeadPhoto() == null ? ConstDefault.DefaultHeadPhoto : user.getHeadPhoto());
             int aId = articleTweetService.insert(data);
             if (aId <= 0) {
                 ResUtil.writeJson(ServletActionContext.getResponse(), new JSONObject() {{
@@ -235,14 +236,21 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
         if (fileInfoList != null) {
             if (fileInfoList.size() > 1) {
                 result.setImages(fileInfoList.stream().map(FileInfo::getUrl).collect(Collectors.toList()));
-            } else {
-                result.setVideo(fileInfoList.get(0).getUrl());
+            } else if (fileInfoList.size() == 1) {
+                String url = fileInfoList.get(0).getUrl();
+                if (!url.endsWith("jpg") && !url.endsWith("png")) {
+                    result.setVideo(fileInfoList.get(0).getUrl());
+                } else {
+                    List<String> images = new ArrayList<>();
+                    images.add(url);
+                    result.setImages(images);
+                }
             }
         }
 
         result.setUserId(data.getUserId());
         result.setUserName(data.getUserName());
-        result.setUserPhoto(data.getUserPhoto());
+        result.setUserPhoto(data.getUserPhoto() == null ? ConstDefault.DefaultHeadPhoto : data.getUserPhoto());
         //region 关注
         if (articleTweetDto.getUserId().equals(data.getUserId())) {
             result.setIsFollow(2);//自己的推文
@@ -869,7 +877,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
         articleComment.setCommentParentId(articleCommentDto.getParentId());
         articleComment.setCommentId(articleCommentDto.getUserId());
         articleComment.setCommentName(user.getUser_name());
-        articleComment.setCommentImage(user.getHeadPhoto());
+        articleComment.setCommentImage(user.getHeadPhoto() == null ? ConstDefault.DefaultHeadPhoto : user.getHeadPhoto());
         articleComment.setContent(articleCommentDto.getContent());
         articleComment.setCreateId(articleCommentDto.getUserId());
         articleComment.setCreateDate(now);
@@ -988,7 +996,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             data.setArticleId(articleTweetDto.getId());
             data.setLikeId(articleTweetDto.getUserId());
             data.setLikeName(user.getUser_name());
-            data.setLikeImage(user.getHeadPhoto());
+            data.setLikeImage(user.getHeadPhoto() == null ? ConstDefault.DefaultHeadPhoto : user.getHeadPhoto());
             data.setIsLose(0);
             data.setCreateId(articleTweetDto.getUserId());
             data.setCreateDate(now);

+ 2 - 2
mhotel/src/com/happy/dao/impl/ArticleTweetImplDao.java

@@ -64,8 +64,8 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
                 "values(:userId,:userName,:userPhoto,:title,:content,:locationId,:hotelId,:createId,:createDate,:status,:approve) ";
         MapSqlParameterSource sps = new MapSqlParameterSource();
         sps.addValue("userId", articleTweet.getUserId());
-        sps.addValue("userName", articleTweet.getApprove());
-        sps.addValue("userPhoto", articleTweet.getApprove());
+        sps.addValue("userName", articleTweet.getUserName());
+        sps.addValue("userPhoto", articleTweet.getUserPhoto());
         sps.addValue("title", articleTweet.getTitle());
         sps.addValue("content", articleTweet.getContent());
         sps.addValue("locationId", articleTweet.getLocationId());