Slide 29
Slide 29 text
29
/$ͷΞʔΩςΫνϟ
w BQQMJDBUJPO
w υϝΠϯϞσϧɺ%#ɺ֎෦"1*ͳͲͱͷॲཧΛ·ͱΊ
ͯɺΞϓϦέʔγϣϯͱͯ͠ͷػೳΛఏڙ͢Δɻ
w %#͔Βऔಘ
w υϝΠϯΛੜͯ͠ɺϝϞϦ্Ͱૢ࡞
w %#ʹอଘ
BQQMJDBUJPO
IBOEMFS
EPNBJO
*OGSBTUSVDUVSF
func (a app)Buy(uid string, cid int64, amount, rate float64) error {
u, err := a.RepoUser.Get(ctx, uid) // 1. DB͔Βऔಘ
buy := domain.NewBuyOrder(u, cid, amount, rate) 2. υϝΠϯΛੜ
err := buy.Exec(ctx) // 2. υϝΠϯΛϝϞϦ্Ͱૢ࡞
err = a.RepoUser.Save(ctx, u) // 4 DBʹอଘ
return nil
}