Skip to content

Commit

Permalink
1.0 patch 22 add msg type
Browse files Browse the repository at this point in the history
  • Loading branch information
MuuuShin committed Dec 3, 2023
1 parent 388b533 commit f1fab64
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Result<String> login(@RequestBody Map<String, Object> jsonMap) {
if (isTeacher) {
Teacher result = loginService.loginTeacher(username, password);
if (result == null) {
log.info(username + "Invalid username or password");
log.info(username + " Invalid username or password");
return Result.error("Invalid username or password");
}
Map<String, Object> claims = new HashMap<>();
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/cse/ooad/project/model/Msg.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* 属性列表:
* <ul>
* <li>msgId: 消息的唯一标识。</li>
* <li>type: 消息的类型。枚举类参见{@link cse.ooad.project.utils.MessageType}</li>
* <li>srcId: 消息发送者的标识。如果为0则为系统消息(System)</li>
* <li>dstId: 消息接收者的标识。</li>
* <li>body: 消息内容。</li>
Expand All @@ -26,12 +27,15 @@
@NoArgsConstructor
@Entity
@Table(name = "msgs", schema = "public", catalog = "cs309a")
public class Msg {
public class Msg {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "msg_id")
private Long msgId;
@Basic
@Column(name = "type")
private int type;
@Basic
@Column(name = "src_id")
private Long srcId;
@Basic
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/cse/ooad/project/utils/MessageType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cse.ooad.project.utils;

public enum MessageType {
MSG(0),APPLY(1);

public final int typeCode;
MessageType(int typeCode){
this.typeCode = typeCode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void LoginTest() {
@Order(7)
@Test
void MsgTest() {
Msg msg = new Msg(null, 1L, 2L, "罗启航牛逼", new Timestamp(12315616L), 12);
Msg msg = new Msg(null,0, 1L, 2L, "罗启航牛逼", new Timestamp(12315616L), 12);
msgService.saveMsg(msg);
}

Expand Down
1 change: 1 addition & 0 deletions src/test/resources/DDL-no-f.sql
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ create table if not exists public.msgs
(
msg_id bigint generated always as identity
primary key,
type integer,
src_id bigint,
dst_id bigint,
body varchar(255),
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/DDL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ create table if not exists public.msgs
(
msg_id bigint generated always as identity
primary key,
type integer,
src_id bigint,
dst_id bigint,
body varchar(255),
Expand Down

0 comments on commit f1fab64

Please sign in to comment.