Skip to content

Commit

Permalink
Merge pull request #20 from StudyFlexUMC5th/yeeun2
Browse files Browse the repository at this point in the history
Yeeun2
  • Loading branch information
Yeeun411 authored Jan 10, 2024
2 parents 3219647 + 7cb94f7 commit 4450520
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ dependencies {
//mysql
implementation 'mysql:mysql-connector-java:8.0.26'

//Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'


compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/umc/StudyFlexBE/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.umc.StudyFlexBE.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

@Bean
public GroupedOpenApi publicApi() {
return GroupedOpenApi.builder()
.group("StudyFlex API")
.pathsToMatch("/**")
.build();
}

@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(new Info()
.title("StudyFlex API")
.description("StudyFlex API Docs")
.version("1.0.0"));
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/umc/StudyFlexBE/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class Member {
@Column(name = "school",length = 100)
private String school;

@Column(name = "is_complained")
private Integer isComplained;


@BatchSize(size = 100)
@OneToMany(mappedBy = "member", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/umc/StudyFlexBE/entity/Role.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.umc.StudyFlexBE.entity;

public enum Role {
ROLE_USER, ROLE_ADMIN, ROLE_CERTIFIED
ROLE_USER, ROLE_ADMIN, ROLE_CERTIFIED, ROLE_SUSPENDED
}
13 changes: 9 additions & 4 deletions src/main/java/com/umc/StudyFlexBE/service/ComplaintService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
import com.umc.StudyFlexBE.dto.response.BaseException;
import com.umc.StudyFlexBE.dto.response.BaseResponseStatus;
import com.umc.StudyFlexBE.dto.response.ComplaintResponseDto;
import com.umc.StudyFlexBE.entity.Complaint;
import com.umc.StudyFlexBE.entity.ComplaintCategory;
import com.umc.StudyFlexBE.entity.Member;
import com.umc.StudyFlexBE.entity.Study;
import com.umc.StudyFlexBE.entity.*;
import com.umc.StudyFlexBE.repository.ComplaintRepository;
import com.umc.StudyFlexBE.repository.MemberRepository;
import com.umc.StudyFlexBE.repository.StudyRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.umc.StudyFlexBE.entity.Role.ROLE_SUSPENDED;

@Service
public class ComplaintService {
private final ComplaintRepository complaintRepository;
Expand Down Expand Up @@ -48,8 +47,14 @@ public ComplaintResponseDto postComplaint(String email, Long studyId, ComplaintR
complaint.setComplainted_member(complaintedMember);
complaint.setComplaint_category(ComplaintCategory.valueOf(request.getComplaintCategory()));
complaint.setContent(request.getContent());
int currentComplainedValue = complaintedMember.getIsComplained();
if (currentComplainedValue == 2) {
complaintedMember.setRole(ROLE_SUSPENDED);
}
complaintedMember.setIsComplained(currentComplainedValue + 1);

complaintRepository.save(complaint);
memberRepository.save(complaintedMember);

return new ComplaintResponseDto(complaint.getComplaint_category().name(), complaint.getContent());
}
Expand Down

0 comments on commit 4450520

Please sign in to comment.