feat: add hosted message
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"message-nest/pkg/app"
|
||||
"message-nest/pkg/util"
|
||||
"message-nest/service/hosted_message_service"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GetHostMessageList 获取托管消息列表
|
||||
func GetHostMessageList(c *gin.Context) {
|
||||
appG := app.Gin{C: c}
|
||||
text := c.Query("text")
|
||||
|
||||
offset, limit := util.GetPageSize(c)
|
||||
messageService := hosted_message_service.HostMessageService{
|
||||
Text: text,
|
||||
PageNum: offset,
|
||||
PageSize: limit,
|
||||
}
|
||||
ways, err := messageService.GetAll()
|
||||
if err != nil {
|
||||
appG.CResponse(http.StatusInternalServerError, "获取托管消息失败!", nil)
|
||||
return
|
||||
}
|
||||
|
||||
count, err := messageService.Count()
|
||||
if err != nil {
|
||||
appG.CResponse(http.StatusInternalServerError, "获取托管消息总数失败!", nil)
|
||||
return
|
||||
}
|
||||
|
||||
appG.CResponse(http.StatusOK, "获取托管消息成功", map[string]interface{}{
|
||||
"lists": ways,
|
||||
"total": count,
|
||||
})
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func GetMsgSendWayList(c *gin.Context) {
|
||||
type AddMsgSendWayReq struct {
|
||||
Name string `json:"name" validate:"required,max=100,min=1" label:"渠道名"`
|
||||
Type string `json:"type" validate:"required,max=100,min=1" label:"渠道类型"`
|
||||
Auth string `json:"auth" validate:"required,max=2048,min=6" label:"渠道认证方式"`
|
||||
Auth string `json:"auth" label:"渠道认证方式"`
|
||||
}
|
||||
|
||||
// AddMsgSendWay 添加发送渠道
|
||||
|
||||
@@ -91,6 +91,9 @@ func InitRouter(f embed.FS) *gin.Engine {
|
||||
apiV1.POST("/cronmessages/delete", v1.DeleteCronMsgTask)
|
||||
apiV1.POST("/cronmessages/edit", v1.EditCronMsgTask)
|
||||
|
||||
// hostedMessage
|
||||
apiV1.GET("/hostedmessages/list", v1.GetHostMessageList)
|
||||
|
||||
}
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user