Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main branch from current develop branch #21

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/gradle-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Gradle Test

on:
push:
branches: [ main, develop ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Gradle 빌드 캐싱
id: gradle-cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Gradle 테스트
run: ./gradlew test
2 changes: 1 addition & 1 deletion src/main/java/kea/alog/user/domain/team/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Team extends BaseTimeEntity implements Serializable{
private String teamName;

@Setter
@Column(name = "team_image", length = 100)
@Column(name = "team_image", length = 500)
private String teamImage;

@Column(name = "team_leader_pk")
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/kea/alog/user/domain/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class User extends BaseTimeEntity implements Serializable{
@Column(name = "user_pw", length = 100, nullable = false)
private String userPw;

@Setter
@Column(name = "user_nn", length = 10, nullable = false)
private String userNn;

Expand All @@ -44,11 +45,9 @@ public class User extends BaseTimeEntity implements Serializable{
private boolean userDeleted;

@Setter
@Column(name = "user_profile", length = 100)
@Column(name = "user_profile", length = 500)
private String userProfile;

// @Column(name = "user_role", length = 10)
// private String userRole;

@Setter
@Column(name = "is_email_verified", length = 10)
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/kea/alog/user/service/TeamMemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import kea.alog.user.domain.user.UserRepository;
import kea.alog.user.web.dto.TeamMemberDto.AddTeamMemberRequestDto;
import kea.alog.user.web.dto.TeamMemberDto.DeleteTeamMembersRequestDto;
import kea.alog.user.web.dto.TeamMemberDto.GetTeamMembersInfoResponseDto;
import kea.alog.user.web.dto.TeamMemberDto.SaveTeamMembersRequestDto;
import kea.alog.user.web.dto.TeamMemberDto.getTeamMembersResponseDto;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -142,8 +143,44 @@ public getTeamMembersResponseDto getTeamMembers(Long teamPk, Long userPk) {
return getTeamMembersResponseDto.builder()
.teamLeaderNN(teamLeader.getUserNn())
.teamMemberNNs(teamMemberNNs)

.build();

}

@Transactional
public List<GetTeamMembersInfoResponseDto> getTeamMembersInfo(Long teamPk) {
Team team = teamRepository.findByTeamPk(teamPk);
if (team == null) {
log.info("Team is not existed");
return null;
}

List<TeamMember> teamMemberList = teamMemberRepository.findAllByTeam(team);
if (teamMemberList == null) {
log.info("Team member is not existed");
return null;
}

List<GetTeamMembersInfoResponseDto> teamMembersInfo = teamMemberList.stream()
.map(teamMember -> new GetTeamMembersInfoResponseDto(teamMember.getUser().getUserPk(),
teamMember.getUser().getUserNn(),
teamMember.getUser().getUserEmail()))
.collect(Collectors.toList());

User teamLeader = userRepository.findByUserPk(team.getTeamLeaderPk());

teamMembersInfo.add(GetTeamMembersInfoResponseDto.builder()
.userPk(teamLeader.getUserPk())
.userNn(teamLeader.getUserNn())
.userEmail(teamLeader.getUserEmail())
.build());

return teamMembersInfo;




}

}
8 changes: 8 additions & 0 deletions src/main/java/kea/alog/user/service/TeamService.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public String deleteTeam(Long teamPk, Long userPk) {
return "you are not team leader";
}

List<TeamMember> teamMemberList = teamMemberRepository.findAllByTeam(team);
if (teamMemberList != null) {
for (TeamMember teamMember : teamMemberList) {
teamMemberRepository.delete(teamMember);
}
}

teamRepository.delete(team);
return "team deleted successfully";
}
Expand Down Expand Up @@ -141,6 +148,7 @@ public String uploadTeamImage(Long teamPk, Long userPk, String teamImage) {
}

team.setTeamImage(teamImage);
log.info("team : ", team.toString() );
return teamImage;

}
Expand Down
50 changes: 39 additions & 11 deletions src/main/java/kea/alog/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public User signUp(UserDto.RegistRequestDto registRequestDto) {
return null;
}

Email email = emailRepository.findByEmail(registRequestDto.getEmail());
if(email==null){
log.info("try to verify with email");
return null;
}
if (!email.getVerifyCode().equals("VERIFIED")) {
log.info("not verified email");
return null;
}
// Email email = emailRepository.findByEmail(registRequestDto.getEmail());
// if(email==null){
// log.info("try to verify with email");
// return null;
// }
// if (!email.getVerifyCode().equals("VERIFIED")) {
// log.info("not verified email");
// return null;
// }

//회원 가입을 완료한 유저이기 때문에 email테이블의 정보 삭제
emailRepository.delete(email);
// //회원 가입을 완료한 유저이기 때문에 email테이블의 정보 삭제
// emailRepository.delete(email);

//비밀번호 암호화
registRequestDto.setUserPw(passwordEncoder.encode(registRequestDto.getUserPw()));
Expand Down Expand Up @@ -147,4 +147,32 @@ public String uploadProfileImage(Long userPk, String image) {
return image;
}


@Transactional
public String getNtoE(String userNn) {
return userRepository.findByUserNn(userNn).getUserEmail();
}


@Transactional
public Long getNtoP(String userNn) {
return userRepository.findByUserNn(userNn).getUserPk();
}


@Transactional
public String changeNn(Long userPk, String userNn) {
User user = userRepository.findByUserPk(userPk);
if(user==null || user.isUserDeleted()){
return "user not found";
}
//중복 확인 후 변경
if(userRepository.existsByUserNn(userNn)){
return "duplicated nickname";
}
user.setUserNn(userNn);
log.info("change to "+userRepository.findByUserPk(userPk).getUserNn());
return "change to "+userNn;
}

}
6 changes: 4 additions & 2 deletions src/main/java/kea/alog/user/web/TeamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public ResponseEntity<List<Team>> getJoinedTeamList(@RequestParam Long userPk){

@Operation(summary = "팀 이미지 업로드(aggr)", description = "팀 이미지 업로드")
@PostMapping("/image")
public ResponseEntity<String> uploadTeamImage(@RequestParam Long teamPk, @RequestParam Long userPk, @RequestParam String teamImage){
return ResponseEntity.ok(teamService.uploadTeamImage(teamPk, userPk, teamImage));
public ResponseEntity<String> uploadTeamImage(@RequestParam("teamPk") Long teamPk, @RequestParam("userPk") Long userPk, @RequestParam("imgs") String imgs){
return ResponseEntity.ok(teamService.uploadTeamImage(teamPk, userPk, imgs));
}


}
9 changes: 9 additions & 0 deletions src/main/java/kea/alog/user/web/TeamMemberController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package kea.alog.user.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -16,6 +18,7 @@
import kea.alog.user.service.TeamMemberService;
import kea.alog.user.web.dto.TeamMemberDto.AddTeamMemberRequestDto;
import kea.alog.user.web.dto.TeamMemberDto.DeleteTeamMembersRequestDto;
import kea.alog.user.web.dto.TeamMemberDto.GetTeamMembersInfoResponseDto;
import kea.alog.user.web.dto.TeamMemberDto.SaveTeamMembersRequestDto;
import kea.alog.user.web.dto.TeamMemberDto.getTeamMembersResponseDto;

Expand Down Expand Up @@ -50,4 +53,10 @@ public ResponseEntity<getTeamMembersResponseDto> getTeamMembers(@RequestParam Lo
return ResponseEntity.status(HttpStatus.OK).body(teamMemberService.getTeamMembers(teamPk, userPk));
}

@Operation(summary = "팀 멤버 정보")
@GetMapping(value="/info")
public ResponseEntity<List<GetTeamMembersInfoResponseDto>> getMethodName(@RequestParam Long teamPk) {
return ResponseEntity.ok(teamMemberService.getTeamMembersInfo(teamPk));
}

}
21 changes: 19 additions & 2 deletions src/main/java/kea/alog/user/web/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -115,12 +116,28 @@ public ResponseEntity<UserDto.LoginResponseDto> isConfirmedEmail(@RequestParam(v

@Operation(summary = "프로필 이미지 업로드(aggr)", description = "프로필 이미지 업로드")
@PostMapping(path = "/image")
public ResponseEntity<String> uploadProfileImage(@RequestParam(value = "userPk") Long userPk, @RequestParam(value = "image") String image) {
return ResponseEntity.ok(userService.uploadProfileImage(userPk, image));
public ResponseEntity<String> uploadProfileImage(@RequestParam(value = "userPk") Long userPk, @RequestParam(value = "imgs") String imgs) {
return ResponseEntity.ok(userService.uploadProfileImage(userPk, imgs));
}


@Operation(summary = "닉네임으로 이메일 가져오기")
@GetMapping("/ntoe")
public ResponseEntity<String> getNtoE(@RequestParam(value = "userNn") String userNn){
return ResponseEntity.ok(userService.getNtoE(userNn));
}


@Operation(summary = "닉네임으로 pk 가져오기")
@GetMapping("/ntop")
public ResponseEntity<Long> getNtoP(@RequestParam(value = "userNn") String userNn){
return ResponseEntity.ok(userService.getNtoP(userNn));
}

@Operation(summary= "닉네임 변경")
@PatchMapping("/nn")
public ResponseEntity<String> changeNn(@RequestParam(value = "userPk") Long userPk, @RequestParam(value = "userNn") String userNn){
return ResponseEntity.ok(userService.changeNn(userPk, userNn));
}

}
14 changes: 14 additions & 0 deletions src/main/java/kea/alog/user/web/dto/TeamMemberDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,18 @@ public getTeamMembersResponseDto(String teamLeaderNN, List<String> teamMemberNNs
}
}

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public static class GetTeamMembersInfoResponseDto {
private Long userPk;
private String userNn;
private String userEmail;

@Builder
public GetTeamMembersInfoResponseDto(Long userPk, String userNn, String userEmail){
this.userPk = userPk;
this.userNn = userNn;
this.userEmail = userEmail;
}
}
}
18 changes: 9 additions & 9 deletions src/test/java/kea/alog/user/UserApplicationTests.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package kea.alog.user;
// package kea.alog.user;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
// import org.junit.jupiter.api.Test;
// import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class UserApplicationTests {
// @SpringBootTest
// class UserApplicationTests {

@Test
void contextLoads() {
}
// @Test
// void contextLoads() {
// }

}
// }
Loading