|
|
@@ -138,3 +138,113 @@ func GetUserAuthStatus(c *gin.Context) {
|
|
|
logger.GetLogger().Debugln("GetUserAuthStatus successed: %v", isAuth)
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, isAuth)
|
|
|
}
|
|
|
+
|
|
|
+// QueryUserFavoriteGoodsesReq 获取用户商品收藏信息请求参数
|
|
|
+type QueryUserFavoriteGoodsesReq struct {
|
|
|
+ UserID int `form:"userID" binding:"required"`
|
|
|
+}
|
|
|
+
|
|
|
+// QueryUserFavoriteGoodses 获取用户商品收藏信息
|
|
|
+// @Summary 获取用户商品收藏信息
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param userID query int true "用户ID"
|
|
|
+// @Success 200 {bool} models.Userfavoritegoods
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
+// @Router /User/QueryUserFavoriteGoodses [get]
|
|
|
+// @Tags 用户信息
|
|
|
+func QueryUserFavoriteGoodses(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+
|
|
|
+ // 获取请求参数
|
|
|
+ var req QueryUserFavoriteGoodsesReq
|
|
|
+ if err := appG.C.ShouldBindQuery(&req); err != nil {
|
|
|
+ logger.GetLogger().Errorf("QueryUserFavoriteGoodses failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ userFavoriteGoodses, err := models.GetUserFavoriteGoodses(req.UserID)
|
|
|
+ if err != nil {
|
|
|
+ // 查询失败
|
|
|
+ logger.GetLogger().Errorf("GetUserAuthStatus failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询成功
|
|
|
+ logger.GetLogger().Debugln("QueryUserFavoriteGoodses successed: %v", userFavoriteGoodses)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, userFavoriteGoodses)
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateUserFavoriteGoodsReq 更新用户商品收藏信息请求参数
|
|
|
+type UpdateUserFavoriteGoodsReq struct {
|
|
|
+ UserID int `form:"userID" binding:"required"`
|
|
|
+ GoodsID int `form:"goodsID" binding:"required"`
|
|
|
+}
|
|
|
+
|
|
|
+// AddUserFavoriteGoods 添加用户商品收藏信息
|
|
|
+// @Summary 添加用户商品收藏信息
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param userID query int true "用户ID"
|
|
|
+// @Param goodsID query int true "商品ID"
|
|
|
+// @Success 200 {object} app.Response
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
+// @Router /User/AddUserFavoriteGoods [post]
|
|
|
+// @Tags 用户信息
|
|
|
+func AddUserFavoriteGoods(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+
|
|
|
+ // 获取请求参数
|
|
|
+ var req UpdateUserFavoriteGoodsReq
|
|
|
+ if err := appG.C.ShouldBind(&req); err != nil {
|
|
|
+ logger.GetLogger().Errorf("AddUserFavoriteGoods failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := models.InsertUserFavoriteGoods(req.UserID, req.GoodsID); err != nil {
|
|
|
+ // 执行失败
|
|
|
+ logger.GetLogger().Errorf("AddUserFavoriteGoods failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行成功
|
|
|
+ logger.GetLogger().Debugln("AddUserFavoriteGoods successed: %v", "ok")
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "")
|
|
|
+}
|
|
|
+
|
|
|
+// RemoveUserFavoriteGoods 移除用户商品收藏信息
|
|
|
+// @Summary 移除用户商品收藏信息
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param userID query int true "用户ID"
|
|
|
+// @Param goodsID query int true "商品ID"
|
|
|
+// @Success 200 {object} app.Response
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
+// @Router /User/RemoveUserFavoriteGoods [post]
|
|
|
+// @Tags 用户信息
|
|
|
+func RemoveUserFavoriteGoods(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+
|
|
|
+ // 获取请求参数
|
|
|
+ var req UpdateUserFavoriteGoodsReq
|
|
|
+ if err := appG.C.ShouldBind(&req); err != nil {
|
|
|
+ logger.GetLogger().Errorf("RemoveUserFavoriteGoods failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := models.DelUserFavoriteGoods(req.UserID, req.GoodsID); err != nil {
|
|
|
+ // 执行失败
|
|
|
+ logger.GetLogger().Errorf("RemoveUserFavoriteGoods failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_OPERATION_FAILED, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行成功
|
|
|
+ logger.GetLogger().Debugln("RemoveUserFavoriteGoods successed: %v", "ok")
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "")
|
|
|
+}
|