Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: account 및 project 기본 구성 및 구조 변경 #16

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b323faa
feat: util 폴더 및 기본적인 유틸 함수 추가
2rebi Feb 27, 2021
805b794
feat: 로컬 bus(게이트웨이), pubsub(큐는 존재 x) 추가
2rebi Feb 27, 2021
11f09b8
feat: entgo initialize 및 account schema 생성 및 필드(column) 타입 정의
2rebi Feb 27, 2021
c8bc50d
feat(account-query): 소셜 로그인 가입정보를 찾는 쿼리
2rebi Feb 27, 2021
557867a
feat(account-application): 계정 생성, 수정, 삭제 커맨드 및 이벤트 모델 추가
2rebi Feb 27, 2021
7628f04
feat(account-domain): 레파지토리 인터페이스 추가
2rebi Feb 27, 2021
23978a9
feat(account-infra): 레파지토리 구현
2rebi Feb 27, 2021
f50b939
feat(di, config): 환경 변수, wire(di) 기초 공사, go generate를 사용하는 모든 generat…
2rebi Feb 27, 2021
656da40
chore: 라이브러리 의존성 다운로드 및 di를 이용한 repository 가져오는 예시 추가
2rebi Feb 27, 2021
91c047e
chore: git ignore .idea
kyhsa93 Feb 27, 2021
70b6b52
wip
kyhsa93 Feb 27, 2021
689918a
ci: makefile init
2rebi Mar 2, 2021
38139e4
chore: 불필요한 파일 제거
2rebi Mar 2, 2021
52935b1
feat: 구글 토큰 인증 API
2rebi Mar 2, 2021
f85c58a
feat: 카카오 인증, 프로필 가져오기 API
2rebi Mar 2, 2021
4c00392
refactor: 불필요한 코드 제거
2rebi Mar 3, 2021
ac6d23b
feat: wip
2rebi Mar 4, 2021
2442c58
refactor: scaffolding
kyhsa93 Mar 5, 2021
cb6b5da
feat(account): repository complete, social adapter(google, kakao) com…
2rebi Mar 7, 2021
28d729b
fix: bus return nil 일때 exception 나는 부분 해결
2rebi Mar 9, 2021
ed66f4f
refactor: account 테이블명 명시
2rebi Mar 9, 2021
3583a14
refactor: social 어뎁터 인터페이스 도메인으로 이동 및 변경 된 패키지명 적용 (app -> domain)
2rebi Mar 9, 2021
9ba89a2
feat: di 적용
2rebi Mar 9, 2021
cbe3565
refactor: 어카운트 딥카피 부분 코드 정리
2rebi Mar 9, 2021
a9e1e8e
feat: 토큰 발행 및 소셜 어뎁터 파편화된 부분 소셜서비스로 묶음
2rebi Mar 9, 2021
6904669
feat: 값을 가져오는 기능 추가
2rebi Mar 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
meonzi
.idea
go.sum
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ifndef binary
binary=debug
endif

test:
go test -v -cover -covermode=atomic ./...

mod-download:
go mod download

generate:
bash ./generate.sh

build:
go build -o ${binary} .

unittest:
go test -short ./...

clean:
if [ -f ${binary} ] ; then rm ${binary} ; fi

lint-prepare:
@echo "Installing golangci-lint"
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s latest

lint:
./bin/golangci-lint run \
--exclude-use-default=false \
--enable=golint \
--enable=gocyclo \
--enable=goconst \
--enable=unconvert \
./...
76 changes: 0 additions & 76 deletions account/api/controller.go

This file was deleted.

107 changes: 107 additions & 0 deletions account/app/command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package app

import (
"context"
"errors"
"github/four-servings/meonzi/account/domain"
"github/four-servings/meonzi/pipe"
"time"

"golang.org/x/sync/errgroup"

"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)

type (
CommandBus interface {
pipe.Bus
}

commandHandler struct {
domain.AccountRepository
domain.SocialService
}
)

func NewCommandBus(accountRepo domain.AccountRepository, socialService domain.SocialService, timeout time.Duration) (bus CommandBus) {
handler := commandHandler{accountRepo, socialService}
bus = pipe.NewBusWithTimeout(timeout)

g, _ := errgroup.WithContext(context.Background())
g.Go(func() error {
return bus.RegistryHandler(RegisterAccountCommand{}, handler.RegisterAccountHandle)
})
g.Go(func() error {
return bus.RegistryHandler(DeregisterAccountCommand{}, handler.DeregisterAccountHandle)
})
err := g.Wait()
if err != nil {
panic(err)
}

return
}

type RegisterAccountCommand struct {
Name string
Token string
Provider domain.AuthProvider
}

func (ch *commandHandler) RegisterAccountHandle(ctx context.Context, command RegisterAccountCommand) (err error) {
id, err := ch.AccountRepository.FindNewID(ctx)
if err != nil {
log.WithError(err).Error("Can not get new account ID")
return
}

thirdUser, err := ch.SocialService.GetUser(ctx, command.Provider, command.Token)
if err != nil {
log.WithError(err).Errorf("Can not fetch %s user", command.Provider)
return
}

exists, _ := ch.AccountRepository.FindByProviderAndSocialID(ctx, command.Provider, command.Token)
if exists != nil {
err = errors.New("exists account")
log.Error("Account is exists")
return
}

account := domain.NewAccount(domain.NewAccountOptions{
ID: id,
Name: command.Name,
AuthProvider: thirdUser.AuthProvider(),
SocialID: thirdUser.ID(),
})

account, err = ch.AccountRepository.Save(ctx, account)
if err != nil {
log.WithError(err).Error("Can not save account")
return
}

return nil
}

type DeregisterAccountCommand struct {
ID uuid.UUID
}

//TODO refactor, error handling on http handler
func (ch *commandHandler) DeregisterAccountHandle(ctx context.Context, command DeregisterAccountCommand) error {
account, err := ch.AccountRepository.FindByID(ctx, command.ID)
if err != nil {
log.WithError(err).Error("Can not found account")
}

account.Deregister()

account, err = ch.AccountRepository.Save(ctx, account)
if err != nil {
log.WithError(err).Error("Can not save account")
}

return nil
}
34 changes: 0 additions & 34 deletions account/app/command/bus.go

This file was deleted.

30 changes: 0 additions & 30 deletions account/app/command/create.go

This file was deleted.

13 changes: 13 additions & 0 deletions account/app/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app

import (
"github/four-servings/meonzi/pipe"
)

type EventPublisher interface {
pipe.PubSub
}

func NewEventPublisher() EventPublisher {
return pipe.NewPubSub()
}
36 changes: 0 additions & 36 deletions account/app/query/bus.go

This file was deleted.

36 changes: 0 additions & 36 deletions account/app/query/find.go

This file was deleted.

Loading