Skip to content

Commit 3dcbc5f

Browse files
author
xiaoqunLiu
committed
final
1 parent c771e88 commit 3dcbc5f

File tree

19 files changed

+1974
-228
lines changed

19 files changed

+1974
-228
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.sismics.docs.core.dao;
2+
3+
import com.sismics.docs.core.model.jpa.UserRegistrationRequest;
4+
import com.sismics.util.context.ThreadLocalContext;
5+
import jakarta.persistence.EntityManager;
6+
import jakarta.persistence.NoResultException;
7+
import jakarta.persistence.Query;
8+
import java.util.Date;
9+
import java.util.List;
10+
import java.util.UUID;
11+
12+
/**
13+
* User registration request DAO.
14+
*/
15+
public class UserRegistrationRequestDao {
16+
/**
17+
* Creates a new user registration request.
18+
*
19+
* @param request User registration request to create
20+
* @return Request ID
21+
*/
22+
public String create(UserRegistrationRequest request) {
23+
// Create the request UUID
24+
request.setId(UUID.randomUUID().toString());
25+
26+
// Checks for username unicity
27+
EntityManager em = ThreadLocalContext.get().getEntityManager();
28+
Query q = em.createQuery("select u from User u where u.username = :username and u.deleteDate is null");
29+
q.setParameter("username", request.getUsername());
30+
List<?> l = q.getResultList();
31+
if (l.size() > 0) {
32+
throw new RuntimeException("AlreadyExistingUsername");
33+
}
34+
35+
// Create the request
36+
request.setCreateDate(new Date());
37+
request.setStatus("PENDING");
38+
em.persist(request);
39+
40+
return request.getId();
41+
}
42+
43+
/**
44+
* Gets a user registration request by ID.
45+
*
46+
* @param id Request ID
47+
* @return User registration request
48+
*/
49+
public UserRegistrationRequest getById(String id) {
50+
EntityManager em = ThreadLocalContext.get().getEntityManager();
51+
Query q = em.createQuery("select u from UserRegistrationRequest u where u.id = :id");
52+
q.setParameter("id", id);
53+
try {
54+
return (UserRegistrationRequest) q.getSingleResult();
55+
} catch (NoResultException e) {
56+
return null;
57+
}
58+
}
59+
60+
/**
61+
* Gets all pending user registration requests.
62+
*
63+
* @return List of pending requests
64+
*/
65+
public List<UserRegistrationRequest> getPendingRequests() {
66+
EntityManager em = ThreadLocalContext.get().getEntityManager();
67+
Query q = em.createQuery("select u from UserRegistrationRequest u where u.status = 'PENDING' order by u.createDate");
68+
return q.getResultList();
69+
}
70+
71+
/**
72+
* Updates a user registration request.
73+
*
74+
* @param request Request to update
75+
* @param userId User ID who processed the request
76+
* @param comment Process comment
77+
*/
78+
public void update(UserRegistrationRequest request, String userId, String comment) {
79+
EntityManager em = ThreadLocalContext.get().getEntityManager();
80+
request.setProcessDate(new Date());
81+
request.setProcessUserId(userId);
82+
request.setProcessComment(comment);
83+
em.merge(request);
84+
}
85+
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
package com.sismics.docs.core.model.jpa;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.Id;
6+
import jakarta.persistence.Table;
7+
import java.util.Date;
8+
9+
/**
10+
* User registration request entity.
11+
*/
12+
@Entity
13+
@Table(name = "T_USER_REGISTRATION_REQUEST")
14+
public class UserRegistrationRequest {
15+
/**
16+
* Request ID.
17+
*/
18+
@Id
19+
@Column(name = "URR_ID_C", length = 36)
20+
private String id;
21+
22+
/**
23+
* Username.
24+
*/
25+
@Column(name = "URR_USERNAME_C", nullable = false, length = 50)
26+
private String username;
27+
28+
/**
29+
* Email address.
30+
*/
31+
@Column(name = "URR_EMAIL_C", nullable = false, length = 100)
32+
private String email;
33+
34+
/**
35+
* Password.
36+
*/
37+
@Column(name = "URR_PASSWORD_C", nullable = false, length = 100)
38+
private String password;
39+
40+
/**
41+
* Status (PENDING, APPROVED, REJECTED).
42+
*/
43+
@Column(name = "URR_STATUS_C", nullable = false, length = 20)
44+
private String status;
45+
46+
/**
47+
* Creation date.
48+
*/
49+
@Column(name = "URR_CREATEDATE_D", nullable = false)
50+
private Date createDate;
51+
52+
/**
53+
* Processed date.
54+
*/
55+
@Column(name = "URR_PROCESSDATE_D")
56+
private Date processDate;
57+
58+
/**
59+
* Processed by user ID.
60+
*/
61+
@Column(name = "URR_PROCESSUSERID_C", length = 36)
62+
private String processUserId;
63+
64+
/**
65+
* Process comment.
66+
*/
67+
@Column(name = "URR_PROCESSCOMMENT_C", length = 500)
68+
private String processComment;
69+
70+
public String getId() {
71+
return id;
72+
}
73+
74+
public void setId(String id) {
75+
this.id = id;
76+
}
77+
78+
public String getUsername() {
79+
return username;
80+
}
81+
82+
public void setUsername(String username) {
83+
this.username = username;
84+
}
85+
86+
public String getEmail() {
87+
return email;
88+
}
89+
90+
public void setEmail(String email) {
91+
this.email = email;
92+
}
93+
94+
public String getPassword() {
95+
return password;
96+
}
97+
98+
public void setPassword(String password) {
99+
this.password = password;
100+
}
101+
102+
public String getStatus() {
103+
return status;
104+
}
105+
106+
public void setStatus(String status) {
107+
this.status = status;
108+
}
109+
110+
public Date getCreateDate() {
111+
return createDate;
112+
}
113+
114+
public void setCreateDate(Date createDate) {
115+
this.createDate = createDate;
116+
}
117+
118+
public Date getProcessDate() {
119+
return processDate;
120+
}
121+
122+
public void setProcessDate(Date processDate) {
123+
this.processDate = processDate;
124+
}
125+
126+
public String getProcessUserId() {
127+
return processUserId;
128+
}
129+
130+
public void setProcessUserId(String processUserId) {
131+
this.processUserId = processUserId;
132+
}
133+
134+
public String getProcessComment() {
135+
return processComment;
136+
}
137+
138+
public void setProcessComment(String processComment) {
139+
this.processComment = processComment;
140+
}
141+
}

docs-core/src/main/java/com/sismics/docs/core/util/YoudaoTranslateUtil.java

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
alter table T_FILE alter column FIL_IDUSER_C set not null;
2+
3+
create table T_USER_REGISTRATION_REQUEST (
4+
URR_ID_C varchar(36) not null,
5+
URR_USERNAME_C varchar(50) not null,
6+
URR_EMAIL_C varchar(100) not null,
7+
URR_PASSWORD_C varchar(100) not null,
8+
URR_STATUS_C varchar(20) not null,
9+
URR_CREATEDATE_D timestamp not null,
10+
URR_PROCESSDATE_D timestamp,
11+
URR_PROCESSUSERID_C varchar(36),
12+
URR_PROCESSCOMMENT_C varchar(500),
13+
primary key (URR_ID_C)
14+
);
15+
216
update T_CONFIG set CFG_VALUE_C = '5' where CFG_ID_C = 'DB_VERSION';

0 commit comments

Comments
 (0)