-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/IoTeaTime/meong-ha-nyang…
…-server into feature/37-kan-93-token
- Loading branch information
Showing
36 changed files
with
627 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ | |
import jakarta.validation.constraints.Email; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record SendEmailRequest( | ||
public record EmailRequest( | ||
@Valid @Email @NotNull @Schema(description = "이메일", example = "[email protected]") | ||
String email) {} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/org/ioteatime/meonghanyangserver/cctv/domain/CctvEntity.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,24 @@ | ||
package org.ioteatime.meonghanyangserver.cctv.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
import org.ioteatime.meonghanyangserver.group.domain.GroupEntity; | ||
|
||
@Data | ||
@Entity | ||
@Table(name = "cctv") | ||
public class CctvEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "group_id", nullable = false) | ||
private GroupEntity group; | ||
|
||
@Column(nullable = false, length = 20) | ||
private String cctvNickname; | ||
|
||
@Column(nullable = false, length = 100) | ||
private String kvsChannelName; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/org/ioteatime/meonghanyangserver/common/utils/LoginMember.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 org.ioteatime.meonghanyangserver.common.utils; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@AuthenticationPrincipal(expression = "id == null ? 0L : id") | ||
public @interface LoginMember {} |
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 |
---|---|---|
|
@@ -3,6 +3,13 @@ | |
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.info.Contact; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import io.swagger.v3.oas.models.servers.Server; | ||
import java.util.List; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@OpenAPIDefinition( | ||
|
@@ -13,4 +20,48 @@ | |
version = "v1", | ||
contact = @Contact(name = "서유진", email = "[email protected]"))) | ||
@Configuration | ||
public class OpenApiConfig {} | ||
public class OpenApiConfig { | ||
@Bean | ||
public OpenAPI openAPI() { | ||
SecurityScheme apiKey = | ||
new SecurityScheme() | ||
.type(SecurityScheme.Type.APIKEY) | ||
.in(SecurityScheme.In.HEADER) | ||
.name("Authorization"); | ||
|
||
SecurityRequirement securityRequirement = new SecurityRequirement().addList("Bearer Token"); | ||
|
||
Server productionServer = new Server(); | ||
productionServer.setDescription("Production Server"); | ||
productionServer.setUrl("https://my-server-name.com"); | ||
|
||
Server localServer = new Server(); | ||
localServer.setDescription("Local Server"); | ||
localServer.setUrl("http://localhost:8080"); | ||
|
||
return new OpenAPI() | ||
.addSecurityItem(getSecurityRequirement()) | ||
.components(getAuthComponent()) | ||
.servers(List.of(productionServer, localServer)) | ||
.components(new Components().addSecuritySchemes("Bearer Token", apiKey)) | ||
.addSecurityItem(securityRequirement); | ||
} | ||
|
||
private SecurityRequirement getSecurityRequirement() { | ||
String jwt = "JWT"; | ||
return new SecurityRequirement().addList(jwt); | ||
} | ||
|
||
private Components getAuthComponent() { | ||
return new Components() | ||
.addSecuritySchemes( | ||
"JWT", | ||
new SecurityScheme() | ||
.name("JWT") | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT") | ||
.in(SecurityScheme.In.HEADER) | ||
.name("Authorization")); | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/org/ioteatime/meonghanyangserver/group/controller/GroupApi.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,13 @@ | ||
package org.ioteatime.meonghanyangserver.group.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.ioteatime.meonghanyangserver.common.api.Api; | ||
import org.ioteatime.meonghanyangserver.group.dto.response.CreateGroupResponse; | ||
import org.springframework.security.core.Authentication; | ||
|
||
@Tag(name = "Group Api", description = "Group 관련 API 목록입니다.") | ||
public interface GroupApi { | ||
@Operation(summary = "그룹을 생성합니다.") | ||
Api<CreateGroupResponse> createGroup(Authentication authentication); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/ioteatime/meonghanyangserver/group/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,24 @@ | ||
package org.ioteatime.meonghanyangserver.group.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.ioteatime.meonghanyangserver.common.api.Api; | ||
import org.ioteatime.meonghanyangserver.group.dto.response.CreateGroupResponse; | ||
import org.ioteatime.meonghanyangserver.group.service.GroupService; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/group") | ||
public class GroupController implements GroupApi { | ||
private final GroupService groupService; | ||
|
||
@Override | ||
@PostMapping | ||
public Api<CreateGroupResponse> createGroup(Authentication authentication) { | ||
CreateGroupResponse createGroupResponse = groupService.createGroup(authentication); | ||
return Api.OK(createGroupResponse); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/ioteatime/meonghanyangserver/group/domain/GroupEntity.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,35 @@ | ||
package org.ioteatime.meonghanyangserver.group.domain; | ||
|
||
import jakarta.persistence.*; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.ioteatime.meonghanyangserver.cctv.domain.CctvEntity; | ||
import org.ioteatime.meonghanyangserver.video.entity.VideoEntity; | ||
|
||
@Data | ||
@Entity | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Table(name = "`group`") | ||
public class GroupEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false, length = 100) | ||
private String groupName; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime createdAt; | ||
|
||
@OneToMany(mappedBy = "group", cascade = CascadeType.ALL) | ||
private List<CctvEntity> cctvs; | ||
|
||
@OneToMany(mappedBy = "group", cascade = CascadeType.ALL) | ||
private List<VideoEntity> videos; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/ioteatime/meonghanyangserver/group/domain/GroupUserEntity.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,33 @@ | ||
package org.ioteatime.meonghanyangserver.group.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.ioteatime.meonghanyangserver.group.domain.enums.GroupUserRole; | ||
import org.ioteatime.meonghanyangserver.user.domain.UserEntity; | ||
|
||
@Data | ||
@Entity | ||
@Table(name = "group_user") | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class GroupUserEntity { | ||
@EmbeddedId private GroupUserId id; | ||
|
||
@Column(nullable = false, length = 10) | ||
@Enumerated(value = EnumType.STRING) | ||
private GroupUserRole role; | ||
|
||
@ManyToOne | ||
@MapsId("groupId") | ||
@JoinColumn(name = "group_id") | ||
private GroupEntity group; | ||
|
||
@ManyToOne | ||
@MapsId("userId") | ||
@JoinColumn(name = "user_id", unique = true) | ||
private UserEntity user; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/org/ioteatime/meonghanyangserver/group/domain/GroupUserId.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,16 @@ | ||
package org.ioteatime.meonghanyangserver.group.domain; | ||
|
||
import jakarta.persistence.Embeddable; | ||
import java.io.Serializable; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Embeddable | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class GroupUserId implements Serializable { | ||
private Long groupId; | ||
private Long userId; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/org/ioteatime/meonghanyangserver/group/domain/enums/GroupUserRole.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,11 @@ | ||
package org.ioteatime.meonghanyangserver.group.domain.enums; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
public enum GroupUserRole { | ||
ROLE_USER("USER"), | ||
ROLE_MASTER("MASTER"); | ||
|
||
private final String description; | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/org/ioteatime/meonghanyangserver/group/dto/response/CreateGroupResponse.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,5 @@ | ||
package org.ioteatime.meonghanyangserver.group.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record CreateGroupResponse(Long groupId, String groupName, LocalDateTime createdAt) {} |
10 changes: 10 additions & 0 deletions
10
src/main/java/org/ioteatime/meonghanyangserver/group/mapper/group/GroupEntityMapper.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,10 @@ | ||
package org.ioteatime.meonghanyangserver.group.mapper.group; | ||
|
||
import java.time.LocalDateTime; | ||
import org.ioteatime.meonghanyangserver.group.domain.GroupEntity; | ||
|
||
public class GroupEntityMapper { | ||
public static GroupEntity toEntity(String groupName) { | ||
return GroupEntity.builder().groupName(groupName).createdAt(LocalDateTime.now()).build(); | ||
} | ||
} |
Oops, something went wrong.