diff --git a/.github/workflows/auto-deployment.yml b/.github/workflows/auto-deployment.yml new file mode 100644 index 0000000..f61f45b --- /dev/null +++ b/.github/workflows/auto-deployment.yml @@ -0,0 +1,80 @@ +name: AWS EC2 자동 배포 + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + env: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USERNAME }} + + steps: + - uses: actions/checkout@v4.1.2 + + - name: Show git status + run: git status + + - name: Setup Java JDK + uses: actions/setup-java@v4.2.1 + with: + java-version: 17 + distribution: temurin + java-package: jdk + architecture: x64 + cache: gradle + + - name: Build Jar + run: | + chmod 755 gradlew + ./gradlew bootJar + working-directory: JWT + + - name: Prepare SSH connect + env: + private_key: ${{ secrets.EC2_PRIVATE_KEY }} + run: | + echo "$private_key" > private_key.pem + chmod 400 private_key.pem + mkdir ~/.ssh + ssh-keyscan -t rsa $host > ~/.ssh/known_hosts + working-directory: JWT + + - name: Upload deployment scripts + run: | + scp -i private_key.pem -r deploy "${username}@${host}:~" + working-directory: JWT + + - name: Kill current running Spring process + uses: fifsky/ssh-action@v0.0.6 + with: + command: | + sudo chmod 755 deploy/* + deploy/shutdown.sh + deploy/backup.sh + host: ${{ secrets.EC2_HOST }} + user: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_PRIVATE_KEY }} + + - name: Send jar file to EC2 + run: | + jarPath=$(./gradlew -q jarPath) + scp -i private_key.pem $jarPath "${username}@${host}:~/server.jar" + working-directory: JWT + + - name: Run new uploaded jar + uses: fifsky/ssh-action@v0.0.6 + with: + command: | + sudo chmod 755 deploy/* + deploy/startup.sh + host: ${{ secrets.EC2_HOST }} + user: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_PRIVATE_KEY }} diff --git a/.idea/modules.xml b/.idea/modules.xml index 7e7eefc..e21ecee 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + \ No newline at end of file diff --git a/.idea/modules/JWTLogIn.JWT.main.iml b/.idea/modules/JWTLogIn.JWT.main.iml new file mode 100644 index 0000000..e52f99e --- /dev/null +++ b/.idea/modules/JWTLogIn.JWT.main.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/JWT/build.gradle b/JWT/build.gradle index 3458ea1..48ed3f8 100644 --- a/JWT/build.gradle +++ b/JWT/build.gradle @@ -41,6 +41,13 @@ dependencies { implementation 'io.jsonwebtoken:jjwt-impl:0.11.2' implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2' + // Swagger + implementation 'io.springfox:springfox-boot-starter:3.0.0' + implementation 'io.springfox:springfox-swagger-ui:3.0.0' +// implementation 'io.springfox:springfox-swagger2:2.9.2' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' + + // // Spring Security testImplementation 'org.springframework.security:spring-security-test' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/config/SecurityConfig.java b/JWT/src/main/java/JWTLogIn/JWT/user/config/SecurityConfig.java index 955d037..369c9b5 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/config/SecurityConfig.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/config/SecurityConfig.java @@ -3,11 +3,14 @@ import JWTLogIn.JWT.user.security.JwtFilter; import JWTLogIn.JWT.user.service.UserService; import lombok.RequiredArgsConstructor; +import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.security.servlet.PathRequest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -17,6 +20,7 @@ @Configuration @EnableWebSecurity // request를 filterchain에서 가로채도록 하는 장치 @RequiredArgsConstructor +@Log4j2 public class SecurityConfig { private final UserService userService; @@ -24,6 +28,37 @@ public class SecurityConfig { @Value("${jwt.secret}") private String secretKey; + private static final String[] PERMIT_URL_ARRAY = { + /* swagger v2 */ + "/v2/api-docs", + "/swagger-resources", + "/swagger-resources/**", + "/configuration/ui", + "/configuration/security", + "/swagger-ui.html", + "/webjars/**", + /* swagger v3 */ + "/v3/api-docs/**", + "/swagger-ui/**", + "/swagger-ui/swagger-ui-standalone-preset.js", + "/swagger-ui/swagger-initializer.js", + "/swagger-ui/swagger-ui-bundle.js", + "/swagger-ui/swagger-ui.css", + "/swagger-ui/index.css", + "/swagger-ui/favicon-32x32.png", + "/swagger-ui/favicon-16x16.png", + "/api-docs/json/swagger-config", + "/api-docs/json" + }; + + @Bean + public WebSecurityCustomizer webSecurityCustomizer() { + log.info("WebSecurity......................"); + + return web -> web.ignoring() + .requestMatchers(PathRequest.toStaticResources().atCommonLocations()); + } + @Bean // 요청이 들어오면 SecurityFilterChain이 가로채서 인증, 인가를 체크함. public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { @@ -31,12 +66,19 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .httpBasic(AbstractHttpConfigurer::disable) .csrf(AbstractHttpConfigurer::disable) // 토큰 사용하기에 csrf 불가능 .cors(AbstractHttpConfigurer::disable) - .authorizeHttpRequests(request -> { - request.requestMatchers("/tgwing.kr", "/tgwing.kr/register", "/tgwing.kr/login").permitAll(); - // 3개의 url에서는 token인증없이 접근 가능. - request.anyRequest().authenticated(); - // 그 외의 url에서는 token인증없이 접근 불가능. - }) + .authorizeHttpRequests(request -> request + .requestMatchers("/tgwing.kr", "/tgwing.kr/register", "/tgwing.kr/login") + .permitAll() + .requestMatchers(PERMIT_URL_ARRAY) + .permitAll() + .anyRequest().authenticated() + ) +// .formLogin((form) -> form +// .loginPage("/tgwing.kr/login") +// .permitAll() +// ) +// .logout((logout) -> logout +// .clearAuthentication(true)) .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) // jwt를 사용하기 때문에 session을 사용하지 않음. .addFilterBefore(new JwtFilter(userService, secretKey), UsernamePasswordAuthenticationFilter.class) diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/controller/AdminController.java b/JWT/src/main/java/JWTLogIn/JWT/user/controller/AdminController.java index 1f45488..1d3a41a 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/controller/AdminController.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/controller/AdminController.java @@ -15,6 +15,7 @@ import java.util.List; @RestController +@RequestMapping("/tgwing.kr") @RequiredArgsConstructor public class AdminController { @@ -22,23 +23,27 @@ public class AdminController { private final AuthService authService; @GetMapping("/info/user") - public ResponseEntity> userAll(Authentication authentication) { + public ResponseEntity> userAll(Authentication authentication, @RequestHeader("authorization") String token) { List userAll = userService.findUserAll(); + String jwt = token.split(" ")[1]; + String studentId = authService.extractStudentId(jwt); if(userAll == null) return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); + System.out.println("studentId = " + studentId); + return ResponseEntity.ok(userAll); } @GetMapping("/userlist") public ResponseEntity> userPage(Pageable pageable, @RequestHeader("authorization") String token) { String jwt = token.split(" ")[1]; - Level level = authService.extractLevel(jwt); - - if(!level.equals(Level.MANAGER)) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } +// Level level = authService.extractLevel(jwt); +// +// if(!level.equals(Level.MANAGER)) { +// return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); +// } Page userAllByPage = userService.findUserAllByPage(pageable); @@ -48,11 +53,11 @@ public ResponseEntity> userPage(Pageable pageable, @RequestHeader( @PutMapping("/userlist/put/manager/{userId}") public ResponseEntity changeAdmin(@PathVariable Long userId, @RequestHeader("authorization") String token) { String jwt = token.split(" ")[1]; - Level level = authService.extractLevel(jwt); - - if(!level.equals(Level.MANAGER)) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } +// Level level = authService.extractLevel(jwt); +// +// if(!level.equals(Level.MANAGER)) { +// return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); +// } userService.changeLevel(userId, Level.MANAGER); @@ -62,11 +67,11 @@ public ResponseEntity changeAdmin(@PathVariable Long userId, @RequestHeade @PutMapping("/userlist/put/member/{userId}") public ResponseEntity changeMember(@PathVariable Long userId, @RequestHeader("authorization") String token) { String jwt = token.split(" ")[1]; - Level level = authService.extractLevel(jwt); - - if(!level.equals(Level.MANAGER)) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } +// Level level = authService.extractLevel(jwt); +// +// if(!level.equals(Level.MANAGER)) { +// return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); +// } userService.changeLevel(userId, Level.MEMBER); @@ -76,11 +81,11 @@ public ResponseEntity changeMember(@PathVariable Long userId, @RequestHead @PutMapping("/userlist/put/normal/{userId}") public ResponseEntity changeNormal(@PathVariable Long userId, @RequestHeader("authorization") String token) { String jwt = token.split(" ")[1]; - Level level = authService.extractLevel(jwt); - - if(!level.equals(Level.MANAGER)) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } +// Level level = authService.extractLevel(jwt); +// +// if(!level.equals(Level.MANAGER)) { +// return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); +// } userService.changeLevel(userId, Level.NORMAL); diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/controller/UserController.java b/JWT/src/main/java/JWTLogIn/JWT/user/controller/UserController.java index 545e7a8..e69671d 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/controller/UserController.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/controller/UserController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*; @RestController +@RequestMapping("/tgwing.kr") @RequiredArgsConstructor public class UserController { @@ -50,7 +51,7 @@ public ResponseEntity logout() { @DeleteMapping("/profile/delete/{id}") public ResponseEntity deleteId(@PathVariable Long id) { - if(userService.withdrawalUser(id)) { + if(userService.deleteUser(id)) { System.out.println("회원 삭제 완료"); return ResponseEntity.ok().build(); } diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/dto/UserDTO.java b/JWT/src/main/java/JWTLogIn/JWT/user/dto/UserDTO.java index ac64db2..b81e7d2 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/dto/UserDTO.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/dto/UserDTO.java @@ -19,7 +19,7 @@ public class UserDTO { private Status status; // 재학/휴학 상태 private String semester; // 학년, 학기(3글자로 설정) private String phoneNumber; // 전화번호(13글자로 설정) - private Level level;// 일반, 동아리, 관리인 3가지 분류 +// private Level level;// 일반, 동아리, 관리인 3가지 분류 public static UserEntity toUserEntity(UserDTO userDTO) { @@ -33,7 +33,7 @@ public static UserEntity toUserEntity(UserDTO userDTO) { .status(userDTO.getStatus()) .semester(userDTO.getSemester()) .phoneNumber(userDTO.getPhoneNumber()) - .level(userDTO.getLevel()) +// .level(userDTO.getLevel()) .build(); } } diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/entity/UserEntity.java b/JWT/src/main/java/JWTLogIn/JWT/user/entity/UserEntity.java index fe9c980..d30bb45 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/entity/UserEntity.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/entity/UserEntity.java @@ -3,6 +3,7 @@ import JWTLogIn.JWT.user.dto.UserDTO; import JWTLogIn.JWT.user.entity.Enum.Level; import JWTLogIn.JWT.user.entity.Enum.Status; +import com.fasterxml.jackson.annotation.JsonValue; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.DynamicInsert; @@ -40,8 +41,8 @@ public class UserEntity extends BaseEntity{ @Column(nullable = false, unique = true, length = 13) private String phoneNumber; // 전화번호(13글자로 설정) - @Column(length = 7) - private Level level; +// @Column(length = 7) +// private Level level; // 연관매핑: 일대다 // 참조 당하는 엔티티에서 사용 @@ -60,7 +61,7 @@ public static UserDTO toUserDTO(UserEntity userEntity) { .status(userEntity.getStatus()) .semester(userEntity.getSemester()) .phoneNumber(userEntity.getPhoneNumber()) - .level(userEntity.getLevel()) +// .level(userEntity.getLevel()) .build(); } diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/repository/UserRepository.java b/JWT/src/main/java/JWTLogIn/JWT/user/repository/UserRepository.java index 0611784..4ae2ee5 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/repository/UserRepository.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/repository/UserRepository.java @@ -22,12 +22,12 @@ public interface UserRepository extends JpaRepository { @Query("DELETE FROM UserEntity U WHERE U.id = :id") void deleteUser(@Param("id") Long id); - @Modifying - @Transactional - @Query("UPDATE UserEntity u SET " + - "u.level = :level " + - "WHERE u.id = :id") - void changeLv (@Param("id") Long id, @Param("level") Level level); +// @Modifying +// @Transactional +// @Query("UPDATE UserEntity u SET " + +// "u.level = :level " + +// "WHERE u.id = :id") +// void changeLv (@Param("id") Long id, @Param("level") Level level); // @Query("UPDATE BoardEntity b SET " + diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtFilter.java b/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtFilter.java index 439a526..b6d22de 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtFilter.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtFilter.java @@ -16,6 +16,7 @@ import org.springframework.web.filter.OncePerRequestFilter; import java.io.IOException; +import java.util.Arrays; import java.util.List; @RequiredArgsConstructor @@ -25,54 +26,71 @@ public class JwtFilter extends OncePerRequestFilter { private final UserService userService; private final String secretKey; + @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { final String authorization = request.getHeader(HttpHeaders.AUTHORIZATION); - log.info("Authorization : {}", authorization); - // slf4j에서 log를 찍어서 확인함. - if(authorization.isEmpty() || !authorization.startsWith("Bearer ")) { - log.error("권한이 없음."); + log.info("doFilterChain....................."); - filterChain.doFilter(request, response); - return; - } - // authentication이 없을 경우, token이 없을 경우, 혹은 "Bearer "로 시작하지 않으면 block함. - // 이 때 header의 authorization의 부분에서 어떤 입력이라도 있으면 200이 됨. + if(authorization != null && !authorization.isEmpty()) { + log.info("Authorization : {}", authorization); + // slf4j에서 log를 찍어서 확인함. + if(authorization.isEmpty() || !authorization.startsWith("Bearer ")) { + log.error("권한이 없음."); + filterChain.doFilter(request, response); + return; + } + // authentication이 없을 경우, token이 없을 경우, 혹은 "Bearer "로 시작하지 않으면 block함. + // 이 때 header의 authorization의 부분에서 어떤 입력이라도 있으면 200이 됨. - String token = authorization.split(" ")[1]; - // 토큰 꺼내기 - // authorization의 첫번째 부분이 토큰이다. - // 띄워쓰기를 쪼개는 방식으로 가져갈 때, Bearer다음의 부분이 토큰이다. - // 토큰 유효기간 확인 - if(JwtUtil.isExpired(token, secretKey)) { - log.error("토큰이 만료됨."); - filterChain.doFilter(request, response); - return; - } + String token = authorization.split(" ")[1]; + // 토큰 꺼내기 + // authorization의 첫번째 부분이 토큰이다. + // 띄워쓰기를 쪼개는 방식으로 가져갈 때, Bearer다음의 부분이 토큰이다. + + // 토큰 유효기간 확인 + if(JwtUtil.isExpired(token, secretKey)) { + log.error("토큰이 만료됨."); + filterChain.doFilter(request, response); + + return; + } - //Username Token에서 꺼내기 - //이를 통해 아래 UsernamePasswordAuthenticationToken에서 userName을 사용가능함. - String name = JwtUtil.getUserName(token, secretKey); - Level level = JwtUtil.getLevel(token, secretKey); - log.info("name : {}", name); - log.info("level : {}", level); + //Username Token에서 꺼내기 + //이를 통해 아래 UsernamePasswordAuthenticationToken에서 userName을 사용가능함. + String name = JwtUtil.getUserName(token, secretKey); +// Level level = JwtUtil.getLevel(token, secretKey); + String studentId = JwtUtil.getStudentId(token, secretKey); - // 권한 부여 - UsernamePasswordAuthenticationToken authenticationToken = - new UsernamePasswordAuthenticationToken(name, null, - List.of(new SimpleGrantedAuthority("name"))); - // Detail을 넣어줌 - authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); - authenticationToken.setDetails(level); - SecurityContextHolder.getContext().setAuthentication(authenticationToken); - filterChain.doFilter(request, response); + log.info("name : {}", name); + log.info("studentId : {}", studentId); + +// log.info("level : {}", level); + + // 권한 부여 + UsernamePasswordAuthenticationToken authenticationToken = + new UsernamePasswordAuthenticationToken(name, null, + List.of(new SimpleGrantedAuthority("name"))); + // Detail을 넣어줌 + authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); +// authenticationToken.setDetails(level); + SecurityContextHolder.getContext().setAuthentication(authenticationToken); + filterChain.doFilter(request, response); + } + + else { + log.info("authorization null......"); +// if(Arrays.stream(PERMIT_URL_ARRAY).anyMatch(req -> request.getRequestURI().equals(req))) { + filterChain.doFilter(request, response); + + } }// 관문. 이곳을 통과해서 지나감. }// 권한을 부여해줌. 본래 authenticate를 통과해야하는 상태를 통과하게 해줌. diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtUtil.java b/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtUtil.java index 7e48dfa..58c70a3 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtUtil.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/security/JwtUtil.java @@ -20,12 +20,17 @@ public static String getUserName(String token, String secretKey) { .getBody().get("name", String.class); } // userName 꺼내오기. - public static Level getLevel(String token, String secretKey) { + public static String getStudentId(String token, String secretKey) { return Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token) - .getBody().get("level", Level.class); - } // level 꺼내오기 + .getBody().get("studentId", String.class); + } - public static String createJwt(String name, String studentId, Level level, String secretKey) { +// public static Level getLevel(String token, String secretKey) { +// return Jwts.parserBuilder().setSigningKey(secretKey).build().parseClaimsJws(token) +// .getBody().get("level", Level.class); +// } // level 꺼내오기 + + public static String createJwt(String name, String studentId, /*Level level,*/ String secretKey) { // name : token에 들어있는 것으로 사용함 // secretKey : 서명 @@ -34,7 +39,7 @@ public static String createJwt(String name, String studentId, Level level, Strin claims.put("name", name); claims.put("studentId", studentId); - claims.put("level", level); +// claims.put("level", level); Long expiredMs = 1000 * 60 * 60l; diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/service/AuthService.java b/JWT/src/main/java/JWTLogIn/JWT/user/service/AuthService.java index 0524e42..d96f98b 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/service/AuthService.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/service/AuthService.java @@ -12,7 +12,12 @@ public class AuthService { @Value("${jwt.secret}") private String secretKey; - public Level extractLevel(String token) { - return JwtUtil.getLevel(token, secretKey); +// public Level extractLevel(String token) { +// return JwtUtil.getLevel(token, secretKey); +// } + + public String extractStudentId(String token) { + return JwtUtil.getStudentId(token, secretKey); } + } diff --git a/JWT/src/main/java/JWTLogIn/JWT/user/service/UserService.java b/JWT/src/main/java/JWTLogIn/JWT/user/service/UserService.java index c4e5df3..3aa91de 100644 --- a/JWT/src/main/java/JWTLogIn/JWT/user/service/UserService.java +++ b/JWT/src/main/java/JWTLogIn/JWT/user/service/UserService.java @@ -23,6 +23,7 @@ public class UserService { @Value("${jwt.secret}") private String secretKey; + private final UserRepository userRepository; public void userSave(UserDTO userDTO) throws Exception { @@ -30,7 +31,7 @@ public void userSave(UserDTO userDTO) throws Exception { if(studentId.isPresent()) throw new Exception("This studentId already exist."); - userDTO.setLevel(Level.MANAGER); +// userDTO.setLevel(Level.MANAGER); BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); UserEntity userEntity = UserDTO.toUserEntity(userDTO); @@ -48,7 +49,7 @@ public String login(LogInDTO logInDTO){ if(userEntity.isPresent()) { // 학번을 통해 찾은 user의 정보가 존재한다면 if(user.checkPassword(logInDTO.getPassword(), bCryptPasswordEncoder)) { - return JwtUtil.createJwt(user.getName(), user.getStudentId(), user.getLevel(), secretKey); + return JwtUtil.createJwt(user.getName(), user.getStudentId(), /*user.getLevel()*/ secretKey); } else { // password 일치하지 않을 경우 return null; @@ -60,7 +61,7 @@ public String login(LogInDTO logInDTO){ }// login. null일 경우 회원정보 불일치함. 아닐 경우, 회원정보 일치. 회원 정보 return. - public Boolean withdrawalUser(Long id) { + public Boolean deleteUser(Long id) { Optional find = userRepository.findById(id); if(find != null) { // 회원이 있으면 null이 아님. 이를 삭제하고 true보내서 삭제 완료를 보냄. userRepository.deleteUser(id); @@ -105,7 +106,7 @@ public Page findUserAllByPage(Pageable request) { public void changeLevel(Long id, Level level) { Optional user = userRepository.findById(id); if(user.isPresent()) { - userRepository.changeLv(user.get().getId(), level); +// userRepository.changeLv(user.get().getId(), level); } } // 회원의 level 변경 diff --git a/JWT/src/main/resources/application.properties b/JWT/src/main/resources/application.properties index 4a6059a..5f5c67a 100644 --- a/JWT/src/main/resources/application.properties +++ b/JWT/src/main/resources/application.properties @@ -11,7 +11,7 @@ spring.datasource.password=tgwing2024 spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.show-sql=true -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=update spring.jpa.open-in-view=false spring.jpa.generate-ddl=true spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect