瀏覽代碼

评论列表页面完成

南鑫林 5 年之前
父節點
當前提交
0ea393496f

+ 5 - 1
RainbowPlanet/RainbowPlanet/Model/VirusModel/VirueRecordAddParameterModel.swift

@@ -52,11 +52,13 @@ class VirueRecordAddParameterModel: NSObject, Mappable{
     /// 当前评论内容
     var commentContent : String?
     /// 上级评论ID
-    var parentCommentId : String?
+    var parentCommentId : Int?
     /// 上级评论内容
     var parentCommentContent : String?
     /// 上级评论人用户ID
     var parentCommentUid : Int?
+    //上级评论时间
+    var parentCommentTime : String?
     /// 帖子ID
     var postId : Int?
     /// 评论ID
@@ -114,6 +116,8 @@ class VirueRecordAddParameterModel: NSObject, Mappable{
         parentCommentContent <- map["parent_comment_content"]
         /// 上级评论人用户ID
         parentCommentUid <- map["parent_comment_uid"]
+        /// 上级评论时间
+        parentCommentTime <- map["parent_comment_time"]
         /// 帖子ID
         postId <- map["post_id"]
         /// 评论ID

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift

@@ -352,7 +352,7 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
                 return cell
             }else {
                 let cell = RecommendMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
-                cell.postId = id
+                cell.communityPostDetailModel = communityPostDetailModel
                 cell.communityPostCommentModel = communityPostCommentModels[indexPath.row]
                 cell.frame = tableView.bounds
                 cell.layoutIfNeeded()

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendMajorCommentCell.swift

@@ -172,7 +172,7 @@ class RecommendMajorCommentCell: UITableViewCell {
     }
     
     /// 帖子Id
-    var postId : Int?
+    var communityPostDetailModel : CommunityPostDetailModel?
 }
 
 
@@ -200,7 +200,7 @@ extension RecommendMajorCommentCell: UITableViewDataSource, UITableViewDelegate
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
         let vc = CommunitySubCommentController()
         vc.communityPostCommentModel = communityPostCommentModel
-        vc.postId = postId
+        vc.communityPostDetailModel = communityPostDetailModel
         findViewController()?.navigationController?.pushViewController(vc, animated: true)
     }
     

+ 12 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/ViewController/CommunitySubCommentController.swift

@@ -11,8 +11,9 @@ import IQKeyboardManagerSwift
 
 class CommunitySubCommentController: BaseViewController {
     
-    var postId : Int?
+    var communityPostDetailModel : CommunityPostDetailModel?
     var communityPostCommentModel : CommunityPostCommentModel?
+    
     var communityPostReplyModels = Array<CommunityPostReplyModel>()
     var communityPostReplyModel : CommunityPostReplyModel?
 
@@ -102,7 +103,7 @@ extension CommunitySubCommentController {
     
     func communityPostCommentApi(text:String) {
         let communityCustomCommnetModel = CommunityCustomCommnetModel()
-        communityCustomCommnetModel.postId = postId ?? 0
+        communityCustomCommnetModel.postId = communityPostDetailModel?.id ?? 0
         communityCustomCommnetModel.content = text
         communityCustomCommnetModel.parentId = communityPostCommentModel?.id
         communityCustomCommnetModel.replyUid = communityPostReplyModel?.uid
@@ -124,6 +125,15 @@ extension CommunitySubCommentController {
             self?.communityPostReplyModels.insert(communityPostReplyModel, at: 0)
             self?.tableView.reloadSections([1], with: UITableView.RowAnimation.none)
             self?.commentInputView.sendSuccess()
+            
+            if self?.communityPostReplyModel != nil {
+                VirusViewModel.shared.comment(communityPostDetailModel: (self?.communityPostDetailModel)!, communityPostCommentModel: (self?.communityPostCommentModel)!, communityPostReplyModel: (self?.communityPostReplyModel)!)
+                
+            }else {
+                VirusViewModel.shared.comment(communityPostDetailModel: (self?.communityPostDetailModel)!, communityPostCommentModel: (self?.communityPostCommentModel)!)
+
+            }
+            
         }
     }
 }

+ 33 - 0
RainbowPlanet/RainbowPlanet/ViewModel/Virus/VirusViewModel.swift

@@ -432,3 +432,36 @@ extension VirusViewModel {
         })
     }
 }
+// MARK: - 评论
+extension VirusViewModel {
+    func comment(communityPostDetailModel:CommunityPostDetailModel,communityPostCommentModel:CommunityPostCommentModel,communityPostReplyModel:CommunityPostReplyModel? = nil) {
+        let virueRecordAddParameterModel = VirueRecordAddParameterModel()
+        virueRecordAddParameterModel.behaviorId = (ConfigModel.shared.object()?.virus?.publish ?? "")
+        virueRecordAddParameterModel.behaviorFlag = BehaviorFlagType.publish.rawValue
+
+        virueRecordAddParameterModel.postId = communityPostDetailModel.id
+        virueRecordAddParameterModel.postAuthorUid = "\(communityPostDetailModel.uid!)"
+        if communityPostDetailModel.title == nil ||  communityPostDetailModel.title == "" {
+            virueRecordAddParameterModel.postDesc = String(describing: communityPostDetailModel.content!.prefix(20))
+        }else {
+            virueRecordAddParameterModel.postDesc = communityPostDetailModel.title
+        }
+        virueRecordAddParameterModel.postType = communityPostDetailModel.type
+        virueRecordAddParameterModel.postCover = communityPostDetailModel.img
+        virueRecordAddParameterModel.targetId = "\((UserModel.shared().getModel()?.uid)!)"
+        
+        virueRecordAddParameterModel.commentId = communityPostCommentModel.id
+        virueRecordAddParameterModel.commentContent = communityPostCommentModel.content
+        virueRecordAddParameterModel.actionId = "\(communityPostCommentModel.id ?? 0)"
+        
+        virueRecordAddParameterModel.parentCommentId = communityPostReplyModel?.id
+        virueRecordAddParameterModel.parentCommentContent = communityPostReplyModel?.content
+        virueRecordAddParameterModel.parentCommentUid = communityPostReplyModel?.uid
+        virueRecordAddParameterModel.parentCommentTime = communityPostReplyModel?.createdAt
+
+        
+        SwiftMoyaNetWorkServiceVirus.shared().virueRecordAddApi(virueRecordAddParameterModel: virueRecordAddParameterModel, completion: {(data) -> (Void) in
+        })
+    }
+    
+}