Skip to content

Commit e6de4d0

Browse files
committed
mission2 update
1 parent e6625ec commit e6de4d0

24 files changed

Lines changed: 920 additions & 452 deletions

config/channel.ser

44.3 KB
Binary file not shown.

config/message.ser

6.51 KB
Binary file not shown.

config/user.ser

18.7 KB
Binary file not shown.

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

Lines changed: 224 additions & 176 deletions
Large diffs are not rendered by default.

src/main/java/com/sprint/mission/discodeit/entity/BaseEntity.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package com.sprint.mission.discodeit.entity;
22

3+
import java.io.Serializable;
34
import java.util.UUID;
45

5-
public abstract class BaseEntity {
6-
private transient UUID id;
6+
public abstract class BaseEntity implements Serializable {
7+
private static final long serialVersionUID = 1L;
8+
private UUID id;
79
private Long createdAt;
810
private Long updatedAt;
911

1012
public BaseEntity(){
11-
this.id = UUID.randomUUID();
12-
System.out.println("새로 생성된 UUID: " + this.id); // 로그 추가
13+
this.id = id != null ? id : UUID.randomUUID();
14+
// System.out.println("새로 생성된 UUID: " + this.id); // 로그 추가
1315
this.createdAt = System.currentTimeMillis();
1416
this.updatedAt = createdAt;
1517
}

src/main/java/com/sprint/mission/discodeit/entity/Channel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import lombok.Getter;
44
import lombok.Setter;
55

6+
import java.io.Serializable;
67
import java.util.List;
78

89
@Getter @Setter
9-
public class Channel extends BaseEntity{
10+
public class Channel extends BaseEntity implements Serializable {
11+
private static final long serialVersionUID = 1L;
1012
private String name;
1113
private String description;
1214
private List<User> member;

src/main/java/com/sprint/mission/discodeit/entity/Message.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
import lombok.Getter;
44
import lombok.Setter;
55

6+
import java.io.Serializable;
7+
68
@Getter @Setter
7-
public class Message extends BaseEntity{
9+
public class Message extends BaseEntity implements Serializable {
10+
private static final long serialVersionUID = 1L;
811
private String content;
912
private User sender;
1013
private User recipient;
Lines changed: 109 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,109 @@
1-
package com.sprint.mission.discodeit.jcf;
2-
3-
import com.sprint.mission.discodeit.entity.Channel;
4-
import com.sprint.mission.discodeit.entity.User;
5-
import com.sprint.mission.discodeit.exception.DataNotFoundException;
6-
import com.sprint.mission.discodeit.exception.IdNotFoundException;
7-
import com.sprint.mission.discodeit.service.ChannelService;
8-
import groovyjarjarasm.asm.tree.TryCatchBlockNode;
9-
10-
import java.util.*;
11-
12-
public class JCFChannelService implements ChannelService {
13-
private final Map<UUID, Channel> data;
14-
15-
public JCFChannelService(){
16-
this.data = new HashMap<>();
17-
}
18-
19-
@Override
20-
public Channel create(Channel channel) {
21-
data.put(channel.getId(), channel);
22-
System.out.println(channel.getName() + " 채널이 오픈되었습니다.");
23-
return channel;
24-
}
25-
26-
@Override
27-
public Channel readOne(UUID id) {
28-
return data.get(id);
29-
}
30-
31-
@Override
32-
public List<Channel> readAll() {
33-
data.values().forEach(channel -> {
34-
System.out.println(channel.getName());
35-
});
36-
37-
return new ArrayList<>(data.values());
38-
}
39-
40-
@Override
41-
public Channel update(UUID id, Channel updatedChannel) {
42-
try{
43-
if(data.containsKey(id)){
44-
Channel existingChannel = data.get(id);
45-
existingChannel.setName(updatedChannel.getName());
46-
existingChannel.setDescription(updatedChannel.getDescription());
47-
updatedChannel.update();
48-
return existingChannel;
49-
}
50-
}catch (DataNotFoundException e){
51-
throw new DataNotFoundException("채널을 찾을 수 없습니다." + e);
52-
}
53-
return null;
54-
}
55-
56-
@Override
57-
public void channelOwnerChange(UUID id, User owner){
58-
try {
59-
if(data.containsKey(id)){
60-
Channel existingChannel = data.get(id);
61-
User existingOwnerName = existingChannel.getOwner();
62-
existingChannel.setOwner(owner);
63-
existingChannel.update();
64-
System.out.println("채널 주인이 " + existingOwnerName.getUsername() + "님에서 " + owner.getUsername() + "님으로 변경되었습니다.");
65-
}
66-
}catch (DataNotFoundException e){
67-
throw new DataNotFoundException("채널을 찾을 수 없습니다." + e);
68-
}
69-
}
70-
71-
@Override
72-
public boolean delete(UUID id) {
73-
try{
74-
String removename = data.get(id).getName();
75-
data.remove(id);
76-
System.out.println(removename +" 삭제가 완료되었습니다.");
77-
return true;
78-
} catch (NullPointerException e){
79-
System.out.println("유효하지 않은 ID 입니다..\n" + e);
80-
}
81-
return false;
82-
}
83-
84-
@Override
85-
public void channelMemberJoin(UUID id, User joinUser){
86-
try {
87-
if (data.containsKey(id)) {
88-
Channel joinChannel = data.get(id);
89-
90-
List<User> members = new ArrayList<>(joinChannel.getMember());
91-
if (!members.contains(joinUser)) {
92-
members.add(joinUser);
93-
System.out.println(joinChannel.getName() + " 채널에 " + joinUser.getUsername() + "님이 등록되었습니다.");
94-
} else {
95-
System.out.println("User is already a member.");
96-
}
97-
joinChannel.setMember(members);
98-
}
99-
}catch (DataNotFoundException e){
100-
throw new DataNotFoundException("채널을 찾을 수 없습니다.");
101-
}
102-
}
103-
104-
@Override
105-
public void channelMemberWithdrawal(UUID id, User withdrawalUser){
106-
107-
}
108-
109-
}
1+
//package com.sprint.mission.discodeit.jcf;
2+
//
3+
//import com.sprint.mission.discodeit.entity.Channel;
4+
//import com.sprint.mission.discodeit.entity.User;
5+
//import com.sprint.mission.discodeit.exception.DataNotFoundException;
6+
//import com.sprint.mission.discodeit.exception.IdNotFoundException;
7+
//import com.sprint.mission.discodeit.service.ChannelService;
8+
//import groovyjarjarasm.asm.tree.TryCatchBlockNode;
9+
//
10+
//import java.util.*;
11+
//
12+
//public class JCFChannelService implements ChannelService {
13+
// private final Map<UUID, Channel> data;
14+
//
15+
// public JCFChannelService(){
16+
// this.data = new HashMap<>();
17+
// }
18+
//
19+
// @Override
20+
// public Channel create(Channel channel) {
21+
// data.put(channel.getId(), channel);
22+
// System.out.println(channel.getName() + " 채널이 오픈되었습니다.");
23+
// return channel;
24+
// }
25+
//
26+
// @Override
27+
// public Channel readOne(UUID id) {
28+
// return data.get(id);
29+
// }
30+
//
31+
// @Override
32+
// public List<Channel> readAll() {
33+
// data.values().forEach(channel -> {
34+
// System.out.println(channel.getName());
35+
// });
36+
//
37+
// return new ArrayList<>(data.values());
38+
// }
39+
//
40+
// @Override
41+
// public Channel update(UUID id, Channel updatedChannel) {
42+
// try{
43+
// if(data.containsKey(id)){
44+
// Channel existingChannel = data.get(id);
45+
// existingChannel.setName(updatedChannel.getName());
46+
// existingChannel.setDescription(updatedChannel.getDescription());
47+
// updatedChannel.update();
48+
// return existingChannel;
49+
// }
50+
// }catch (DataNotFoundException e){
51+
// throw new DataNotFoundException("채널을 찾을 수 없습니다." + e);
52+
// }
53+
// return null;
54+
// }
55+
//
56+
// @Override
57+
// public void channelOwnerChange(UUID id, User owner){
58+
// try {
59+
// if(data.containsKey(id)){
60+
// Channel existingChannel = data.get(id);
61+
// User existingOwnerName = existingChannel.getOwner();
62+
// existingChannel.setOwner(owner);
63+
// existingChannel.update();
64+
// System.out.println("채널 주인이 " + existingOwnerName.getUsername() + "님에서 " + owner.getUsername() + "님으로 변경되었습니다.");
65+
// }
66+
// }catch (DataNotFoundException e){
67+
// throw new DataNotFoundException("채널을 찾을 수 없습니다." + e);
68+
// }
69+
// }
70+
//
71+
// @Override
72+
// public boolean delete(UUID id) {
73+
// try{
74+
// String removename = data.get(id).getName();
75+
// data.remove(id);
76+
// System.out.println(removename +" 삭제가 완료되었습니다.");
77+
// return true;
78+
// } catch (NullPointerException e){
79+
// System.out.println("유효하지 않은 ID 입니다..\n" + e);
80+
// }
81+
// return false;
82+
// }
83+
//
84+
// @Override
85+
// public void channelMemberJoin(UUID id, User joinUser){
86+
// try {
87+
// if (data.containsKey(id)) {
88+
// Channel joinChannel = data.get(id);
89+
//
90+
// List<User> members = new ArrayList<>(joinChannel.getMember());
91+
// if (!members.contains(joinUser)) {
92+
// members.add(joinUser);
93+
// System.out.println(joinChannel.getName() + " 채널에 " + joinUser.getUsername() + "님이 등록되었습니다.");
94+
// } else {
95+
// System.out.println("User is already a member.");
96+
// }
97+
// joinChannel.setMember(members);
98+
// }
99+
// }catch (DataNotFoundException e){
100+
// throw new DataNotFoundException("채널을 찾을 수 없습니다.");
101+
// }
102+
// }
103+
//
104+
// @Override
105+
// public void channelMemberWithdrawal(UUID id, User withdrawalUser){
106+
//
107+
// }
108+
//
109+
//}

0 commit comments

Comments
 (0)