功能:增加平台账号管理与管理员保护
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user