Skip to content

Commit

Permalink
feat: webconfig 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
junseokkim committed Jan 2, 2024
1 parent 6a33795 commit 48b08ad
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 12 deletions.
18 changes: 18 additions & 0 deletions src/main/java/com/teami/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.teami.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedHeaders("*")
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "PATCH")
.exposedHeaders("Authorization");
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.teami.domain.calendar.entitty;

import com.teami.domain.member.entitty.Member;
import com.teami.domain.mission.entity.Mission;
import com.teami.global.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import com.teami.domain.member.dto.request.LoginRequest;
import com.teami.domain.member.dto.request.MemberRequest;
import com.teami.domain.member.dto.request.VisitorCommentReq;
import com.teami.domain.member.dto.response.MemberIdResponse;
import com.teami.domain.member.dto.response.VisitorCommentRes;
import com.teami.domain.member.entitty.Member;
import com.teami.domain.member.service.MemberService;
import com.teami.global.apiPayload.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -26,15 +28,15 @@ public class MemberController {


@PostMapping("/signup")
public ApiResponse<MemberRequest> addMember(@RequestBody MemberRequest memberRequest){
public ApiResponse<MemberIdResponse> addMember(@RequestBody MemberRequest memberRequest){
boolean res = memberService.addMember(memberRequest);
return ApiResponse.onSuccess(null);
}

@PostMapping("/login")
public ApiResponse<Member> login(@RequestBody LoginRequest loginRequest){
public ApiResponse<MemberIdResponse> login(@RequestBody LoginRequest loginRequest){
Member res = memberService.login(loginRequest);
return ApiResponse.onSuccess(res);
return ApiResponse.onSuccess(new MemberIdResponse(res.getId()));
}


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.teami.domain.member.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class MemberIdResponse {
private Long memberId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@ public boolean addMember(MemberRequest memberRequest){
String nickname = memberRequest.getNickname();
String pw = memberRequest.getPassword();

//pw 암호화하는 과정 필요!!!!!!!!!!

//아이디가 존재하면
if(memberRepository.findMemberByLoginId(loginId) != null){
throw new ExceptionHandler(ErrorStatus.MEMBER_FOUND);
}
//닉네임이 존재하면
else if(memberRepository.findMemberByNickname(nickname) != null){
throw new ExceptionHandler(ErrorStatus.NICKNAME_EXIST);
}


Member member = new Member(memberRequest);

memberRepository.save(member);
rewardService.createReward_Member(member);
return true;
Expand All @@ -73,6 +79,8 @@ public Member login(LoginRequest loginRequest) {
}

public Boolean addVisitorComment(VisitorCommentReq visitorCommentReq) {


Optional<Member> writer = memberRepository.findById(visitorCommentReq.getWriterId());
Optional<Member> owner = memberRepository.findById(visitorCommentReq.getOwnerId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
@Service
@RequiredArgsConstructor
public class MissionService {

@Value("${chat.api}")
private String API_KEY;

@Value("${chat.comment}")
private String comment;
private static final String comment = "30일동안 하루 단위로 수행할 간단한 미션 생성해서 [n일차 : 미션] json 형태로 보내줘";

private static final String OPENAI_API_URL = "https://api.openai.com/v1/chat/completions";

Expand Down Expand Up @@ -62,6 +62,7 @@ public List<NewMissionResponse> generateMission() throws Exception {
}

public List<NewMissionResponse> parseMissionFromContent(String content) {
System.out.println("준석" + content);
List<NewMissionResponse> missions = new ArrayList<>();
String[] lines = content.split("\n");
for (String line : lines) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.teami.domain.member.entitty.Member;
import com.teami.domain.reward.dto.RewardResponse;
import com.teami.domain.reward.entity.MemberReward;
import com.teami.domain.reward.entity.Reward;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface MemberRewardRepository extends JpaRepository<MemberReward, Long> {
List<RewardResponse> findByMemberId(Long MemberId);
boolean existsByMemberAndRewardId(Member member, Long rewardId);

boolean existsByMemberAndReward(Member member, Reward reward);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RewardService {
private final MemberRewardRepository memberRewardRepository;

public Reward createReward_Member(Member member) {
if (!memberRewardRepository.existsByMemberAndRewardId(member, SIGNUP_AND_CALENDAR_CREATE.getRewardId())) {
if (!memberRewardRepository.existsByMemberAndReward(member, SIGNUP_AND_CALENDAR_CREATE)) {
memberRewardRepository.save(MemberReward.createMemberReward(member, SIGNUP_AND_CALENDAR_CREATE));
return SIGNUP_AND_CALENDAR_CREATE;
}
Expand All @@ -28,7 +28,7 @@ public Reward createReward_Member(Member member) {

public Reward createReward_Mission(Member member) {
// COMPLETE_FIVE_MISSION(1L, "5개의 미션을 연속으로 완료했어요!", MISSION),
if (!memberRewardRepository.existsByMemberAndRewardId(member, COMPLETE_FIVE_MISSION.getRewardId())) {
if (!memberRewardRepository.existsByMemberAndReward(member, COMPLETE_FIVE_MISSION)) {
// pass
}
return null;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/teami/domain/test/controller/HttpsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.teami.domain.test.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
@RequiredArgsConstructor
public class HttpsTest {
@GetMapping("/healthcheck")
public String healthcheck() {
return "OK";
}
}

0 comments on commit 48b08ad

Please sign in to comment.