words_v1_update.go 614 B

12345678910111213141516171819202122232425
  1. package words
  2. import (
  3. "context"
  4. v1 "star/api/words/v1"
  5. "star/internal/logic/words"
  6. )
  7. func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
  8. uid, err := c.users.GetUid(ctx)
  9. if err != nil {
  10. return nil, err
  11. }
  12. err = c.words.Update(ctx, req.Id, words.UpdateInput{
  13. Uid: uid,
  14. Word: req.Word,
  15. Definition: req.Definition,
  16. ExampleSentence: req.ExampleSentence,
  17. ChineseTranslation: req.ChineseTranslation,
  18. Pronunciation: req.Pronunciation,
  19. ProficiencyLevel: req.ProficiencyLevel,
  20. })
  21. return nil, err
  22. }