Skip to content

Commit 65c2605

Browse files
authored
Merge pull request #170 from martinP-Ghub/part1-박태식-sprint3
[박태식] sprint3
2 parents 3770f59 + dd37096 commit 65c2605

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1094
-443
lines changed

build.gradle

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
plugins {
22
id 'groovy'
33
id 'checkstyle'
4+
id 'java'
5+
id 'org.springframework.boot' version '3.4.2'
6+
id 'io.spring.dependency-management' version '1.1.7'
47
}
58

69
group 'com.sprint.mission'
710
version '1.0-SNAPSHOT'
811

12+
java {
13+
toolchain {
14+
languageVersion = JavaLanguageVersion.of(17)
15+
}
16+
}
17+
918
repositories {
1019
mavenCentral()
1120
}
1221

1322
dependencies {
14-
implementation 'org.apache.groovy:groovy:4.0.14'
15-
implementation 'org.projectlombok:lombok:1.18.30' // 최신 버전 사용
16-
annotationProcessor 'org.projectlombok:lombok:1.18.30' // Lombok 애노테이션 프로세서 추가
17-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
18-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
19-
// https://mvnrepository.com/artifact/com.google.guava/guava
20-
implementation 'com.google.guava:guava:33.2.1-jre'
21-
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
23+
implementation 'org.springframework.boot:spring-boot-starter-web' // Spring Web 추가
24+
implementation 'org.springframework.boot:spring-boot-starter'
25+
26+
implementation 'org.projectlombok:lombok:1.18.30'
27+
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
28+
annotationProcessor 'org.projectlombok:lombok:1.18.30'
29+
2230
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
31+
32+
implementation 'com.google.guava:guava:33.2.1-jre'
33+
34+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
2335
}
2436

