Executable
+74
@@ -0,0 +1,74 @@
|
||||
package immessagectrl
|
||||
|
||||
import (
|
||||
"91porn-server/app/service/immessageser"
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/stderr"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// List doc
|
||||
//
|
||||
// @Summary 获取im消息列表接口
|
||||
// @Description 获取im消息列表
|
||||
// @Tags 移动端-im消息
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q query immessageser.AppQueryListReq false "请求参数"
|
||||
// @Success 200 object immessageser.AppListRes "成功"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/app/immessage/list [get]
|
||||
func List(ctx *gin.Context) {
|
||||
p := &immessageser.AppQueryListReq{}
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取用户当前配置
|
||||
// var err error
|
||||
// p.Uid, err = common.GetUID(ctx)
|
||||
// if err != nil {
|
||||
// common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
list := p.GetList()
|
||||
common.ServeJSON(ctx, stderr.Success, list)
|
||||
}
|
||||
|
||||
// Send doc
|
||||
// @Summary 发送im消息
|
||||
// @Description 发送im消息
|
||||
// @Tags 移动端-im消息
|
||||
// @Accept mpfd,json
|
||||
// @Produce json
|
||||
// @Param q body immessageser.SendReq false "请求参数"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /api/app/immessage/send [post]
|
||||
func Send(ctx *gin.Context) {
|
||||
uid, err := common.GetUID(ctx)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrNoToken, err)
|
||||
return
|
||||
}
|
||||
|
||||
p := &immessageser.SendReq{}
|
||||
err = ctx.ShouldBindJSON(&p)
|
||||
if err != nil {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
||||
return
|
||||
}
|
||||
if p.Content == "" && p.Image == "" {
|
||||
common.ServeJSON(ctx, stderr.ErrParamError, nil)
|
||||
return
|
||||
}
|
||||
// 创建
|
||||
err = p.Create(uid)
|
||||
if err != nil {
|
||||
common.ServeError(ctx, err)
|
||||
return
|
||||
}
|
||||
common.ServeJSON(ctx, stderr.Success, "")
|
||||
}
|
||||
Reference in New Issue
Block a user