From f6ed78269b358b742ca844585b9cba446509c617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=84=9D=20=EC=B5=9C?= Date: Fri, 19 Aug 2022 11:04:38 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85,=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dbnt/faisp/controller/BaseController.java | 3 +-- .../faisp/controller/UserInfoController.java | 24 +++++++++++++++++++ .../java/com/dbnt/faisp/model/UserInfo.java | 22 +++++++---------- .../dbnt/faisp/service/UserInfoService.java | 5 ++-- src/main/resources/static/js/login/login.js | 3 +-- src/main/resources/templates/login/login.html | 2 +- 6 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/dbnt/faisp/controller/UserInfoController.java diff --git a/src/main/java/com/dbnt/faisp/controller/BaseController.java b/src/main/java/com/dbnt/faisp/controller/BaseController.java index 99869e59..199c50b5 100644 --- a/src/main/java/com/dbnt/faisp/controller/BaseController.java +++ b/src/main/java/com/dbnt/faisp/controller/BaseController.java @@ -5,6 +5,7 @@ import com.dbnt.faisp.service.CommonCodeService; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; @@ -22,8 +23,6 @@ public class BaseController { if(loginUser == null){ mav = new ModelAndView("redirect:/login"); }else{ - session.setAttribute("positionList", commonCodeService.selectCommonCodeValue("POSITION")); - session.setAttribute("departmentList", commonCodeService.selectCommonCodeValue("DEPARTMENT")); if(loginUser.getUserRole().indexOf("ADMIN")>0){ mav = new ModelAndView("redirect:/admin/main"); }else{ diff --git a/src/main/java/com/dbnt/faisp/controller/UserInfoController.java b/src/main/java/com/dbnt/faisp/controller/UserInfoController.java new file mode 100644 index 00000000..6cc10f07 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/controller/UserInfoController.java @@ -0,0 +1,24 @@ +package com.dbnt.faisp.controller; + +import com.dbnt.faisp.model.UserInfo; +import com.dbnt.faisp.service.CommonCodeService; +import com.dbnt.faisp.service.UserInfoService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/user") +public class UserInfoController { + + private final UserInfoService userInfoService; + + @PostMapping("/insertUserInfo") + public String insertUserInfo(UserInfo insertReqInfo) { + return userInfoService.insertUserInfo(insertReqInfo); + } +} diff --git a/src/main/java/com/dbnt/faisp/model/UserInfo.java b/src/main/java/com/dbnt/faisp/model/UserInfo.java index 26febdc3..7826269c 100644 --- a/src/main/java/com/dbnt/faisp/model/UserInfo.java +++ b/src/main/java/com/dbnt/faisp/model/UserInfo.java @@ -21,27 +21,21 @@ import java.util.Set; @NoArgsConstructor @DynamicInsert @DynamicUpdate -@Table(name = "USER_INFO") +@Table(name = "user_info") public class UserInfo extends BaseModel implements UserDetails{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "USER_SEQ") + @Column(name = "user_seq") private Integer userSeq; - @Column(name = "USER_ID") + @Column(name = "user_id") private String userId; - @Column(name = "PASSWORD") + @Column(name = "passwd") private String password; - @Column(name = "NAME") + @Column(name = "name") private String name; - @Column(name = "POSITION") - private Integer position; - @Column(name = "DEPARTMENT") - private Integer department; - @Column(name = "USER_ROLE") + @Column(name = "user_role") private String userRole; - @Column(name = "CREATE_DATE", updatable = false) - private LocalDateTime createDate; - @Column(name = "USER_STATUS") + @Column(name = "user_status") private String userStatus; @Transient @@ -82,6 +76,6 @@ public class UserInfo extends BaseModel implements UserDetails{ @Override public boolean isEnabled() { - return userStatus.equals("T"); + return userStatus.equals("ST002"); } } diff --git a/src/main/java/com/dbnt/faisp/service/UserInfoService.java b/src/main/java/com/dbnt/faisp/service/UserInfoService.java index 148229ac..36227b07 100644 --- a/src/main/java/com/dbnt/faisp/service/UserInfoService.java +++ b/src/main/java/com/dbnt/faisp/service/UserInfoService.java @@ -1,5 +1,6 @@ package com.dbnt.faisp.service; +import com.dbnt.faisp.config.Role; import com.dbnt.faisp.mapper.UserInfoMapper; import com.dbnt.faisp.model.UserInfo; import com.dbnt.faisp.repository.UserInfoRepository; @@ -25,6 +26,8 @@ public class UserInfoService implements UserDetailsService { if(userInfoRepository.findByUserId(userInfo.getUserId()).orElse(null) != null){ return "userIdDuplication"; } + userInfo.setUserRole(Role.USER.getValue()); + userInfo.setUserStatus("ST001"); userInfo.setPassword(convertPassword(userInfo.getPassword())); return userInfoRepository.save(userInfo).getUserId(); } @@ -35,8 +38,6 @@ public class UserInfoService implements UserDetailsService { targetUserInfo.setPassword(convertPassword(userInfo.getPassword())); } targetUserInfo.setName(userInfo.getName()); - targetUserInfo.setPosition(userInfo.getPosition()); - targetUserInfo.setDepartment(userInfo.getDepartment()); targetUserInfo.setUserRole(userInfo.getUserRole()); targetUserInfo.setUserStatus(userInfo.getUserStatus()); return targetUserInfo.getUserId(); diff --git a/src/main/resources/static/js/login/login.js b/src/main/resources/static/js/login/login.js index d213f286..c317f6ff 100644 --- a/src/main/resources/static/js/login/login.js +++ b/src/main/resources/static/js/login/login.js @@ -5,11 +5,10 @@ $(document).on('click', '#saveBtn', function (){ if(confirm("저장하시겠습니까?")){ contentFade("in"); const formData = new FormData($("#userInfoInsert")[0]); - debugger $.ajax({ type : 'POST', data : formData, - url : "/admin/insertUserInfo", + url : "/user/insertUserInfo", processData: false, contentType: false, success : function(result) { diff --git a/src/main/resources/templates/login/login.html b/src/main/resources/templates/login/login.html index e1278238..aff99fc7 100644 --- a/src/main/resources/templates/login/login.html +++ b/src/main/resources/templates/login/login.html @@ -16,7 +16,7 @@

반갑습니다

이곳은 외사정보시스템입니다

-
+