jdk 1.8 -> 17, @Component("...") 추가, 사용자 아이디 관련 변경

master
mjkhan21 1 year ago
parent a8bd23921e
commit 8e6422c562

@ -12,7 +12,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version> <java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
@ -120,8 +120,8 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<source>1.8</source> <source>${java.version}</source>
<target>1.8</target> <target>${java.version}</target>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>

@ -49,7 +49,6 @@ public abstract class GenericUser extends User {
} }
private String private String
key,
passwordHint, passwordHint,
passwordHintAnswer, passwordHintAnswer,
gender, gender,
@ -62,7 +61,6 @@ public abstract class GenericUser extends User {
faxNo, faxNo,
mobilePhoneNo, mobilePhoneNo,
groupID, groupID,
locked,
status; status;
private int lockCount; private int lockCount;
private String lockedDate; private String lockedDate;
@ -72,20 +70,6 @@ public abstract class GenericUser extends User {
*/ */
public abstract String getType(); public abstract String getType();
/** ID .
* @return ID
*/
public String getKey() {
return key;
}
/** ID .
* @param key ID
*/
public void setKey(String key) {
this.key = key;
}
/** . /** .
* @return * @return
*/ */
@ -255,20 +239,6 @@ public abstract class GenericUser extends User {
this.groupID = groupID; this.groupID = groupID;
} }
/** .
* @return
*/
public String getLocked() {
return Assert.ifEmpty(locked, "N");
}
/** .
* @param locked
*/
public void setLocked(String locked) {
this.locked = locked;
}
/** . /** .
* @return * @return
*/ */

@ -12,7 +12,6 @@ public class ManagedUser extends GenericUser {
deptCode, deptCode,
birthday, birthday,
positionName, positionName,
institute,
certificateDn; certificateDn;
@Override @Override
@ -104,20 +103,6 @@ public class ManagedUser extends GenericUser {
this.positionName = positionName; this.positionName = positionName;
} }
/** .
* @return
*/
public String getInstitute() {
return institute;
}
/** .
* @param insititute
*/
public void setInstitute(String insititute) {
this.institute = insititute;
}
/** DN . /** DN .
* @return DN * @return DN
*/ */

@ -57,6 +57,31 @@ public interface UserMapper extends AbstractMapper {
return !users.isEmpty() ? users.get(0) : null; return !users.isEmpty() ? users.get(0) : null;
} }
/** .
* @param params
* <pre><code>{
* "account": ,
* "institute":
* }</code></pre>
* @return
*/
<T extends User> T getUser(Map<String, Object> params);
/** .
* @param account
* @param institute
* @return
*/
default <T extends User> T getUser(String account, String institute) {
notEmpty(account, "사용자 계정");
notEmpty(institute, "소속 기관 코드");
return getUser(
params()
.set("account", account)
.set("institute", institute)
);
}
/** . /** .
* @param user * @param user
* @return * @return

@ -59,6 +59,14 @@ public interface UserService {
*/ */
<T extends User> T getUser(String userID); <T extends User> T getUser(String userID);
/** .
* @param <T>
* @param account
* @param institute
* @return
*/
<T extends User> T getUser(String account, String institute);
/** . {@link cokr.xit.foundation.util.CharsEncoder } . /** . {@link cokr.xit.foundation.util.CharsEncoder } .
* @param user * @param user
* @return * @return

@ -30,7 +30,7 @@ public class UserBean extends AbstractComponent {
*/ */
public List<DataObject> getUserList(UserQuery req) { public List<DataObject> getUserList(UserQuery req) {
switch (ifEmpty(req.getBy(), () -> "")) { switch (ifEmpty(req.getBy(), () -> "")) {
case "userID": req.setBy("USER_ID"); break; case "userAccount": req.setBy("USER_ACNT"); break;
default: req.setBy("USER_NM"); break; default: req.setBy("USER_NM"); break;
} }
req.setOrderBy(req.getBy()); req.setOrderBy(req.getBy());
@ -63,6 +63,16 @@ public class UserBean extends AbstractComponent {
return userMapper.getUser(userID); return userMapper.getUser(userID);
} }
/** .
* @param <T>
* @param account
* @param institute
* @return
*/
public <T extends User> T getUser(String account, String institute) {
return userMapper.getUser(account, institute);
}
/** . {@link cokr.xit.foundation.util.CharsEncoder } . /** . {@link cokr.xit.foundation.util.CharsEncoder } .
* @param user * @param user
* @return * @return
@ -73,8 +83,7 @@ public class UserBean extends AbstractComponent {
public boolean create(User user) { public boolean create(User user) {
if (user == null) return false; if (user == null) return false;
String userID = notEmpty(user.getId(), "user.id"); User existing = getExistingUser(user);
User existing = getUser(userID);
if (existing != null) if (existing != null)
throw applicationException(null) throw applicationException(null)
.setMessage(message("duplicate.object", "사용자")); .setMessage(message("duplicate.object", "사용자"));
@ -85,6 +94,12 @@ public class UserBean extends AbstractComponent {
return userMapper.insertUser(user) > 0; return userMapper.insertUser(user) > 0;
} }
private User getExistingUser(User user) {
String account = user.getAccount(),
institute = user.getInstitute();
return getUser(account, institute);
}
/** . /** .
* @param user * @param user
* @return * @return
@ -95,6 +110,11 @@ public class UserBean extends AbstractComponent {
public boolean update(User user) { public boolean update(User user) {
if (user == null) return false; if (user == null) return false;
User existing = getExistingUser(user);
if (existing != null && !equals(user.getId(), existing.getId()))
throw applicationException(null)
.setMessage(message("duplicate.object", "사용자"));
user.setModifiedBy(currentUser().getId()); user.setModifiedBy(currentUser().getId());
return userMapper.updateUser(user) > 0; return userMapper.updateUser(user) > 0;
} }

@ -42,6 +42,11 @@ public class UserServiceBean extends AbstractServiceBean implements UserService
return userBean.getUser(userID); return userBean.getUser(userID);
} }
@Override
public <T extends User> T getUser(String account, String institute) {
return userBean.getUser(account, institute);
}
@Override @Override
public boolean create(User user) { public boolean create(User user) {
return userBean.create(user); return userBean.create(user);

@ -68,16 +68,17 @@ public class UserController<U extends User> extends AbstractController {
return mav.addObject("userList", toJson(list)); return mav.addObject("userList", toJson(list));
} }
/** . /** .
* @param userID * @param account
* @param institute
* @return jsonView * @return jsonView
* <pre><code> { * <pre><code> {
* "duplicate": true, false * "duplicate": true, false
* }</code></pre> * }</code></pre>
*/ */
@RequestMapping(name="중복 확인", value="/duplicate.do") @RequestMapping(name="중복 확인", value="/duplicate.do")
public ModelAndView isDuplicate(String userID) { public ModelAndView isDuplicate(String account, String institute) {
U user = userService.getUser(userID); U user = userService.getUser(account, institute);
return new ModelAndView("jsonView") return new ModelAndView("jsonView")
.addObject("duplicate", user != null); .addObject("duplicate", user != null);
} }

Loading…
Cancel
Save