fix: mysql 数据库删除增加使用判断

This commit is contained in:
ssongliu
2022-12-04 17:28:03 +08:00
committed by ssongliu
parent 8a78657519
commit 1c4da6d88b
7 changed files with 126 additions and 39 deletions

View File

@@ -145,18 +145,29 @@ func (b *BaseApi) RecoverMysql(c *gin.Context) {
helper.SuccessWithData(c, nil)
}
func (b *BaseApi) DeleteMysql(c *gin.Context) {
var req dto.BatchDeleteReq
if err := c.ShouldBindJSON(&req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
return
}
if err := global.VALID.Struct(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
func (b *BaseApi) DeleteCheckMysql(c *gin.Context) {
id, err := helper.GetParamID(c)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
return
}
if err := mysqlService.Delete(req.Ids); err != nil {
apps, err := mysqlService.DeleteCheck(id)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, apps)
}
func (b *BaseApi) DeleteMysql(c *gin.Context) {
id, err := helper.GetParamID(c)
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil)
return
}
if err := mysqlService.Delete(id); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}