http://192.168.0.251:3000/localnet/localhost-back.git into main
This commit is contained in:
commit
c9a2906e2d
@ -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 java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.authentication.RememberMeAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
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.RequestMapping;
|
||||
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.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.dto.ApiResponse;
|
||||
import io.company.localhost.common.dto.MapDto;
|
||||
import io.company.localhost.service.FileService;
|
||||
import io.company.localhost.service.NetmemberService;
|
||||
import io.company.localhost.service.commoncodService;
|
||||
import io.company.localhost.utils.AuthUtil;
|
||||
@ -204,23 +208,36 @@ public class UserController {
|
||||
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")
|
||||
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);
|
||||
public ApiResponse<MemberVo> getUserInfo2(@AuthenticationPrincipal MemberVo memberVo) {
|
||||
Long memberId = AuthUtil.getUser().getId();
|
||||
|
||||
MemberVo user = AuthUtil.getUser();
|
||||
log.info(">> AuthUtil : {}", user);
|
||||
log.info("🧩 memberId from AuthUtil: {}", memberId);
|
||||
|
||||
return ApiResponse.ok(memberVo);
|
||||
MemberVo user = netmemberservice.getUserInfoById(memberId);
|
||||
log.info("📦 User from DB: {}", user);
|
||||
|
||||
return ApiResponse.ok(user);
|
||||
}
|
||||
|
||||
|
||||
// 유저 세션 체크
|
||||
@GetMapping(value = "check")
|
||||
public ApiResponse<?> check() {
|
||||
@ -301,6 +318,27 @@ public class UserController {
|
||||
outData.put("user", user);
|
||||
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
|
||||
@GetMapping("get1")
|
||||
|
||||
@ -6,6 +6,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -119,5 +123,6 @@ public class WeatherController {
|
||||
|
||||
return dailyWeatherList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -50,6 +50,10 @@ public interface NetmemberMapper {
|
||||
List<MapDto> selectMemberBirthDay(MapDto map);
|
||||
|
||||
List<MapDto> selectRegisterMemberList();
|
||||
|
||||
void updateUserInfo(MapDto map);
|
||||
|
||||
MemberVo selectUserById(Long memberId);
|
||||
|
||||
int updateRegistMember(long memberSeq);
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
*************************************************************/
|
||||
package io.company.localhost.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
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.PromemberMapper;
|
||||
import io.company.localhost.mapper.commoncodMapper;
|
||||
import io.company.localhost.vo.MemberVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@ -201,6 +203,23 @@ public class NetmemberService {
|
||||
public List<MapDto> 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);
|
||||
}
|
||||
|
||||
|
||||
public int registerMember(long memberSeq) {
|
||||
return memberMapper.updateRegistMember(memberSeq);
|
||||
|
||||
@ -71,4 +71,12 @@ public class commoncodService {
|
||||
|
||||
return commoncodmapper.selectCodeList(map);
|
||||
}
|
||||
|
||||
public int updateColorYon(MapDto map) {
|
||||
return commoncodmapper.updateColorYon(map);
|
||||
}
|
||||
|
||||
public int updateColorChange(MapDto map) {
|
||||
return commoncodmapper.updateColorChange(map);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,4 +215,53 @@
|
||||
|
||||
</update>
|
||||
|
||||
<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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user