diff --git a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/controller/CommunityController.java b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/controller/CommunityController.java index dbf776b..41f06b3 100644 --- a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/controller/CommunityController.java +++ b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/controller/CommunityController.java @@ -73,14 +73,15 @@ public ResponseEntity verifyIfPrivilegeStatus( return communityService.verifyIfPrivilegeStatus(token, organizeId); } -// @GetMapping("/community/{organizeId}/privilege/status") -// public ResponseEntity verifyIfPrivilegeStatus( -// @RequestHeader(required = true, name = "Authorization") String token, -// @PathVariable String organizeId) { -// return communityService.verifyIfPrivilegeStatus(token, organizeId); -// } - - @GetMapping("/communitys/user/{uid}") + @GetMapping("/communitys/admin/user/{uid}") + public ResponseEntity findAllCommunityOwnedByUser( + @PathVariable String uid, + @RequestParam(required = false, defaultValue = "0") int page, + @RequestParam(required = false, defaultValue = "10") int contentPerPage) { + return communityService.findAllCommunityOwnedByUser(uid, page, contentPerPage); + } + + @GetMapping("/communitys/subscribe/user/{uid}") public ResponseEntity findAllCommunityThatUserSubscribe( @PathVariable String uid, @RequestParam(required = false, defaultValue = "0") int page, diff --git a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/model/User.java b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/model/User.java index 8aae848..374dd61 100644 --- a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/model/User.java +++ b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/model/User.java @@ -28,6 +28,7 @@ public class User { private String role; + @Indexed private String uid; private String email; diff --git a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/repository/CommunityRepository.java b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/repository/CommunityRepository.java index af55ede..c439112 100644 --- a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/repository/CommunityRepository.java +++ b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/repository/CommunityRepository.java @@ -33,5 +33,7 @@ public interface CommunityRepository extends MongoRepository{ public Page findByInterestTagsIsIn(String[] interestTags, PageRequest of); public Optional findByCommunityId(String communityId); + + public Page findByCommunityOwnerUid(String uid, PageRequest of); } diff --git a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/service/CommunityService.java b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/service/CommunityService.java index 04becb3..c7f44a4 100644 --- a/Microservice/CommunityService/src/main/java/com/meetu/communityservice/service/CommunityService.java +++ b/Microservice/CommunityService/src/main/java/com/meetu/communityservice/service/CommunityService.java @@ -305,7 +305,7 @@ public ResponseEntity verifyIfPrivilegeStatus(String token, String communityId) UserCommunity subscribedCommunity = userCommunityRepository.findByUidAndCommunityId(uid, communityId); Community communityInDatabase = communityRepository.findByCommunityId(communityId).get(); if (uid.equals(communityInDatabase.getCommunityOwner().getUid())) { - response.put("isAdmin", true); + response.put("isOwner", true); } if (subscribedCommunity != null) { response.put("isSubscribe", true); @@ -339,4 +339,8 @@ public ResponseEntity updateCommunity(String token, String communityId, Communit return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); } + public ResponseEntity findAllCommunityOwnedByUser(String uid, int page, int contentPerPage) { + return new ResponseEntity(communityRepository.findByCommunityOwnerUid(uid, PageRequest.of(page, contentPerPage)), HttpStatus.OK); + } + } diff --git a/nuxt-firebase-auth-master/assets/default/community.png b/nuxt-firebase-auth-master/assets/default/community.png new file mode 100644 index 0000000..6158be5 Binary files /dev/null and b/nuxt-firebase-auth-master/assets/default/community.png differ diff --git a/nuxt-firebase-auth-master/components/communityCard.vue b/nuxt-firebase-auth-master/components/communityCard.vue index 400e511..8600bc6 100644 --- a/nuxt-firebase-auth-master/components/communityCard.vue +++ b/nuxt-firebase-auth-master/components/communityCard.vue @@ -29,9 +29,12 @@ export default { name: "CommunityCard", props: { - communityPictureCover: String, + communityPictureCover: { + type: String, + default: require(`@/assets/default/community.png`) + }, communityName: String, - memberLists: Array + memberLists: Array, } }; diff --git a/nuxt-firebase-auth-master/pages/community/_communityId.vue b/nuxt-firebase-auth-master/pages/community/_communityId.vue index e22d2b1..9ac1837 100644 --- a/nuxt-firebase-auth-master/pages/community/_communityId.vue +++ b/nuxt-firebase-auth-master/pages/community/_communityId.vue @@ -162,7 +162,7 @@ -
+

