-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Kusitms-28th-Hackathon-D/feat/qogustj
feat : aws 버킷에 파일 업로드
- Loading branch information
Showing
21 changed files
with
410 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/groupD/server/controller/GroupController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.groupD.server.controller; | ||
|
||
import com.groupD.server.domain.dto.GroupRequest; | ||
import com.groupD.server.service.GroupService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/group") | ||
@RestController | ||
public class GroupController { | ||
|
||
private final GroupService groupService; | ||
@PostMapping("/write") | ||
public void write(@RequestBody GroupRequest request) { | ||
groupService.write(request); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/groupD/server/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.groupD.server.controller; | ||
|
||
import com.groupD.server.domain.dto.GroupRequest; | ||
import com.groupD.server.domain.dto.GroupResponse; | ||
import com.groupD.server.domain.entity.Group; | ||
import com.groupD.server.security.Auth; | ||
import com.groupD.server.security.AuthInfo; | ||
import com.groupD.server.service.MemberService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/members") | ||
public class MemberController { | ||
private final MemberService memberService; | ||
|
||
|
||
@GetMapping("/groups") | ||
public List<GroupResponse> getGroupsByMemberId(@Auth AuthInfo authInfo) { | ||
List<GroupResponse> groups = memberService.getGroupsByAuthInfo(authInfo); | ||
return groups; | ||
} | ||
} | ||
|
30 changes: 30 additions & 0 deletions
30
src/main/java/com/groupD/server/controller/S3Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.groupD.server.controller; | ||
|
||
import com.groupD.server.domain.dto.SignUpRequestDto; | ||
import com.groupD.server.security.Auth; | ||
import com.groupD.server.security.AuthInfo; | ||
import com.groupD.server.service.S3Uploader; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class S3Controller { | ||
private final S3Uploader s3Uploader; | ||
|
||
@PostMapping("/image") | ||
public ResponseEntity<SignUpRequestDto> updateUserImage(@Auth AuthInfo authInfo, @RequestPart("file") MultipartFile multipartFile) { | ||
try { | ||
s3Uploader.uploadFiles(multipartFile, "static"); | ||
} catch (Exception e) { | ||
return new ResponseEntity(HttpStatus.BAD_REQUEST); | ||
} | ||
return new ResponseEntity(HttpStatus.NO_CONTENT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/groupD/server/domain/dto/GroupRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.groupD.server.domain.dto; | ||
|
||
|
||
import com.groupD.server.domain.PreferJob; | ||
import com.groupD.server.domain.entity.Group; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class GroupRequest { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String title; | ||
private String content; | ||
private String manage; | ||
private String date; | ||
@Enumerated(EnumType.STRING) | ||
private PreferJob category; | ||
private String code; | ||
|
||
public GroupRequest(Group group) { | ||
this.id=group.getId(); | ||
this.category=group.getCategory(); | ||
this.code=group.getCode(); | ||
this.date=group.getDate(); | ||
this.manage=group.getManage(); | ||
this.content=group.getContent(); | ||
this.title=group.getTitle(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/groupD/server/domain/dto/GroupResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.groupD.server.domain.dto; | ||
|
||
import com.groupD.server.domain.PreferJob; | ||
import com.groupD.server.domain.entity.Group; | ||
|
||
import javax.persistence.*; | ||
|
||
public class GroupResponse { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String title; | ||
private String content; | ||
private String manage; | ||
private String date; | ||
@Enumerated(EnumType.STRING) | ||
private PreferJob category; | ||
private String code; | ||
|
||
public GroupResponse(Group group) { | ||
this.id=group.getId(); | ||
this.category=group.getCategory(); | ||
this.code=group.getCode(); | ||
this.date=group.getDate(); | ||
this.manage=group.getManage(); | ||
this.content=group.getContent(); | ||
this.title=group.getTitle(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.groupD.server.domain.entity; | ||
|
||
import com.groupD.server.domain.PreferJob; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.NotBlank; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
@Entity | ||
@Table(name = "groups") | ||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Group{ | ||
@Id | ||
@Column(name ="group_id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotBlank | ||
private String title; | ||
@NotBlank | ||
private String content; | ||
@NotBlank | ||
private String manage; | ||
@NotBlank | ||
private String date; | ||
@Enumerated(EnumType.STRING) | ||
private PreferJob category; | ||
@NotBlank | ||
private String code; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/groupD/server/domain/entity/MemberGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.groupD.server.domain.entity; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import javax.persistence.*; | ||
|
||
@Table(name = "member_group") | ||
@Entity | ||
@Getter | ||
@Setter | ||
public class MemberGroup { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "member_group_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "group_id") | ||
private Group group; | ||
|
||
|
||
// Getter, Setter, Constructor | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/groupD/server/repository/GroupRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.groupD.server.repository; | ||
|
||
import com.groupD.server.domain.entity.Group; | ||
import com.groupD.server.domain.entity.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface GroupRepository extends JpaRepository<Group, Long> { | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/groupD/server/repository/MemberGroupRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.groupD.server.repository; | ||
|
||
import com.groupD.server.domain.entity.Member; | ||
import com.groupD.server.domain.entity.MemberGroup; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface MemberGroupRepository extends JpaRepository<MemberGroup, Long> { | ||
public List<MemberGroup> findAllByMember(Member member); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/groupD/server/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
package com.groupD.server.repository; | ||
|
||
import com.groupD.server.domain.dto.GroupRequest; | ||
import com.groupD.server.domain.entity.Group; | ||
import com.groupD.server.domain.entity.Member; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
boolean existsByEmail(String email); | ||
//List<Group> findByEmail(String email); | ||
Optional<Member> findByEmail(String email); | ||
Optional<Member> findById(Long id); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.groupD.server.service; | ||
|
||
import com.groupD.server.domain.dto.GroupRequest; | ||
import com.groupD.server.domain.entity.Group; | ||
import com.groupD.server.repository.GroupRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class GroupService { | ||
private final GroupRepository groupRepository; | ||
public void write(GroupRequest request){ | ||
Group group = Group.builder() | ||
.id(request.getId()) | ||
.code(request.getCode()) | ||
.title(request.getTitle()) | ||
.date(request.getDate()) | ||
.category(request.getCategory()) | ||
.manage(request.getManage()) | ||
.content(request.getContent()) | ||
.build(); | ||
groupRepository.save(group); | ||
} | ||
} |
Oops, something went wrong.