Skip to content

Commit

Permalink
Merge pull request #324 from Team-Ampersand/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
KyungJunNoh authored Apr 10, 2022
2 parents baea755 + d0d323e commit 0784a2c
Show file tree
Hide file tree
Showing 32 changed files with 269 additions and 239 deletions.
61 changes: 60 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" //querydsl
// *** Q-Type error *** //
id "io.franzbecker.gradle-lombok" version "3.0.0"
id 'jacoco' // jacoco
}

group = 'com.server'
Expand Down Expand Up @@ -77,7 +78,23 @@ dependencies {
}

test {
jacoco {
enabled = true
destinationFile = file("$buildDir/jacoco/${name}.exec")
includes = []
excludes = []
excludeClassLoaders = []
includeNoLocationClasses = false
sessionId = "<auto-generated value>"
dumpOnExit = true
classDumpDir = null
output = JacocoTaskExtension.Output.FILE
address = "localhost"
port = 6300
jmx = false
}
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}

//querydsl 추가 시작
Expand All @@ -95,4 +112,46 @@ configurations {
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
//querydsl 추가 끝
//querydsl 추가 끝

// jacoco
jacoco {
toolVersion = '0.8.5'
}

jacocoTestReport {
reports {
html.enabled true // "/build/reports/jacoco/test/html/index.html"
csv.enabled false
xml.enabled false
}
afterEvaluate {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'**/exception/**' // 테스트 커버리지 측정 대상에서 제거
,'**/dto/**' // 테스트 커버리지 측정 대상에서 제거
,'**/Dotori/DotoriApplication*'
,'**/Dotori/**/Q*' // Qclass 테스트 커버리지 측정 대상에서 제거
])
})
}
finalizedBy 'jacocoTestCoverageVerification'
}