2537
test {

config/channel.ser

-44.3 KB
Binary file not shown.

config/message.ser

-6.51 KB
Binary file not shown.

config/user.ser

-16.7 KB
Binary file not shown.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
#distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

src/main/java/com/sprint/mission/discodeit/DiscodeitApplication.java

+80-299
Large diffs are not rendered by default.

src/main/java/com/sprint/mission/discodeit/_DiscodeitApplication.java

+333
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.sprint.mission.discodeit.domain;
2+
3+
public enum ChannelType {
4+
Private, Public;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.sprint.mission.discodeit.domain;
2+
3+
public enum Mimetype {
4+
User, Message;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import com.sprint.mission.discodeit.domain.ChannelType;
4+
5+
import java.util.List;
6+
import java.util.UUID;
7+
8+
public record ChannelRequest(
9+
String name,
10+
String description,
11+
List<UUID> member,
12+
UUID owner,
13+
ChannelType channelType
14+
) {
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import com.sprint.mission.discodeit.domain.ChannelType;
4+
import com.sprint.mission.discodeit.entity.Channel;
5+
6+
import javax.naming.directory.NoSuchAttributeException;
7+
import java.util.List;
8+
import java.util.UUID;
9+
10+
public record ChannelResponse(
11+
String name,
12+
String description,
13+
List<UUID> member,
14+
UUID owner,
15+
ChannelType channelType
16+
) {
17+
public static ChannelResponse fromEntity(Channel channel){
18+
return new ChannelResponse(
19+
channel.getName(),
20+
channel.getDescription(),
21+
channel.getMember(),
22+
channel.getOwner(),
23+
channel.getChannelType()
24+
);
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import java.util.UUID;
4+
5+
public record MessageRequest(
6+
String content,
7+
UUID senderId,
8+
UUID recipientId,
9+
UUID channelId,
10+
UUID attachedFileId
11+
) {
12+
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import com.sprint.mission.discodeit.entity.Message;
4+
5+
import java.util.UUID;
6+
7+
public record MessageResponse(
8+
String content,
9+
UUID senderId,
10+
UUID recipientId,
11+
UUID channelId
12+
) {
13+
public static MessageResponse fromEntity(Message message){
14+
return new MessageResponse(
15+
message.getContent(),
16+
message.getSenderId(),
17+
message.getRecipientId(),
18+
message.getChannelId()
19+
);
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import com.sprint.mission.discodeit.domain.ChannelType;
4+
5+
import java.util.List;
6+
import java.util.UUID;
7+
8+
public record PrivateChannelRequest(
9+
List<UUID> member,
10+
UUID owner,
11+
ChannelType channelType
12+
) {
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import com.sprint.mission.discodeit.domain.ChannelType;
4+
5+
import java.util.List;
6+
import java.util.UUID;
7+
8+
public record PublicChannelRequest(
9+
String name,
10+
String description,
11+
UUID owner,
12+
ChannelType channelType
13+
) {
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import java.util.UUID;
4+
5+
public record UserRequest(
6+
String username,
7+
String password,
8+
String email,
9+
String phoneNumber,
10+
UUID profileImageId
11+
// String profileImageName
12+
) {
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.sprint.mission.discodeit.dto;
2+
3+
import com.sprint.mission.discodeit.entity.User;
4+
5+
import java.util.UUID;
6+
7+
public record UserResponse(
8+
UUID id,
9+
String username,
10+
String email,
11+
String phoneNumber,
12+
boolean isOnline
13+
) {
14+
public static UserResponse fromEntity(User user, Boolean isOnline) {
15+
return new UserResponse(user.getId(), user.getUsername(), user.getEmail(), user.getPhoneNumber(), isOnline);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
package com.sprint.mission.discodeit.entity;
22

3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.Id;
5+
import lombok.Getter;
6+
37
import java.io.Serializable;
8+
import java.time.Instant;
49
import java.util.UUID;
510

11+
//@Entity
12+
@Getter
613
public abstract class BaseEntity implements Serializable {
714
private static final long serialVersionUID = 1L;
15+
// @Id
816
private UUID id;
9-
private Long createdAt;
10-
private Long updatedAt;
17+
private Instant createdAt;
18+
private Instant updatedAt;
1119

1220
public BaseEntity(){
1321
this.id = id != null ? id : UUID.randomUUID();
1422
// System.out.println("새로 생성된 UUID: " + this.id); // 로그 추가
15-
this.createdAt = System.currentTimeMillis();
23+
this.createdAt = Instant.ofEpochMilli(System.currentTimeMillis());
1624
this.updatedAt = createdAt;
1725
}
1826

19-
public UUID getId(){
20-
return id;
21-
}
22-
23-
public Long getCreatedAt(){
24-
return createdAt;
25-
}
26-
27-
public Long getUpdatedAt(){
28-
return updatedAt;
29-
}
30-
3127
public void update(){
32-
this.updatedAt = System.currentTimeMillis();
28+
this.updatedAt = Instant.ofEpochMilli(System.currentTimeMillis());
3329
}
3430
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.sprint.mission.discodeit.entity;
2+
3+
import com.sprint.mission.discodeit.domain.Mimetype;
4+
import lombok.Getter;
5+
6+
import java.io.Serializable;
7+
import java.time.Instant;
8+
import java.util.UUID;
9+
10+
@Getter
11+
public class BinaryContent implements Serializable {
12+
private static final long getSerialVersionUID = 1L;
13+
private UUID id;
14+
private final Instant createdAt;
15+
private final UUID typeId;
16+
// private final byte[] content;
17+
private final Mimetype mimetype;
18+
19+
public BinaryContent(UUID typeId, Mimetype mimetype) {
20+
this.id = id != null ? id : UUID.randomUUID();
21+
this.createdAt = Instant.ofEpochMilli(System.currentTimeMillis());
22+
this.typeId = typeId;
23+
// this.content = content;
24+
this.mimetype = mimetype;
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
package com.sprint.mission.discodeit.entity;
22

3+
import com.sprint.mission.discodeit.domain.ChannelType;
34
import lombok.Getter;
4-
import lombok.Setter;
55

66
import java.io.Serializable;
77
import java.util.List;
8+
import java.util.UUID;
89

9-
@Getter @Setter
10+
@Getter
1011
public class Channel extends BaseEntity implements Serializable {
1112
private static final long serialVersionUID = 1L;
1213
private String name;
1314
private String description;
14-
private List<User> member;
15-
private User owner;
15+
private List<UUID> member;
16+
private UUID owner;
17+
private ChannelType channelType;
1618

17-
public Channel(String name, String description, List<User> member, User owner){
19+
public Channel(String name, String description, List<UUID> member, UUID owner, ChannelType channelType){
1820
super();
1921
this.name = name;
2022
this.description = description;
2123
this.member = member;
2224
this.owner = owner;
25+
this.channelType = channelType;
26+
}
27+
28+
public void setName(String name){
29+
this.name = name;
30+
}
31+
32+
public void setDescription(String description){
33+
this.description = description;
34+
}
35+
36+
public boolean isPrivate(){
37+
return this.channelType == ChannelType.Private;
2338
}
2439
}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
11
package com.sprint.mission.discodeit.entity;
22

3+
import lombok.AllArgsConstructor;
34
import lombok.Getter;
5+
import lombok.NoArgsConstructor;
46
import lombok.Setter;
57

68
import java.io.Serializable;
9+
import java.util.UUID;
10+
711

812
@Getter @Setter
913
public class Message extends BaseEntity implements Serializable {
1014
private static final long serialVersionUID = 1L;
1115
private String content;
12-
private User sender;
13-
private User recipient;
14-
private Channel channel;
15-
16-
17-
public Message(String content, User sender, Channel channel) {
18-
super();
19-
this.content = content;
20-
this.sender = sender;
21-
this.channel = channel;
22-
}
16+
private UUID senderId;
17+
private UUID recipientId;
18+
private UUID channelId;
19+
private BinaryContent attachedFileId;
2320

24-
public Message(String content, User sender, User recipient) {
21+
public Message(String content, UUID senderId, UUID recipientId, UUID channelId) {
2522
super();
2623
this.content = content;
27-
this.sender = sender;
28-
this.recipient = recipient;
24+
this.senderId = senderId;
25+
this.recipientId = recipientId;
26+
this.channelId = channelId;
2927
}
3028
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.sprint.mission.discodeit.entity;
2+
3+
import lombok.Getter;
4+
5+
import java.io.Serializable;
6+
import java.time.Instant;
7+
8+
@Getter
9+
public class ReadStatus extends BaseEntity implements Serializable {
10+
private static final long serialVersionUID = 1L;
11+
private final String userId;
12+
private final String channelId;
13+
private Instant lastReadAt;
14+
15+
public ReadStatus(String userId, String channelId, Instant lastReadAt) {
16+
super();
17+
this.userId = userId;
18+
this.channelId = channelId;
19+
this.lastReadAt = lastReadAt;
20+
}
21+
22+
public void updateLastRead(Instant timestamp) {
23+
this.lastReadAt = timestamp;
24+
update();
25+
}
26+
}

0 commit comments

Comments
 (0)