|
|
@@ -248,3 +248,80 @@ func RemoveUserFavoriteGoods(c *gin.Context) {
|
|
|
logger.GetLogger().Debugln("RemoveUserFavoriteGoods successed: %v", "ok")
|
|
|
appG.Response(http.StatusOK, e.SUCCESS, "")
|
|
|
}
|
|
|
+
|
|
|
+// QueryMessageBoardReq 获取用户留言板信息请求参数
|
|
|
+type QueryMessageBoardReq struct {
|
|
|
+ UserID int `form:"userID" binding:"required"`
|
|
|
+}
|
|
|
+
|
|
|
+// QueryMessageBoard 获取用户留言板信息
|
|
|
+// @Summary 获取用户留言板信息
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param userID query int true "用户ID"
|
|
|
+// @Success 200 {bool} models.Messageboard
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
+// @Router /User/QueryMessageBoard [get]
|
|
|
+// @Tags 用户信息
|
|
|
+func QueryMessageBoard(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+
|
|
|
+ // 获取请求参数
|
|
|
+ var req QueryMessageBoardReq
|
|
|
+ if err := appG.C.ShouldBindQuery(&req); err != nil {
|
|
|
+ logger.GetLogger().Errorf("QueryMessageBoard failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ messageBoards, err := models.GetMessageBoard(req.UserID)
|
|
|
+ if err != nil {
|
|
|
+ // 查询失败
|
|
|
+ logger.GetLogger().Errorf("QueryMessageBoard failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询成功
|
|
|
+ logger.GetLogger().Debugln("QueryMessageBoard successed: %v", messageBoards)
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, messageBoards)
|
|
|
+}
|
|
|
+
|
|
|
+// AddMessageBoardReq 添加用户留言板信息请求参数
|
|
|
+type AddMessageBoardReq struct {
|
|
|
+ UserID int `form:"userID" binding:"required"`
|
|
|
+ Message string `form:"message" binding:"required"`
|
|
|
+}
|
|
|
+
|
|
|
+// AddMessageBoard 添加用户留言板信息
|
|
|
+// @Summary 添加用户留言板信息
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param userID query int true "用户ID"
|
|
|
+// @Param message query string true "留言信息"
|
|
|
+// @Success 200 {object} app.Response
|
|
|
+// @Failure 500 {object} app.Response
|
|
|
+// @Router /User/AddMessageBoard [post]
|
|
|
+// @Tags 用户信息
|
|
|
+func AddMessageBoard(c *gin.Context) {
|
|
|
+ appG := app.Gin{C: c}
|
|
|
+
|
|
|
+ // 获取请求参数
|
|
|
+ var req AddMessageBoardReq
|
|
|
+ if err := appG.C.ShouldBind(&req); err != nil {
|
|
|
+ logger.GetLogger().Errorf("AddMessageBoard failed: %s", err.Error())
|
|
|
+ appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if errCode := models.InsertMessageBoard(req.UserID, req.Message); errCode != 0 {
|
|
|
+ // 执行失败
|
|
|
+ logger.GetLogger().Errorf("AddMessageBoard failed: %s", e.GetMsg(errCode))
|
|
|
+ appG.Response(http.StatusBadRequest, errCode, nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行成功
|
|
|
+ logger.GetLogger().Debugln("AddMessageBoard successed: %v", "ok")
|
|
|
+ appG.Response(http.StatusOK, e.SUCCESS, "")
|
|
|
+}
|