first commit

This commit is contained in:
2026-09-11 01:47:20 +08:00
commit 303207d3cc
74 changed files with 8348 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
package v1
import (
"git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/internal/dto"
"git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/internal/middleware"
"git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/internal/service"
"git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/pkg/app"
"git.lzcwy.cn/zhengchiliu/zt-closet-manage-backend/pkg/errcode"
"github.com/gin-gonic/gin"
)
// NotificationHandler 通知推送接口。
type NotificationHandler struct {
svc *service.NotificationService
}
// NewNotificationHandler 创建通知 handler。
func NewNotificationHandler() *NotificationHandler {
return &NotificationHandler{svc: service.NewNotificationService()}
}
// Send 向单个用户发送系统通知。
func (h *NotificationHandler) Send(c *gin.Context) {
response := app.NewResponse(c)
var request dto.NotificationSendRequest
if err := c.ShouldBindJSON(&request); err != nil {
response.ToErrorResponse(errcode.InvalidParams.WithDetails(err.Error()))
return
}
adminID, _ := middleware.GetAdminID(c.Request.Context())
if e := h.svc.Send(c.Request.Context(), adminID, &request); e != nil {
response.ToErrorResponse(e)
return
}
response.ToResponse(nil)
}
// Broadcast 全量广播系统通知。
func (h *NotificationHandler) Broadcast(c *gin.Context) {
response := app.NewResponse(c)
var request dto.NotificationBroadcastRequest
if err := c.ShouldBindJSON(&request); err != nil {
response.ToErrorResponse(errcode.InvalidParams.WithDetails(err.Error()))
return
}
adminID, _ := middleware.GetAdminID(c.Request.Context())
out, e := h.svc.Broadcast(c.Request.Context(), adminID, &request)
if e != nil {
response.ToErrorResponse(e)
return
}
response.ToResponse(out)
}