功能:增加平台账号管理与管理员保护

This commit is contained in:
yml2213
2026-08-13 12:52:50 +08:00
parent 8c47b961e1
commit 2b3a1b111b
8 changed files with 167 additions and 10 deletions
+17 -5
View File
@@ -4,6 +4,7 @@ import (
"strconv"
"affiliate_dash/internal/middleware"
"affiliate_dash/internal/model"
"affiliate_dash/internal/pkg/response"
"affiliate_dash/internal/service"
@@ -22,11 +23,13 @@ func (h *UserHandler) List(c *gin.Context) {
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
size, _ := strconv.Atoi(c.DefaultQuery("size", "20"))
q := service.UserListQuery{
MerchantID: middleware.GetMerchantID(c),
Page: page,
Size: size,
Keyword: c.Query("keyword"),
Role: c.Query("role"),
Page: page,
Size: size,
Keyword: c.Query("keyword"),
Role: c.Query("role"),
}
if middleware.GetRole(c) != model.RoleAdmin {
q.MerchantID = middleware.GetMerchantID(c)
}
if s := c.Query("status"); s != "" {
v, _ := strconv.Atoi(s)
@@ -78,3 +81,12 @@ func (h *UserHandler) UpdateStatus(c *gin.Context) {
}
response.OK(c, nil)
}
func (h *UserHandler) Delete(c *gin.Context) {
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
if err := h.svc.Delete(uint(id), middleware.GetUserID(c)); err != nil {
response.BadRequest(c, err.Error())
return
}
response.OK(c, nil)
}