Skip to content

Commit

Permalink
Merge pull request #134 from inje-megabrain/feat/admin
Browse files Browse the repository at this point in the history
Feat/admin
  • Loading branch information
Ahn-JuHwan authored Mar 17, 2024
2 parents 1873eda + ece8220 commit 353f38e
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 62 deletions.
Binary file modified .gradle/7.2/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.2/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.2/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
78 changes: 78 additions & 0 deletions application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
gpt :
model: gpt-3.5-turbo
api:
key: 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
url: https://api.openai.com/v1/chat/completions
baseUrl : https://just-s3.s3.ap-northeast-2.amazonaws.com/
server:
port: 9000
cloud:
aws:
credentials:
accessKey: AKIA2PIR5NDYRVE3NDUN
secretKey: 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
region: ap-northeast-2
bucketName: just-s3
stack:
auto: false
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher #Swagger 문제로 추가함 ㅇㅇ
jackson:
default-property-inclusion: non-null
## # -> #까지 뭔지 알아오기 (해석하고 발표하시길)
datasource: ## 뭔지 알아오기
hikari:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://13.209.213.191:3306/just?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC&characterEncoding=UTF-8
username: admin
password: 334334334!
connection-timeout: 15000 #30초 설정
maximum-pool-size: 150 #150개 설정

security:
oauth2:
client:
registration:
kakao:
client-id: 55ec14b78e17e978a4a3b64971060784
redirect-uri: http://13.209.213.191:9000/api/kakao/access_token
client-authentication-method: POST
client-secret: QREhvyjJygyPKlqkJtSFc91GUlvBqA5K
authorization-grant-type: authorization_code
scope:
- account_email
- profile_nickname
client_name: Kakao
provider:
kakao:
authorization-uri: https://kauth.kakao.com/oauth/authorize
token-uri: https://kauth.kakao.com/oauth/token
user-info-uri: https://kapi.kakao.com/v2/user/me
user-name-attribute: id
## #->해석해오기
jpa:
database: mysql
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
generate-ddl: true
open-in-view: false
hibernate:
ddl-auto: validate
## - >필수로 마스터 해오기
naming:
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
use-new-id-generator-mappings: true
properties:
hibernate:
show_sql: false
format_sql: true
enable_lazy_load_no_trans: true

server-add: 13.209.213.191
api-url: https://kauth.kakao.com/oauth/authorize?client_id=55ec14b78e17e978a4a3b64971060784&redirect_uri=http://13.209.213.191:9000/api/kakao/access_token&response_type=code

