📄️ 5.1 Preface
This chapter explores two features of the Star English Book, where users can randomly retrieve words for review and set the level of word mastery to better clarify their review targets. These two functions allow users to have a clearer plan for word learning. At the same time, we delve into RESTful related technologies to enhance the richness and practicality of the interfaces.
📄️ 5.2 Randomly Retrieve Words
Design a random word retrieval API using the GoFrame framework. Provide a path words/rand API that supports retrieving a limited number of words between 1 and 300. Use OrderRandom for random queries and Limit to restrict the number of results. The controller calls the logic to process query results and conducts API testing to verify the functionality.
📄️ 5.3 Set Proficiency Level
Implement the function to set the word proficiency level using the GoFrame framework. Use the PATCH method to modify the ProficiencyLevel field and introduce parameter validation to ensure the level is between 1 and 5. The designed API route style follows the resource hierarchy relationship, and it is recommended to use the form words/{id}/level. Complete the level setting through database updates, providing an interface test example to verify the correctness of the function.
📄️ 5.4 Summary
This chapter developed functions for obtaining random words and understanding RESTful through the PATCH method. This includes random query techniques and enhances understanding of the RESTful architecture through practice, helping users apply and master related programming techniques in the process of learning words.