words_v1_create.go 606 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) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
  8. uid, err := c.users.GetUid(ctx)
  9. if err != nil {
  10. return nil, err
  11. }
  12. err = c.words.Create(ctx, words.CreateInput{
  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. }