Skip to content

Commit

Permalink
Merge pull request #203 from gunsight1/DB_add_insert_common_code_and_…
Browse files Browse the repository at this point in the history
…create_withraw_table

DB :: 회원탈퇴 테이블 추가, 공통코드 레코드 수정 SQL
  • Loading branch information
gunsight1 authored Feb 28, 2024
2 parents d6f13d4 + d2f8088 commit 9f8051d
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import com.kernel360.member.code.MemberErrorCode;
import com.kernel360.member.dto.*;
import com.kernel360.member.entity.Member;
import com.kernel360.member.entity.WithrawMember;
import com.kernel360.member.entity.WithdrawMember;
import com.kernel360.member.enumset.Age;
import com.kernel360.member.enumset.Gender;
import com.kernel360.member.repository.MemberRepository;
import com.kernel360.member.repository.WithrawMemberRepository;
import com.kernel360.member.repository.WithdrawMemberRepository;
import com.kernel360.utils.ConvertSHA256;
import com.kernel360.utils.JWT;
import com.kernel360.washinfo.entity.WashInfo;
Expand Down Expand Up @@ -40,7 +40,7 @@ public class MemberService {
private final CarInfoRepository carInfoRepository;
private final WashInfoRepository washInfoRepository;
private final KakaoRequest kakaoRequest;
private final WithrawMemberRepository withrawMemberRepository;
private final WithdrawMemberRepository withdrawMemberRepository;

@Transactional
public void joinMember(MemberDto requestDto) {
Expand Down Expand Up @@ -252,7 +252,7 @@ public MemberDto loginForKakao(String accessToken) {
public void signOut(String accessToken) {
Member member = memberRepository.findOneById(jwt.ownerId(accessToken));

withrawMemberRepository.save(WithrawMember.of(member.getMemberNo(),member.getId(), member.getEmail(), null));
withdrawMemberRepository.save(WithdrawMember.of(member.getMemberNo(),member.getId(), member.getEmail(), null));

memberRepository.delete(member);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
CREATE TABLE if not exists withdraw_member
(
member_no bigserial NOT NULL,
id varchar NOT NULL,
email varchar NOT NULL,
ip varchar,
created_at date NOT NULL,
created_by varchar(10485760) NULL,
modified_at date NULL,
modified_by varchar(10485760) NULL
);


INSERT INTO public.common_code (code_no, code_name, upper_no, upper_name, sort_order, is_used, description,
sub_description, created_at, created_by, modified_at, modified_by)
VALUES (67, 'OTHERS', 48, NULL, 3, true, '변경필요', NULL, '2024-01-10', 'admin', NULL, NULL)
ON CONFLICT DO NOTHING;
INSERT INTO public.common_code (code_no, code_name, upper_no, upper_name, sort_order, is_used, description,
sub_description, created_at, created_by, modified_at, modified_by)
VALUES (68, 'AGE_99', 51, NULL, 6, true, '변경필요', NULL, '2024-01-10', 'admin', NULL, NULL)
ON CONFLICT DO NOTHING;

UPDATE public.common_code
SET code_name='MALE',
modified_at = CURRENT_TIMESTAMP,
modified_by = 'admin'
WHERE code_no = 49
;

UPDATE public.common_code
SET code_name='FEMALE',
modified_at = CURRENT_TIMESTAMP,
modified_by = 'admin'
WHERE code_no = 50
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.kernel360.member.entity;

import com.kernel360.base.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Table(name = "withdraw_member")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class WithdrawMember extends BaseEntity {

@Id
@Column(name = "member_no", nullable = false)
private Long memberNo;

@Column(name = "id", nullable = false, updatable = false)
private String id;

@Column(name = "email", nullable = false)
private String email;

@Column(name="ip")
private String ip;


public static WithdrawMember of(Long memberNo, String id, String email, String ip) {

return new WithdrawMember(memberNo, id, email, ip);
}

private WithdrawMember(
Long memberNo,
String id,
String email,
String ip
) {
this.memberNo = memberNo;
this.id = id;
this.email = email;
this.ip = ip;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.kernel360.member.repository;

import com.kernel360.member.entity.WithdrawMember;
import jakarta.persistence.Id;
import org.springframework.data.jpa.repository.JpaRepository;

public interface WithdrawMemberRepository extends JpaRepository<WithdrawMember, Id> {
}

0 comments on commit 9f8051d

Please sign in to comment.