등록 신청 컨트롤러, 서비스
This commit is contained in:
parent
a70de1f692
commit
bb9553a033
@ -0,0 +1,97 @@
|
||||
/************************************************************
|
||||
*
|
||||
* @packageName : io.company.localhost.controller.api
|
||||
* @fileName : RegisterController.java
|
||||
* @author : 박지윤
|
||||
* @date : 25.01.17
|
||||
* @description : 등록신청
|
||||
*
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 24.01.17 박지윤 최초 생성
|
||||
*
|
||||
*************************************************************/
|
||||
|
||||
package io.company.localhost.controller.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
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.RegisterService;
|
||||
import io.company.localhost.service.commoncodService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@RequestMapping("/api/register")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public class RegisterController {
|
||||
|
||||
private final commoncodService commoncodservice;
|
||||
private final RegisterService registerService;
|
||||
|
||||
/**
|
||||
* 사용 가능 색상 조회
|
||||
*
|
||||
* @return ApiResponse<List<MapDto>>
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/color")
|
||||
public ApiResponse<List<MapDto>> getColorList() {
|
||||
List<MapDto> ColorList = commoncodservice.getColorList();
|
||||
return ApiResponse.ok(ColorList);
|
||||
}
|
||||
|
||||
/**
|
||||
* MBTI 목록 조회
|
||||
*
|
||||
* @return ApiResponse<List<MapDto>>
|
||||
*
|
||||
*/
|
||||
@ParameterCheck
|
||||
@GetMapping("/mbti")
|
||||
public ApiResponse<List<MapDto>> getMbtiList() {
|
||||
List<MapDto> MbtiList = commoncodservice.getMbtiList();
|
||||
return ApiResponse.ok(MbtiList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 회원가입
|
||||
*
|
||||
* @param profile
|
||||
* @param map
|
||||
* @return ApiResponse<Integer>
|
||||
* @throws RuntimeException 파일 업로드 실패 시
|
||||
*/
|
||||
@PostMapping("/join")
|
||||
public ApiResponse<Integer> register(@RequestParam("profile") MultipartFile profile, @ReqMap MapDto map) {
|
||||
int member = registerService.register(profile, map);
|
||||
return ApiResponse.ok(member);
|
||||
}
|
||||
|
||||
/**
|
||||
* 아이디 중복 체크
|
||||
*
|
||||
* @param memberIds
|
||||
* @return ApiResponse<Boolean>
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@GetMapping("/checkId")
|
||||
public ApiResponse<Boolean> selectCheckId(@RequestParam String memberIds) {
|
||||
boolean isDuplicate = registerService.selectCheckId(memberIds);
|
||||
return ApiResponse.ok(!isDuplicate);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
/************************************************************
|
||||
*
|
||||
* @packageName : io.company.localhost.RegisterService
|
||||
* @fileName : RegisterService.java
|
||||
* @author : 박지윤
|
||||
* @date : 25.01.17
|
||||
* @description :
|
||||
*
|
||||
* ===========================================================
|
||||
* DATE AUTHOR NOTE
|
||||
* -----------------------------------------------------------
|
||||
* 24.01.17 박지윤 최초 생성
|
||||
*
|
||||
*************************************************************/
|
||||
package io.company.localhost.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import io.company.localhost.common.dto.MapDto;
|
||||
import io.company.localhost.mapper.NetmemberMapper;
|
||||
import io.company.localhost.mapper.commoncodMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RegisterService {
|
||||
private final NetmemberMapper memberMapper;
|
||||
private final commoncodMapper commoncodMapper;
|
||||
private final DelegatingPasswordEncoder passwordEncoder;
|
||||
private final FileService fileService;
|
||||
|
||||
/**
|
||||
* 회원 가입
|
||||
*
|
||||
* @param profile
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
public int register(MultipartFile profile, MapDto map) {
|
||||
// 프로필 이미지 저장, 저장된 경로 가져옴
|
||||
String profilePath = fileService.uploadFile(profile, "profiles");
|
||||
map.put("memberPrf", profilePath);
|
||||
|
||||
// 비밀번호 암호화 및 저장
|
||||
String encodedPassword = passwordEncoder.encode(map.getString("memberPwd"));
|
||||
map.put("memberPwd", encodedPassword);
|
||||
|
||||
// 회원 기본 정보 설정
|
||||
map.put("memberRol", "ROLE_MEMBER");
|
||||
map.put("memberPos", 500107);
|
||||
map.put("memberTkn", "Null");
|
||||
map.put("memberPrm", "N");
|
||||
map.put("memberDel", "N");
|
||||
map.put("memberLea", "N");
|
||||
map.put("memberRdt", LocalDateTime.now());
|
||||
map.put("memberCdt", LocalDateTime.now());
|
||||
|
||||
// 회원 정보 저장
|
||||
int result = memberMapper.insertMember(map);
|
||||
|
||||
// 선택한 색상 코드 사용 처리
|
||||
String color = map.getString("memberCol");
|
||||
commoncodMapper.updateColorYon(color);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 아이디 중복 체크
|
||||
*
|
||||
* @param memberIds
|
||||
* @return
|
||||
*/
|
||||
public boolean selectCheckId(String memberIds) {
|
||||
return memberMapper.selectCheckId(memberIds) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user