Enhance smoking tracking API with new features and improvements
- Added a new API endpoint `GET /api/v1/smoke/home` to consolidate core modules for the home dashboard, reducing the need for multiple requests. - Updated the `smoke` routes to include the new home endpoint and improved user profile management with the addition of a `quit_date` field. - Enhanced the algorithm for calculating daily targets and next smoke suggestions, ensuring accurate future time handling and user-specific recommendations. - Improved API documentation to reflect new endpoints, response formats, and detailed field descriptions for better clarity and usability. - Refactored user authentication handling in various handlers to streamline the process and ensure consistent error responses.
This commit is contained in:
@@ -19,11 +19,7 @@ type unlockAIAdviceRequest struct {
|
||||
}
|
||||
|
||||
func (h *SmokeHandler) GetAIAdvice(c *gin.Context) {
|
||||
user, ok := middleware.CurrentUser(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusUnauthorized, model.Error(http.StatusUnauthorized, "未登录或登录已过期"))
|
||||
return
|
||||
}
|
||||
user := middleware.MustCurrentUser(c)
|
||||
|
||||
dateStr := c.Query("date")
|
||||
adviceDate := yesterdayDate()
|
||||
@@ -61,11 +57,7 @@ func (h *SmokeHandler) GetAIAdvice(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (h *SmokeHandler) UnlockAIAdvice(c *gin.Context) {
|
||||
user, ok := middleware.CurrentUser(c)
|
||||
if !ok {
|
||||
c.JSON(http.StatusUnauthorized, model.Error(http.StatusUnauthorized, "未登录或登录已过期"))
|
||||
return
|
||||
}
|
||||
user := middleware.MustCurrentUser(c)
|
||||
|
||||
var req unlockAIAdviceRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil && !errors.Is(err, io.EOF) {
|
||||
|
||||
Reference in New Issue
Block a user