@@ -174,6 +174,11 @@ {{ getUser.displayName}} + + + clear + + @@ -227,8 +232,8 @@ {{ post.displayName}} - - + + clear @@ -406,8 +411,7 @@ export default { imagePost: null, postPictureListsUrl: [], postPictureLists: null, - defaultImage: - "https://www.elegantthemes.com/blog/wp-content/uploads/2017/03/Facebook-Groups-for-Bloggers-shutterstock_555845587-ProStockStudio-FT.png", + defaultImage: require(`@/assets/default/community.png`), remove: ["remove"], post: "", newPost: "", @@ -645,9 +649,37 @@ export default { }); } }, - removePost(todo) { - const postIndex = this.postList.indexOf(todo); - this.postList.splice(postIndex, 1); + removePost(index, postId) { + this.postList.splice(index, 1); + console.log("remove post work") + }, + removeNewPost(index, postId) { + this.newPostList.splice(index, 1); + }, + removePostFromDatabase(postId){ + let loader = this.$loading.show(); + axios + .post( + `${process.env.COMMUNITY_SERVICE}/community/${this.communityId}/unsubscribe`, + null, + { + headers: { + Authorization: `Bearer ${localStorage.getItem("jwtToken")}` + } + } + ) + .then(joinCommunityResponse => { + this.isSubscribe = !this.isSubscribe; + loader.hide(); + }) + .catch(err => { + this.$swal({ + type: "error", + title: "Failed to subscribe community !!!", + text: `${err.response.data.response}` + }); + loader.hide(); + }); }, addComment(postIndex) { let value = this.comment && this.comment.trim(); @@ -698,7 +730,7 @@ export default { `${process.env.COMMUNITY_SERVICE}/community/${this.communityId}/posts?page=${this.page}` ) .then(postListResponse => { - if (postListResponse.data.content.length > 1) { + if (postListResponse.data.content.length > 0) { postListResponse.data.content.forEach(post => this.postList.push(post) ); diff --git a/nuxt-firebase-auth-master/pages/community/index.vue b/nuxt-firebase-auth-master/pages/community/index.vue index 1fef171..00f448b 100644 --- a/nuxt-firebase-auth-master/pages/community/index.vue +++ b/nuxt-firebase-auth-master/pages/community/index.vue @@ -150,7 +150,7 @@ export default { communityName: "", interestTags: [], categoryList: [], - defaultImage: "https://www.elegantthemes.com/blog/wp-content/uploads/2017/03/Facebook-Groups-for-Bloggers-shutterstock_555845587-ProStockStudio-FT.png" + defaultImage: require(`@/assets/default/community.png`) }; }, watch: { @@ -182,7 +182,7 @@ export default { `${process.env.COMMUNITY_SERVICE}/communitys?communityName=${this.communityName}${interestTags}&page=${this.page}` ) .then(response => { - if (response.data.length > 1) { + if (response.data.length > 0) { response.data.forEach(community => this.communityList.push(community) ); diff --git a/nuxt-firebase-auth-master/pages/community/myCommunity.vue b/nuxt-firebase-auth-master/pages/community/myCommunity.vue index 4141fce..d5aaf42 100644 --- a/nuxt-firebase-auth-master/pages/community/myCommunity.vue +++ b/nuxt-firebase-auth-master/pages/community/myCommunity.vue @@ -2,16 +2,27 @@

My Community

- +
+ + + + + + +
diff --git a/nuxt-firebase-auth-master/pages/community/subscribeCommunity.vue b/nuxt-firebase-auth-master/pages/community/subscribeCommunity.vue index 94aa332..d2a3926 100644 --- a/nuxt-firebase-auth-master/pages/community/subscribeCommunity.vue +++ b/nuxt-firebase-auth-master/pages/community/subscribeCommunity.vue @@ -28,7 +28,7 @@ export default { { communityDetail: [ { - communityPictureCover: "", + communityPictureCover: require(`@/assets/default/community.png`), communityName: "" } ] @@ -51,7 +51,7 @@ export default { let loader = this.$loading.show(); axios .get( - `${process.env.COMMUNITY_SERVICE}/communitys/user/${this.getUser.uid}` + `${process.env.COMMUNITY_SERVICE}/communitys/subscribe/user/${this.getUser.uid}` ) .then(subscribeCommunityResponse => { this.communityList = subscribeCommunityResponse.data;