This commit is contained in:
parent
e4956f12b0
commit
0a127c35b4
@ -17,10 +17,12 @@ package io.company.localhost.controller.common;
|
|||||||
|
|
||||||
import static org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY;
|
import static org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.authentication.RememberMeAuthenticationToken;
|
import org.springframework.security.authentication.RememberMeAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||||
@ -33,6 +35,7 @@ import org.springframework.web.bind.annotation.PatchMapping;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@ -43,6 +46,7 @@ import io.company.localhost.common.annotation.ParameterCheck;
|
|||||||
import io.company.localhost.common.annotation.ReqMap;
|
import io.company.localhost.common.annotation.ReqMap;
|
||||||
import io.company.localhost.common.dto.ApiResponse;
|
import io.company.localhost.common.dto.ApiResponse;
|
||||||
import io.company.localhost.common.dto.MapDto;
|
import io.company.localhost.common.dto.MapDto;
|
||||||
|
import io.company.localhost.service.FileService;
|
||||||
import io.company.localhost.service.NetmemberService;
|
import io.company.localhost.service.NetmemberService;
|
||||||
import io.company.localhost.service.commoncodService;
|
import io.company.localhost.service.commoncodService;
|
||||||
import io.company.localhost.utils.AuthUtil;
|
import io.company.localhost.utils.AuthUtil;
|
||||||
@ -204,23 +208,36 @@ public class UserController {
|
|||||||
return ApiResponse.ok(isPwNew);
|
return ApiResponse.ok(isPwNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
// security 인증 체크
|
// // security 인증 체크
|
||||||
|
// @GetMapping("userInfo")
|
||||||
|
// public ApiResponse<MemberVo> getUserInfo(@AuthenticationPrincipal MemberVo memberVo) {
|
||||||
|
// SecurityContextHolderStrategy contextHolderStrategy = SecurityContextHolder.getContextHolderStrategy();
|
||||||
|
// log.info(">> contextHolderStrategy : {}", contextHolderStrategy);
|
||||||
|
// SecurityContext context = contextHolderStrategy.getContext();
|
||||||
|
// log.info(">> context : {}", context);
|
||||||
|
// Authentication authentication = context.getAuthentication();
|
||||||
|
// log.info(">> authentication : {}", authentication);
|
||||||
|
// log.info(">> memberVo : {}", memberVo);
|
||||||
|
//
|
||||||
|
// MemberVo user = AuthUtil.getUser();
|
||||||
|
// log.info(">> AuthUtil : {}", user);
|
||||||
|
//
|
||||||
|
// return ApiResponse.ok(memberVo);
|
||||||
|
// }
|
||||||
|
|
||||||
@GetMapping("userInfo")
|
@GetMapping("userInfo")
|
||||||
public ApiResponse<MemberVo> getUserInfo(@AuthenticationPrincipal MemberVo memberVo) {
|
public ApiResponse<MemberVo> getUserInfo2(@AuthenticationPrincipal MemberVo memberVo) {
|
||||||
SecurityContextHolderStrategy contextHolderStrategy = SecurityContextHolder.getContextHolderStrategy();
|
Long memberId = AuthUtil.getUser().getId();
|
||||||
log.info(">> contextHolderStrategy : {}", contextHolderStrategy);
|
|
||||||
SecurityContext context = contextHolderStrategy.getContext();
|
|
||||||
log.info(">> context : {}", context);
|
|
||||||
Authentication authentication = context.getAuthentication();
|
|
||||||
log.info(">> authentication : {}", authentication);
|
|
||||||
log.info(">> memberVo : {}", memberVo);
|
|
||||||
|
|
||||||
MemberVo user = AuthUtil.getUser();
|
log.info("🧩 memberId from AuthUtil: {}", memberId);
|
||||||
log.info(">> AuthUtil : {}", user);
|
|
||||||
|
|
||||||
return ApiResponse.ok(memberVo);
|
MemberVo user = netmemberservice.getUserInfoById(memberId);
|
||||||
|
log.info("📦 User from DB: {}", user);
|
||||||
|
|
||||||
|
return ApiResponse.ok(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 유저 세션 체크
|
// 유저 세션 체크
|
||||||
@GetMapping(value = "check")
|
@GetMapping(value = "check")
|
||||||
public ApiResponse<?> check() {
|
public ApiResponse<?> check() {
|
||||||
@ -302,6 +319,27 @@ public class UserController {
|
|||||||
return ApiResponse.ok(outData);
|
return ApiResponse.ok(outData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/updateInfo")
|
||||||
|
public ApiResponse<?> updateUserInfo(@ReqMap MapDto map,
|
||||||
|
@RequestPart(value = "profileFile", required = false) MultipartFile profileFile
|
||||||
|
) throws IOException {
|
||||||
|
Long userId = AuthUtil.getUser().getId();
|
||||||
|
map.put("memberId", userId);
|
||||||
|
netmemberservice.updateUserInfo(map, profileFile);
|
||||||
|
return ApiResponse.ok("수정 완료");
|
||||||
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/updateColorYon")
|
||||||
|
public ApiResponse<Integer> updateColorYon(@ReqMap MapDto map) {
|
||||||
|
return ApiResponse.ok(commoncodservice.updateColorYon(map));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/updateColorChange")
|
||||||
|
public ApiResponse<Integer> updateColorChange(@ReqMap MapDto map) {
|
||||||
|
return ApiResponse.ok(commoncodservice.updateColorChange(map));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Guest
|
@Guest
|
||||||
@GetMapping("get1")
|
@GetMapping("get1")
|
||||||
public ApiResponse<?> getAuthTest1() {
|
public ApiResponse<?> getAuthTest1() {
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
package io.company.localhost.controller.common;
|
package io.company.localhost.controller.common;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@ -28,5 +32,6 @@ public class WeatherController {
|
|||||||
|
|
||||||
return ApiResponse.ok(response);
|
return ApiResponse.ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,4 +51,8 @@ public interface NetmemberMapper {
|
|||||||
|
|
||||||
List<MapDto> selectRegisterMemberList();
|
List<MapDto> selectRegisterMemberList();
|
||||||
|
|
||||||
|
void updateUserInfo(MapDto map);
|
||||||
|
|
||||||
|
MemberVo selectUserById(Long memberId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
*************************************************************/
|
*************************************************************/
|
||||||
package io.company.localhost.service;
|
package io.company.localhost.service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -26,6 +27,7 @@ import io.company.localhost.common.dto.MapDto;
|
|||||||
import io.company.localhost.mapper.NetmemberMapper;
|
import io.company.localhost.mapper.NetmemberMapper;
|
||||||
import io.company.localhost.mapper.PromemberMapper;
|
import io.company.localhost.mapper.PromemberMapper;
|
||||||
import io.company.localhost.mapper.commoncodMapper;
|
import io.company.localhost.mapper.commoncodMapper;
|
||||||
|
import io.company.localhost.vo.MemberVo;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -202,4 +204,21 @@ public class NetmemberService {
|
|||||||
return memberMapper.selectRegisterMemberList();
|
return memberMapper.selectRegisterMemberList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateUserInfo(MapDto map, MultipartFile profileFile) throws IOException {
|
||||||
|
// 프로필 이미지 저장 처리
|
||||||
|
if (profileFile != null && !profileFile.isEmpty()) {
|
||||||
|
String savedFilePath = fileService.uploadFile(profileFile);
|
||||||
|
map.put("memberPrf", savedFilePath); // DB 컬럼에 맞게 추가
|
||||||
|
}
|
||||||
|
System.out.println(map);
|
||||||
|
// DB 업데이트
|
||||||
|
memberMapper.updateUserInfo(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemberVo getUserInfoById(Long memberId) {
|
||||||
|
return memberMapper.selectUserById(memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,4 +71,12 @@ public class commoncodService {
|
|||||||
|
|
||||||
return commoncodmapper.selectCodeList(map);
|
return commoncodmapper.selectCodeList(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int updateColorYon(MapDto map) {
|
||||||
|
return commoncodmapper.updateColorYon(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int updateColorChange(MapDto map) {
|
||||||
|
return commoncodmapper.updateColorChange(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -194,4 +194,53 @@
|
|||||||
MEMBERPRM = 'N'
|
MEMBERPRM = 'N'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="updateUserInfo" parameterType="map">
|
||||||
|
UPDATE NETMEMBER
|
||||||
|
<set>
|
||||||
|
<if test="phone != null"> MEMBERTEL = #{phone}, </if>
|
||||||
|
<if test="color != null"> MEMBERCOL = #{color}, </if>
|
||||||
|
<if test="mbti != null"> MEMBERMBT = #{mbti}, </if>
|
||||||
|
<if test="birth != null"> MEMBERBTH = #{birth}, </if>
|
||||||
|
<if test="entryDate != null"> MEMBERCDT = #{entryDate}, </if>
|
||||||
|
<if test="address != null"> MEMBERARR = #{address}, </if>
|
||||||
|
<if test="detailAddress != null"> MEMBERDTL = #{detailAddress}, </if>
|
||||||
|
<if test="memberPrf != null"> MEMBERPRF = #{memberPrf}, </if>
|
||||||
|
</set>
|
||||||
|
WHERE MEMBERSEQ = #{memberId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="selectUserById" resultType="io.company.localhost.vo.MemberVo">
|
||||||
|
SELECT
|
||||||
|
MEMBERSEQ AS id
|
||||||
|
, MEMBERIDS AS loginId
|
||||||
|
, MEMBERROL AS role
|
||||||
|
, MEMBERTKN AS token
|
||||||
|
, MEMBERPRF AS profile
|
||||||
|
, MEMBERNAM AS name
|
||||||
|
, MEMBERPWD AS password
|
||||||
|
, MEMBERPWH AS passwordhint
|
||||||
|
, MEMBERPWR AS passwordRes
|
||||||
|
, MEMBERPOS AS position
|
||||||
|
, MEMBERARR AS address
|
||||||
|
, MEMBERDTL AS addressDetail
|
||||||
|
, MEMBERZIP AS zipcode
|
||||||
|
, MEMBERBTH AS birth
|
||||||
|
, MEMBERTEL AS phone
|
||||||
|
, MEMBERRDT AS regist
|
||||||
|
, MEMBERCDT AS isCdt
|
||||||
|
, MEMBERPRM AS isUsed
|
||||||
|
, MEMBERDEL AS isDel
|
||||||
|
, MEMBERLEA AS isLea
|
||||||
|
, MEMBERCOL AS color
|
||||||
|
, MEMBERMBT AS mbit
|
||||||
|
, c.CMNCODNAM usercolor
|
||||||
|
FROM
|
||||||
|
netmember m
|
||||||
|
left join
|
||||||
|
commoncod c
|
||||||
|
on
|
||||||
|
M.MEMBERCOL = C.CMNCODVAL
|
||||||
|
WHERE MEMBERSEQ = #{memberId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user