jwt:
header: Authorization
secret: QREhvyjJygyPKlqkJtSFc91GUlvBqA5KaijdfijAIfj41jkjiUIJHI3ji123AasdhfuAUSLNJUIGh098587KJMGKN134JBN8
token-validity-in-seconds: 86400
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
<<<<<<< HEAD
date = "2024-03-17T14:02:16+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.21 (Oracle Corporation)"
=======
date = "2024-03-14T18:31:05+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
>>>>>>> 1873eda5ea1d8642f1745319bf607ddf3962b063
)
@Component
public class MemberMapperImpl implements MemberMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
<<<<<<< HEAD
date = "2024-03-17T14:02:15+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.21 (Oracle Corporation)"
=======
date = "2024-03-14T18:31:05+0900",
comments = "version: 1.5.3.Final, compiler: IncrementalProcessingEnvironment from gradle-language-java-7.2.jar, environment: Java 11.0.11 (AdoptOpenJDK)"
>>>>>>> 1873eda5ea1d8642f1745319bf607ddf3962b063
)
@Component
public class PostMapperImpl implements PostMapper {
Expand Down
99 changes: 42 additions & 57 deletions src/main/java/com/example/just/Admin/AdminController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
import com.example.just.Dao.HashTag;
import com.example.just.Dao.Member;
import com.example.just.Dao.Post;
import com.example.just.Repository.HashTagMapRepository;
import com.example.just.Repository.*;
import com.example.just.Response.ResponseUpdateHashtagsDto;
import com.example.just.Repository.CommentRepository;
import com.example.just.Repository.HashTagRepository;
import com.example.just.Repository.MemberRepository;
import com.example.just.Repository.PostRepository;
import com.example.just.Service.ResponsePost;
import com.example.just.Service.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -20,9 +16,8 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.example.just.Service.MemberService;
import com.example.just.Service.CommentService;
import com.example.just.Service.PostService;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand All @@ -43,24 +38,35 @@ public class AdminController {
private CommentRepository commentRepository;
@Autowired
private MemberRepository memberRepository;


@Autowired
private PostRepository postRepository;
@Autowired
private HashTagRepository hashTagRepository;
@Autowired
private HashTagMapRepository hashTagMapRepository;
@Autowired
private HashTagESRepository hashTagESRepository;
@Autowired
private BlameService blameService;

@ApiOperation(value = "멤버 리스트 불러옴 admin페이지에서 members 페이지로 이동할때")
@Operation(summary = "members리스트 뽑는다", description = "\n admin페이지->members페이지-> 리스트 리턴")
@ApiOperation(value = "멤버 리스트 불러옴 admin 페이지에서 members 페이지로 이동할때")
@Operation(summary = "members 리스트 뽑는다", description = "\n admin 페이지->members 페이지-> 리스트 리턴")
@GetMapping("/members")
public ResponseEntity<List<Member>> memberList() {
List<Member> members = memberService.findMembers();
return new ResponseEntity<>(members, HttpStatus.OK);
}


@ApiOperation(value = "신고받은 멤버 조회")
@Operation(summary = "신고받은 멤버 조회", description = "\n 신고받은 횟수가 0보다 큰 멤버 조회")
@GetMapping("/reported-members")
public ResponseEntity<List<Member>> getReportedMembers() {
// 1 이상의 신고를 받은 멤버만 조회
ResponseEntity<List<Member>> reportedMembersResponse = blameService.getBlamedList("member");
List<Member> reportedMembers = reportedMembersResponse.getBody();
return new ResponseEntity<>(reportedMembers, HttpStatus.OK);
}


@ApiOperation(value = "멤버페이지에서 회원 삭제 기능 ")
@Operation(summary = "회원 삭제", description = "\n member_id 헤더로 받고 데이터베이스 비교 후 회원 삭제")
@DeleteMapping("/members/{member_id}")
Expand All @@ -72,8 +78,8 @@ public ResponseEntity drop(@PathVariable Long member_id) {
return new ResponseEntity<>("해당 회원이 존재하지 않습니다.", HttpStatus.BAD_REQUEST);
}

@ApiOperation(value = "comments페이지에서 comment 리스트 불러옴")
@Operation(summary = "comments리스트", description = "\n admin페이지 -> comments->페이지로 return하여 리스트 뽑")
@ApiOperation(value = "comments 페이지에서 comment 리스트 불러옴")
@Operation(summary = "comments 리스트", description = "\n admin 페이지 -> comments->페이지로 return 하여 리스트 뽑")
@GetMapping("/comments")
public ResponseEntity<List<Comment>> commentList() {
List<Comment> comments = commentService.getAllComments();
Expand All @@ -82,26 +88,24 @@ public ResponseEntity<List<Comment>> commentList() {

//댓글 삭제
@ApiOperation(value = "댓글 아이디와 멤버 아이디 비교 후 삭제 ")
@Operation(summary = "댓글 삭제", description = "\n comment_id, member_id 헤더로 받고 데이터베이스 비교 후 회원 삭제")
@DeleteMapping("/comments/{comment_id}/{member_id}")
@Operation(summary = "댓글 삭제", description = "\n comment_id, 헤더로 받고 데이터베이스 비교 후 회원 삭제")
@DeleteMapping("/comments/{comment_id}/")
public ResponseEntity<String> deleteComment(@PathVariable Long comment_id) {
Comment comment = commentRepository.findById(comment_id)
.orElseThrow(() -> new RuntimeException("부모 댓글이 존재하지 않습니다."));
List<Comment> children = comment.getChildren();
if (children != null) {
for (Comment child : children) {
commentRepository.delete(child);
}
commentRepository.deleteAll(children);
}
commentRepository.deleteById(comment_id);
return ResponseEntity.ok("ok");
}


@ApiOperation(value = "게시물 리스트 불러옴 posts페이지에서")
@Operation(summary = "게시글 리스트", description = "\n admin 페이지-> posts페이지-> return하여 post list 출력")
@ApiOperation(value = "게시물 리스트 불러옴 posts 페이지에서")
@Operation(summary = "게시글 리스트", description = "\n admin 페이지-> posts 페이지-> return 하여 post list 출력")
@GetMapping("/posts")
public ResponseEntity<List<Post>> postList() {
public ResponseEntity<List<Post>> PostList() {
List<Post> posts = postService.getAllPostList();
return new ResponseEntity<>(posts, HttpStatus.OK);
}
Expand All @@ -116,45 +120,26 @@ public ResponsePost deletePost(@PathVariable Long post_id) throws NotFoundExcept
ResponsePost responsePost = new ResponsePost(post_id, "삭제 완료");
return responsePost;
}
/*

@ApiOperation(value = "포스트페이지 해시태그 수정 ")
@Operation(summary = "해시태그 수정", description = "\n hashtag_id 헤더로 받고 내용을 수정하면 새로운 해시태그를 생성하여 저장 ex) id_101 -> id_104로")
@PutMapping("/posts/{hashtag_id}")
public ResponseEntity<?> updateHashtags(@PathVariable Long hashtag_id, @RequestBody List<String> newHashtags)
throws NotFoundException {
Optional<HashTag> optionalHashtag = hashTagRepository.findById(hashtag_id);
@PutMapping("/hashtags/{hashtag_id}")
public ResponseEntity<?> updateHashTag(@PathVariable Long hashtag_id, @RequestBody String newName) {
Optional<HashTag> optionalHashTag = hashTagRepository.findById(hashtag_id);

if (!optionalHashtag.isPresent()) {
throw new NotFoundException();
if (!optionalHashTag.isPresent()) {
return ResponseEntity.notFound().build();
}

HashTag existingHashtag = optionalHashtag.get();
Post post = existingHashtag.getPost();
// 기존 게시물의 해시태그 제거
List<HashTag> existingHashtags = hashTagRepository.findByPost(post);
for (HashTag hashtag : existingHashtags) {
hashTagRepository.deleteById(hashtag.getId());
}
HashTag hashTag = optionalHashTag.get();
hashTag.setName(newName);
hashTagRepository.save(hashTag);

// 새로운 해시태그를 생성 저장
List<HashTag> updatedHashtags = newHashtags.stream()
.map(name -> {
HashTag hashtag = new HashTag();
hashtag.setName(name);
hashtag.setPost(post);
return hashtag;
})
.collect(Collectors.toList());
hashTagRepository.saveAll(updatedHashtags);
// 업데이트된 정보 DTO 반환
ResponseUpdateHashtagsDto response = new ResponseUpdateHashtagsDto(hashtag_id, newHashtags);
return ResponseEntity.ok(response);
return ResponseEntity.ok("해시태그 내용이 성공적으로 수정되었습니다.");
}
*/
}





2 changes: 1 addition & 1 deletion src/main/java/com/example/just/JustApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ public static void main(String[] args) {
SpringApplication.run(JustApplication.class, args);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import com.example.just.Document.HashTagDocument;
import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.data.repository.CrudRepository;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/example/just/Service/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class PostService {
private GptService gptService;

@Autowired
PostContentESRespository postContentESRespository;
private PostContentESRespository postContentESRespository;
@Autowired
private HashTagMapRepository hashTagMapRepository;

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/example/just/CommentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.example.just.Dao.Role;
import com.example.just.Dto.CommentDto;
import com.example.just.Dto.PutCommentDto;
import com.example.just.Dto.ResponseMyCommentDto;
import com.example.just.Dto.ResponsePostCommentDto;
import com.example.just.Response.ResponseMyCommentDto;
import com.example.just.Response.ResponsePostCommentDto;
import com.example.just.Repository.CommentRepository;
import com.example.just.Repository.MemberRepository;
import com.example.just.Repository.PostRepository;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/example/just/KakaoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.example.just.Dao.Member;
import com.example.just.Dao.Role;
import com.example.just.Dto.ResponseMemberDto;
import com.example.just.Response.ResponseMemberDto;
import com.example.just.Repository.MemberRepository;
import com.example.just.Service.KakaoService;
import com.example.just.jwt.JwtFilter;
Expand Down

0 comments on commit 353f38e

Please sign in to comment.