words_v1_detail.go 735 B

12345678910111213141516171819202122232425262728293031
  1. package words
  2. import (
  3. "context"
  4. v1 "star/api/words/v1"
  5. )
  6. func (c *ControllerV1) Detail(ctx context.Context, req *v1.DetailReq) (res *v1.DetailRes, err error) {
  7. uid, err := c.users.GetUid(ctx)
  8. if err != nil {
  9. return nil, err
  10. }
  11. word, err := c.words.Detail(ctx, uid, req.Id)
  12. if err != nil {
  13. return nil, err
  14. }
  15. return &v1.DetailRes{
  16. Id: word.Id,
  17. Word: word.Word,
  18. Definition: word.Definition,
  19. ExampleSentence: word.ExampleSentence,
  20. ChineseTranslation: word.ChineseTranslation,
  21. Pronunciation: word.Pronunciation,
  22. ProficiencyLevel: v1.ProficiencyLevel(word.ProficiencyLevel),
  23. CreatedAt: word.CreatedAt,
  24. UpdatedAt: word.UpdatedAt,
  25. }, nil
  26. }