modelとexternalからdomainを作る処理をserviceかhandlerで書きたい

Open
#552 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
go
Domain
backend

Research direction

Start by tracing the handler-service-repository-database/external flow and reviewing infrastructure/traq.go, portal.go, knoq.go, interfaces/external, usecases, and wire.go. Check the build flag situation before editing wire.go. Done means external calls are removed from repositories, services combine models with external data into domains, and the listed package moves and repository signatures are resolved.

Written by the indexing model from the issue text.

Description

今はrepositoryからdomainを返しているためrepositoryの中でexternal(とDB操作のdatabase)を呼んでいる

handler->service->repository->database,external

repositoryではrepository以上のこと(CRUD)をしたくないため、serviceかhandlerでこれをしたい
これをするためにはrepositoryの引数/返り値をdomainからmodelにする必要がありそう

handler->service->(repository->database),external

infrastructure/traq.go,portal.go,knoq.goがinfrastructureにあるのも微妙な気がする
externalって名前も変えていい
wire.goを修正する必要があるので注意 (build flagを立てているため補完が効かない、一時的に外すと良い)

  • interfaces/externalをusecases/externalに移動、infra/{traq,portal,knoq,apiclient}.goをinterfaces/externalに移動
  • 各Repositoryからexternalを抜く
  • 各Serviceにexternal.TraqAPIなどを追加し、ここからexternalを呼ぶようにする
  • Repositoryの返り値(引数はdomainのままでもいいのかも)をmodelにする
  • serviceでmodelとexternalを組み合わせてdomainを返すようにする
Dominant language
Go
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from traPtitech/traPortfolio

All issues in traPtitech/traPortfolio

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.