update
This commit is contained in:
@@ -97,6 +97,25 @@ func (h *Handler) Delete(c *gin.Context) {
|
||||
response.OK(c, nil)
|
||||
}
|
||||
|
||||
// UpdateStatus 更新小程序状态(0 禁用、1 启用)。
|
||||
func (h *Handler) UpdateStatus(c *gin.Context) {
|
||||
id, ok := parseID(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req miniappsvc.StatusReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.Error(errors.ErrBadRequest)
|
||||
return
|
||||
}
|
||||
m, err := h.svc.UpdateStatus(c.Request.Context(), id, req.Status)
|
||||
if err != nil {
|
||||
c.Error(err)
|
||||
return
|
||||
}
|
||||
response.OK(c, m)
|
||||
}
|
||||
|
||||
// parseID 从路径参数解析并校验 uint64 主键。
|
||||
func parseID(c *gin.Context) (uint64, bool) {
|
||||
id, err := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
@@ -117,5 +136,6 @@ func Register(g *gin.RouterGroup, h *Handler) {
|
||||
rg.GET("/:id", middleware.RequirePerm(middleware.PermMiniView), h.Get)
|
||||
rg.GET("", middleware.RequirePerm(middleware.PermMiniView), h.List)
|
||||
rg.DELETE("/:id", middleware.RequirePerm(middleware.PermMiniManage), h.Delete)
|
||||
rg.PUT("/:id/status", middleware.RequirePerm(middleware.PermMiniManage), h.UpdateStatus)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user