feat: License 支持筛选多选批量删除

仅已吊销或已过期可删,有效授权自动跳过;单条删除同步限制。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Logan.LiandCursor committed 2026-08-12 21:53:34 +08:00
1 parent f26e787cfc
commit d0e1ca3729
6 files changed
+152 -9

No files matched your search

@@ -135,7 +135,7 @@ func (ctrl *LicenseController) Update(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"code": 0, "message": "更新成功", "data": lic})
}
// Delete 删除 License // Logan.Li
// Delete 删除 License(仅已吊销/已过期) // Logan.Li
func (ctrl *LicenseController) Delete(c *gin.Context) {
id, _ := strconv.ParseUint(c.Param("id"), 10, 32)
lic, err := ctrl.svc.Delete(uint(id))
@@ -147,6 +147,32 @@ func (ctrl *LicenseController) Delete(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"code": 0, "message": "删除成功"})
}
// BatchDelete 批量删除:非吊销/未到期自动跳过 // Logan.Li
func (ctrl *LicenseController) BatchDelete(c *gin.Context) {
var req dto.LicenseBatchDeleteRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"code": 400, "message": "参数错误: 请提供 ids"})
return
}
result, err := ctrl.svc.BatchDelete(req.IDs)
if err != nil {
c.JSON(http.StatusOK, gin.H{"code": 1, "message": err.Error()})
return
}
utils.LogAction(ctrl.db, c, "batch_delete", "license", 0, "", "", "",
"批量删除 License deleted="+strconv.Itoa(result.Deleted)+" skipped="+strconv.Itoa(result.Skipped))
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "批量删除完成",
"data": dto.LicenseBatchDeleteResponse{
Deleted: result.Deleted,
Skipped: result.Skipped,
Failed: result.Failed,
SkippedIDs: result.SkippedIDs,
},
})
}
// Renew 续期 // Logan.Li
func (ctrl *LicenseController) Renew(c *gin.Context) {
id, _ := strconv.ParseUint(c.Param("id"), 10, 32)