优化删除

This commit is contained in:
yml2213
2026-06-19 17:26:37 +08:00
parent 076ac6098e
commit 2df935f74c
6 changed files with 193 additions and 17 deletions
@@ -44,6 +44,23 @@ func (h *Handler) BatchCreateQrCodeHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": qrcodes})
}
// BatchDeleteQrCodeHandler 批量删除二维码
func (h *Handler) BatchDeleteQrCodeHandler(c *gin.Context) {
var req BatchDeleteQrCodeRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
deleted, err := h.service.repo.BatchDeleteQrCodes(c.Request.Context(), req.IDs)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"data": gin.H{"deleted": deleted}})
}
// ListQrCodesHandler 列表查询二维码
func (h *Handler) ListQrCodesHandler(c *gin.Context) {
var req QrCodeListRequest
@@ -157,10 +174,6 @@ func (h *Handler) DeleteQrCodeHandler(c *gin.Context) {
c.JSON(http.StatusNotFound, gin.H{"error": "二维码不存在"})
return
}
if err == ErrQrCodeCannotDelete {
c.JSON(http.StatusBadRequest, gin.H{"error": "已使用的二维码不能删除"})
return
}
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}