jacocoTestCoverageVerification {
violationRules {
rule {
// 룰을 on 여부
enabled = true

// 룰을 check 단위 (패키지 번들)
element = 'BUNDLE'

limit {
counter = 'INSTRUCTION' // Java 바이트코드 명령 수
value = 'COVEREDRATIO' // 커버된 비율
minimum = 0.50 // 50%
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.server.Dotori.domain.member.enumType.Role;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDateTime;
import java.util.List;

import static lombok.AccessLevel.PROTECTED;

@Getter @Setter @Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor
@NoArgsConstructor(access = PROTECTED) @AllArgsConstructor
public class BoardGetDto {

private Long id;
private String title;
private List<Role> roles;

@CreatedDate
private LocalDateTime createdDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
import org.springframework.stereotype.Repository;

@Repository
public interface BoardRepository extends JpaRepository<Board, Long> {

public interface BoardRepository extends JpaRepository<Board, Long>, BoardRepositoryCustom {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.server.Dotori.domain.board.repository;

import com.server.Dotori.domain.board.Board;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public interface BoardRepositoryCustom {

Page<Board> getAllBoardCreateDateDesc(Pageable pageable);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.server.Dotori.domain.board.repository;

import com.querydsl.core.QueryResults;
import com.querydsl.jpa.impl.JPAQueryFactory;
import com.server.Dotori.domain.board.Board;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;

import java.util.List;

import static com.server.Dotori.domain.board.QBoard.board;
import static com.server.Dotori.domain.member.QMember.member;

@RequiredArgsConstructor
public class BoardRepositoryImpl implements BoardRepositoryCustom {

private final JPAQueryFactory queryFactory;

@Override
public Page<Board> getAllBoardCreateDateDesc(Pageable pageable) {
QueryResults<Board> boardQueryResults = queryFactory
.select(board)
.from(board)
.innerJoin(board.member, member)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(board.createdDate.desc())
.fetchResults();

List<Board> content = boardQueryResults.getResults();

long total = boardQueryResults.getTotal();

return new PageImpl<>(content, pageable, total);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Board createBoard(BoardDto boardDto, MultipartFile multipartFileList) {
*/
@Override
public Page<BoardGetDto> getAllBoard(Pageable pageable) {
Page<Board> boardPage = boardRepository.findAll(pageable);
Page<Board> boardPage = boardRepository.getAllBoardCreateDateDesc(pageable);

if (boardPage.isEmpty()) throw new DotoriException(BOARD_EMPTY);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.server.Dotori.domain.main_page.dto;

import com.server.Dotori.domain.member.enumType.Gender;
import lombok.*;

@Getter @Builder
Expand All @@ -9,5 +10,6 @@ public class GetProfileDto {
private Long id;
private String stuNum;
private String memberName;
private Gender gender;
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ public class MainPageServiceImpl implements MainPageService {

/**
* 메인페이지를 조회했을 때 프로필정보를 반환해주는 서비스로직 (로그인된 유저 사용가능)
* @return GetAboutPointDto (id, username, stNum, point)
* @author 배태현
* @return GetAboutPointDto (id, username, stNum, gender)
* @author 배태현, 노경준
*/

@Override
public GetProfileDto getMyProfile() {
return memberRepository.findProfileByMember(currentMemberUtil.getCurrentMember());
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/com/server/Dotori/domain/member/Member.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.server.Dotori.domain.member;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.server.Dotori.domain.member.enumType.*;
import com.server.Dotori.global.entity.BaseTimeEntity;
import com.server.Dotori.domain.member.enumType.Massage;
import com.server.Dotori.domain.member.enumType.Music;
import com.server.Dotori.domain.member.enumType.Role;
import com.server.Dotori.domain.member.enumType.SelfStudy;
import com.server.Dotori.domain.rule.RuleViolation;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
Expand Down Expand Up @@ -60,6 +58,10 @@ public class Member extends BaseTimeEntity implements UserDetails {
@Column(name = "massage_expired_date")
private LocalDateTime massageExpiredDate;

@Enumerated(STRING)
@Column(name = "member_gender")
private Gender gender;

@Enumerated(STRING) @Column(name = "Role")
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "Role", joinColumns = @JoinColumn(name = "member_id"))
Expand Down Expand Up @@ -159,4 +161,8 @@ public void updateRefreshToken(String refreshToken){
public void updateSelfStudyExpiredDate(LocalDateTime selfStudyExpiredDate) {
this.selfStudyExpiredDate = selfStudyExpiredDate;
}

public void updateMemberGender(Gender gender) {
this.gender = gender;
}
}
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.ChangePasswordDto;
import com.server.Dotori.domain.member.dto.ChangePasswordEmailCheckDto;
import com.server.Dotori.domain.member.dto.EmailDto;
import com.server.Dotori.domain.member.dto.WithdrawlDto;
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 Down Expand Up @@ -96,4 +93,11 @@ public CommonResult withdrawal(@RequestBody WithdrawlDto withdrawlDto){
memberService.withdrawal(withdrawlDto);
return responseService.getSuccessResult();
}

@PutMapping("/gender")
@ApiOperation(value="성별설정")
public CommonResult setGender(@RequestBody SetGenderDto setGenderDto){
memberService.setGender(setGenderDto);
return responseService.getSuccessResult();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.server.Dotori.domain.member.dto;

import com.server.Dotori.domain.member.Member;
import com.server.Dotori.domain.member.enumType.Massage;
import com.server.Dotori.domain.member.enumType.Music;
import com.server.Dotori.domain.member.enumType.Role;
import com.server.Dotori.domain.member.enumType.SelfStudy;
import com.server.Dotori.domain.member.enumType.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -36,6 +33,8 @@ public class MemberDto {
@Pattern(regexp = "^[a-zA-Z0-9][email protected]$")
private String email;

private Gender gender;

public Member toEntity(String encodePassword){
return Member.builder()
.memberName(memberName)
Expand All @@ -48,6 +47,7 @@ public Member toEntity(String encodePassword){
.music(Music.CAN)
.selfStudy(SelfStudy.CAN)
.point(0L)
.gender(gender)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.server.Dotori.domain.member.dto;

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

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

public enum Gender {
MAN,WOMAN,PENDING
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,17 @@ public List<GetAboutPointDto> findStudentPoint(Long id) {
/**
* 현재 로그인된 유저의 프로필 정보(메인페이지)를 조회하는 query
* @param memberEntity currentUser
* @return GetAboutPointDto (id, username, stNum, point)
* @author 배태현
* @return GetAboutPointDto (id, username, stNum, gender)
* @author 배태현, 노경준
*/
@Override
public GetProfileDto findProfileByMember(Member memberEntity) {
return queryFactory.from(member)
.select(Projections.constructor(GetProfileDto.class,
member.id,
member.stuNum,
member.memberName
member.memberName,
member.gender
))
.where(member.eq(memberEntity))
.fetchOne();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ public interface MemberService {
void checkEmailChangePassword(ChangePasswordEmailCheckDto verifiedAuthKeyAndChangePasswordDto);
void logout();
void withdrawal(WithdrawlDto memberDeleteDto);


void setGender(SetGenderDto setGenderDto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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 All @@ -23,7 +24,6 @@

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


@RequiredArgsConstructor
@Service
public class MemberServiceImpl implements MemberService {
Expand Down Expand Up @@ -199,6 +199,14 @@ public void withdrawal(WithdrawlDto withdrawlDto) {
memberRepository.delete(findMember);
}

@Transactional
@Override
public void setGender(SetGenderDto setGenderDto) {
Member member = memberRepository.findById(setGenderDto.getMemberId()).get();

member.updateMemberGender(setGenderDto.getGender());
}

/**
* 토큰을 생성하는 private 메서드
* @param member
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.server.Dotori.domain.rule.dto;

import com.server.Dotori.domain.member.Member;
import com.server.Dotori.domain.rule.RuleViolation;
import com.server.Dotori.domain.rule.enumType.Rule;
import lombok.*;

Expand All @@ -11,19 +9,11 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
@Setter
@Getter
public class RuleGrantDto {

private List<String> stuNum;
private Rule rule;
private List<Rule> rule;
private LocalDate date;

public RuleViolation toEntity(Member member){
return RuleViolation.builder()
.member(member)
.rule(rule)
.date(date)
.build();
}
}
Loading

0 comments on commit 0784a2c

Please sign in to comment.