Skip to content

Commit

Permalink
Merge pull request #335 from Team-Ampersand/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
qoxogus authored Apr 16, 2022
2 parents f24757f + a979172 commit ad3ffc4
Show file tree
Hide file tree
Showing 29 changed files with 218 additions and 101 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/server/Dotori/domain/board/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Board extends BaseTimeEntity {
@Column(name = "board_title", nullable = false)
private String title;

@Column(name = "board_content", length = 800, nullable = false)
@Column(name = "board_content", length = 5000, nullable = false)
private String content;

@Column(name = "board_image_url")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BoardDto {
private String title;

@NotBlank
@Size(min = 1, max = 800)
@Size(min = 1, max = 5000)
private String content;

public Board saveToEntity(Member member, String url) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.server.Dotori.domain.main_page.service.Impl;

import com.server.Dotori.domain.board.Board;
import com.server.Dotori.domain.main_page.dto.BoardAlarmDto;
import com.server.Dotori.domain.board.repository.BoardRepository;
import com.server.Dotori.domain.main_page.dto.BoardAlarmDto;
import com.server.Dotori.domain.main_page.service.BoardAlarmService;
import com.server.Dotori.global.exception.DotoriException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import static com.server.Dotori.global.exception.ErrorCode.BOARD_EMPTY;

@Service
@RequiredArgsConstructor
public class BoardAlarmServiceImpl implements BoardAlarmService {
Expand All @@ -22,6 +25,8 @@ public class BoardAlarmServiceImpl implements BoardAlarmService {
public BoardAlarmDto getBoardAlarmInfo() {
Board lastWriteBoard = boardRepository.findTop1ByOrderByCreatedDateDesc();

if (lastWriteBoard == null) throw new DotoriException(BOARD_EMPTY);

return BoardAlarmDto.builder()
.id(lastWriteBoard.getId())
.title(lastWriteBoard.getTitle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ public SingleResult getMassageStudentsAdmin() {
}

/**
* 안마의자를 신청한 학생수와 자신의 신청 상태 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태)>
* 안마의자를 신청한 학생수와 자신의 신청 상태와 안마의자 신청 금지 만료일 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태), String expiredTime(안마의자 신청 금지 만료일)>
*/
@GetMapping ("/massage/info")
@ResponseStatus( HttpStatus.OK )
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회")
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일")
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "로그인 성공 후 access_token", required = true, dataType = "String", paramType = "header"),
@ApiImplicitParam(name = "RefreshToken", value = "로그인 성공 후 refresh_token", required = false, dataType = "String", paramType = "header")
})
public SingleResult<Map<String, String>> getMassageStatusAndCountAdmin() {
return responseService.getSingleResult(massageService.getMassageStatusAndCount());
public SingleResult<Map<String, String>> getMassageInfoAdmin() {
return responseService.getSingleResult(massageService.getMassageInfo());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ public SingleResult<List<MassageStudentsDto>> getMassageStudentsCouncillor() {
}

/**
* 안마의자를 신청한 학생수와 자신의 신청 상태 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태)>
* 안마의자를 신청한 학생수와 자신의 신청 상태와 안마의자 신청 금지 만료일 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태), String expiredTime(안마의자 신청 금지 만료일)>
*/
@GetMapping ("/massage/info")
@ResponseStatus( HttpStatus.OK )
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회")
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일")
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "로그인 성공 후 access_token", required = true, dataType = "String", paramType = "header"),
@ApiImplicitParam(name = "RefreshToken", value = "로그인 성공 후 refresh_token", required = false, dataType = "String", paramType = "header")
})
public SingleResult<Map<String, String>> getMassageStatusAndCountCouncillor() {
return responseService.getSingleResult(massageService.getMassageStatusAndCount());
public SingleResult<Map<String, String>> getMassageInfoCouncillor() {
return responseService.getSingleResult(massageService.getMassageInfo());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ public SingleResult<List<MassageStudentsDto>> getMassageStudentsDeveloper() {
}

/**
* 안마의자를 신청한 학생수와 자신의 신청 상태 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태)>
* 안마의자를 신청한 학생수와 자신의 신청 상태와 안마의자 신청 금지 만료일 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태), String expiredTime(안마의자 신청 금지 만료일)>
*/
@GetMapping ("/massage/info")
@ResponseStatus( HttpStatus.OK )
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회")
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일")
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "로그인 성공 후 access_token", required = true, dataType = "String", paramType = "header"),
@ApiImplicitParam(name = "RefreshToken", value = "로그인 성공 후 refresh_token", required = false, dataType = "String", paramType = "header")
})
public SingleResult<Map<String, String>> getMassageStatusAndCountDeveloper() {
return responseService.getSingleResult(massageService.getMassageStatusAndCount());
public SingleResult<Map<String, String>> getMassageInfoDeveloper() {
return responseService.getSingleResult(massageService.getMassageInfo());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ public SingleResult<List<MassageStudentsDto>> getMassageStudentsMember() {
}

/**
* 안마의자를 신청한 학생수와 자신의 신청 상태 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태)>
* 안마의자를 신청한 학생수와 자신의 신청 상태와 안마의자 신청 금지 만료일 조회
* @return Map<String count(안마의자 신청을 한 학생수), String massageStatus(자신의 안마의자 신청 상태), String expiredTime(안마의자 신청 금지 만료일)>
*/
@GetMapping ("/massage/info")
@ResponseStatus( HttpStatus.OK )
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회")
@ApiOperation(value = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일", notes = "안마의자를 신청한 학생 카운트, 안마의자 신청 상태 조회, 안마의자 신청 금지 만료일")
@ApiImplicitParams({
@ApiImplicitParam(name = "Authorization", value = "로그인 성공 후 access_token", required = true, dataType = "String", paramType = "header"),
@ApiImplicitParam(name = "RefreshToken", value = "로그인 성공 후 refresh_token", required = false, dataType = "String", paramType = "header")
})
public SingleResult<Map<String, String>> getMassageStatusAndCountMember() {
return responseService.getSingleResult(massageService.getMassageStatusAndCount());
public SingleResult<Map<String, String>> getMassageInfoMember() {
return responseService.getSingleResult(massageService.getMassageInfo());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.time.DayOfWeek;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -32,6 +33,12 @@ public class MassageServiceImpl implements MassageService {
private final CurrentMemberUtil currentMemberUtil;
private final MemberRepository memberRepository;

private void timeValidate(DayOfWeek dayOfWeek, int hour, int min) {
if (dayOfWeek == DayOfWeek.FRIDAY || dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_DATE);
if (!(hour >= 20 && hour < 21)) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_TIME);
if (!(min >= 20)) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_TIME);
}

/**
* 안마의자를 신청하는 로직
* 5명이 신청가능, 안마의자 신청 상태가 'CAN'일때만 신청가능, 금토일은 신청 불가능
Expand All @@ -50,12 +57,10 @@ public class MassageServiceImpl implements MassageService {
@Override
@Transactional
public void requestMassage(DayOfWeek dayOfWeek, int hour, int min) {
if (dayOfWeek == DayOfWeek.FRIDAY || dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_DATE);
if (!(hour >= 20 && hour < 21)) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_TIME);
if (!(min >= 20)) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_TIME);
timeValidate(dayOfWeek, hour, min);

long count = massageRepository.count();
try{
try {
if (count < 5) {
Member currentMember = currentMemberUtil.getCurrentMember();

Expand All @@ -67,10 +72,10 @@ public void requestMassage(DayOfWeek dayOfWeek, int hour, int min) {
currentMember.updateMassage(APPLIED);
currentMember.updateMassageExpiredDate(LocalDateTime.now().plusMonths(1));

log.info("Current MassageRequest Student Count is {}", count+1);
log.info("Current MassageRequest Student Count is {}", count + 1);
} else throw new DotoriException(MASSAGE_ALREADY);
} else throw new DotoriException(MASSAGE_OVER);
} catch (DataIntegrityViolationException e){
} catch (DataIntegrityViolationException e) {
throw new DotoriException(MASSAGE_ALREADY);
}
}
Expand All @@ -93,9 +98,7 @@ public void requestMassage(DayOfWeek dayOfWeek, int hour, int min) {
@Override
@Transactional
public void cancelMassage(DayOfWeek dayOfWeek, int hour, int min) {
if (dayOfWeek == DayOfWeek.FRIDAY || dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_DATE);
if (!(hour >= 20 && hour < 21)) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_TIME);
if (!(min >= 20)) throw new DotoriException(MASSAGE_CANT_REQUEST_THIS_TIME);
timeValidate(dayOfWeek, hour, min);

long count = massageRepository.count();
Member currentMember = currentMemberUtil.getCurrentMember();
Expand Down Expand Up @@ -127,16 +130,19 @@ public void updateMassageStatus() {
}

/**
* 안마의자 신청을 한 학생수와 현재 자신의 안마의자 신청 상태를 조회하는 로직
* @return Map <String massageStatus(안마의자 신청 상태), String count(안마의자 신청 카운트)>
* 안마의자 신청을 한 학생수와 현재 자신의 안마의자 신청 상태와 안마의자 신청 금지 만료일을 조회하는 로직
* @return Map <String massageStatus(안마의자 신청 상태), String count(안마의자 신청 카운트), String expiredTime(안마의자 신청 금지 만료일)>
* @author 김태민
*/
@Override
@Transactional(readOnly = true)
public Map<String, String> getMassageStatusAndCount() {
public Map<String, String> getMassageInfo() {
Map<String, String> map = new HashMap<>();
map.put("status",currentMemberUtil.getCurrentMember().getMassage().toString());
map.put("count", String.valueOf(massageRepository.count()));
if (!(currentMemberUtil.getCurrentMember().getMassageExpiredDate() == null)) {
map.put("expiredTime", currentMemberUtil.getCurrentMember().getMassageExpiredDate().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
}
return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface MassageService {
void cancelMassage(DayOfWeek dayOfWeek, int hour, int min);
void updateMassageStatus();
List<MassageStudentsDto> getMassageStudents();
Map<String, String> getMassageStatusAndCount();
Map<String, String> getMassageInfo();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.server.Dotori.domain.member.controller;

import com.server.Dotori.domain.member.dto.EmailDto;
import com.server.Dotori.domain.member.dto.MemberDto;
import com.server.Dotori.domain.member.dto.SignInDto;
import com.server.Dotori.domain.member.dto.SignUpEmailCheckDto;
import com.server.Dotori.domain.member.dto.*;
import com.server.Dotori.domain.member.service.MemberService;
import com.server.Dotori.global.response.ResponseService;
import com.server.Dotori.global.response.result.CommonResult;
Expand All @@ -16,7 +13,6 @@
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

@RequiredArgsConstructor
@RestController
Expand Down Expand Up @@ -73,8 +69,8 @@ public CommonResult checkEmailSignup(@Valid @RequestBody SignUpEmailCheckDto mem
*/
@PostMapping("/signin")
@ApiOperation(value="로그인")
public SingleResult<Map<String, String>> signin(@Valid @RequestBody SignInDto memberLoginDto){
Map<String, String> data = memberService.signIn(memberLoginDto);
public SingleResult<SignInResponseDto> signin(@Valid @RequestBody SignInDto memberLoginDto){
SignInResponseDto data = memberService.signIn(memberLoginDto);
return responseService.getSingleResult(data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

@Getter
public class SetGenderDto {
private Long memberId;
private String email;
private Gender gender;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.server.Dotori.domain.member.dto;

import com.server.Dotori.domain.member.enumType.Gender;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;

@Getter
@AllArgsConstructor
public class SignInResponseDto {

private Map<String, String> token;
private Gender gender;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public List<SelfStudyStudentsDto> findBySelfStudyAPLLIED() {
.select(Projections.fields(SelfStudyStudentsDto.class,
member.id,
member.stuNum,
member.memberName)
member.memberName,
member.gender
)
).where(
member.selfStudy.eq(SelfStudy.APPLIED)
)
Expand All @@ -56,7 +58,10 @@ public List<SelfStudyStudentsDto> findBySelfStudyCategory(Long id) {
.select(Projections.fields(SelfStudyStudentsDto.class,
member.id,
member.stuNum,
member.memberName))
member.memberName,
member.gender
)
)
.where(
member.selfStudy.eq(SelfStudy.APPLIED)
.and(member.stuNum.like(id+"%"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import com.server.Dotori.domain.member.dto.*;

import java.util.Map;

public interface MemberService {
Long signup(MemberDto memberDto);
String sendEmailSignup(EmailDto emailDto);
void checkEmailSignup(SignUpEmailCheckDto memberEmailKeyDto);
Map<String,String> signIn(SignInDto memberLoginDto);
SignInResponseDto signIn(SignInDto memberLoginDto);
String changePassword(ChangePasswordDto changePasswordDto);
String sendEmailChangePassword(EmailDto emailDto);
void checkEmailChangePassword(ChangePasswordEmailCheckDto verifiedAuthKeyAndChangePasswordDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.server.Dotori.domain.member.EmailCertificate;
import com.server.Dotori.domain.member.Member;
import com.server.Dotori.domain.member.dto.*;
import com.server.Dotori.domain.member.enumType.Gender;
import com.server.Dotori.domain.member.repository.email.EmailCertificateRepository;
import com.server.Dotori.domain.member.repository.member.MemberRepository;
import com.server.Dotori.domain.member.service.MemberService;
Expand Down Expand Up @@ -99,16 +98,16 @@ public void checkEmailSignup(SignUpEmailCheckDto signUpEmailCheckDto) {
*/
@Transactional
@Override
public Map<String,String> signIn(SignInDto signInDto) {
public SignInResponseDto signIn(SignInDto signInDto) {
String email = signInDto.getEmail();

Member findMember = memberRepository.findByEmail(email)
.orElseThrow(() -> new DotoriException(MEMBER_NOT_FOUND));
if(!passwordEncoder.matches(signInDto.getPassword(),findMember.getPassword())) throw new DotoriException(MEMBER_PASSWORD_NOT_MATCHING);

Map<String, String> token = createToken(findMember);
SignInResponseDto signInResponseDto = new SignInResponseDto(createToken(findMember),findMember.getGender());

return token;
return signInResponseDto;
}

/**
Expand Down Expand Up @@ -174,6 +173,7 @@ public void checkEmailChangePassword(ChangePasswordEmailCheckDto changePasswordE
* 로그아웃 하는 서비스 로직
* @author 노경준
*/
@Transactional
@Override
public void logout() {
currentMemberUtil.getCurrentMember().updateRefreshToken(null);
Expand Down Expand Up @@ -202,7 +202,8 @@ public void withdrawal(WithdrawlDto withdrawlDto) {
@Transactional
@Override
public void setGender(SetGenderDto setGenderDto) {
Member member = memberRepository.findById(setGenderDto.getMemberId()).get();
Member member = memberRepository.findByEmail(setGenderDto.getEmail())
.orElseThrow(() -> new DotoriException(MEMBER_NOT_FOUND));

member.updateMemberGender(setGenderDto.getGender());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package com.server.Dotori.domain.self_study.dto;

import com.server.Dotori.domain.member.enumType.Gender;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SelfStudyStudentsDto {

private Long id;
private String stuNum;
private String memberName;

public SelfStudyStudentsDto(Long id, String stuNum, String memberName) {
this.id = id;
this.stuNum = stuNum;
this.memberName = memberName;
}
private Gender gender;
}
Loading

0 comments on commit ad3ffc4

Please sign in to comment.