mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 18:20:50 +00:00
added BatchDelete action
This commit is contained in:
@@ -139,10 +139,11 @@ func UpdateConfig(c *gin.Context) {
|
|||||||
// @Router /api/v1/config/{configId} [delete]
|
// @Router /api/v1/config/{configId} [delete]
|
||||||
func DeleteConfig(c *gin.Context) {
|
func DeleteConfig(c *gin.Context) {
|
||||||
var data models.SysConfig
|
var data models.SysConfig
|
||||||
id, err := tools.StringToInt(c.Param("configId"))
|
|
||||||
data.UpdateBy = tools.GetUserIdStr(c)
|
data.UpdateBy = tools.GetUserIdStr(c)
|
||||||
data.ConfigId = id
|
IDS := tools.IdsStrToIdsIntGroup("configId", c)
|
||||||
_, err = data.Delete()
|
result, err := data.BatchDelete(IDS)
|
||||||
tools.HasError(err, "修改失败", 500)
|
tools.HasError(err, "修改失败", 500)
|
||||||
app.OK(c, nil, msg.DeletedSuccess)
|
app.OK(c, result, msg.DeletedSuccess)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -144,12 +144,9 @@ func UpdateDictData(c *gin.Context) {
|
|||||||
// @Router /api/v1/dict/data/{dictCode} [delete]
|
// @Router /api/v1/dict/data/{dictCode} [delete]
|
||||||
func DeleteDictData(c *gin.Context) {
|
func DeleteDictData(c *gin.Context) {
|
||||||
var data models.DictData
|
var data models.DictData
|
||||||
id, err := tools.StringToInt(c.Param("dictCode"))
|
|
||||||
data.UpdateBy = tools.GetUserIdStr(c)
|
data.UpdateBy = tools.GetUserIdStr(c)
|
||||||
_, err = data.Delete(id)
|
IDS := tools.IdsStrToIdsIntGroup("dictCode", c)
|
||||||
|
result, err := data.BatchDelete(IDS)
|
||||||
tools.HasError(err, "修改失败", 500)
|
tools.HasError(err, "修改失败", 500)
|
||||||
|
app.OK(c,result,"删除成功")
|
||||||
var res app.Response
|
|
||||||
res.Msg = "删除成功"
|
|
||||||
c.JSON(http.StatusOK, res.ReturnOK())
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ func GetDictType(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, res.ReturnOK())
|
c.JSON(http.StatusOK, res.ReturnOK())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func GetDictTypeOptionSelect(c *gin.Context) {
|
func GetDictTypeOptionSelect(c *gin.Context) {
|
||||||
var DictType models.DictType
|
var DictType models.DictType
|
||||||
DictType.DictName = c.Request.FormValue("dictName")
|
DictType.DictName = c.Request.FormValue("dictName")
|
||||||
@@ -136,13 +135,10 @@ func UpdateDictType(c *gin.Context) {
|
|||||||
// @Router /api/v1/dict/type/{dictId} [delete]
|
// @Router /api/v1/dict/type/{dictId} [delete]
|
||||||
func DeleteDictType(c *gin.Context) {
|
func DeleteDictType(c *gin.Context) {
|
||||||
var data models.DictType
|
var data models.DictType
|
||||||
id, err := tools.StringToInt(c.Param("dictId"))
|
|
||||||
data.UpdateBy = tools.GetUserIdStr(c)
|
data.UpdateBy = tools.GetUserIdStr(c)
|
||||||
_, err = data.Delete(id)
|
IDS := tools.IdsStrToIdsIntGroup("dictId", c)
|
||||||
|
result, err := data.BatchDelete(IDS)
|
||||||
tools.HasError(err, "修改失败", 500)
|
tools.HasError(err, "修改失败", 500)
|
||||||
|
app.OK(c, result, "删除成功")
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"code": 200,
|
|
||||||
"message": "删除成功",
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -106,9 +106,9 @@ func UpdatePost(c *gin.Context) {
|
|||||||
// @Router /api/v1/post/{postId} [delete]
|
// @Router /api/v1/post/{postId} [delete]
|
||||||
func DeletePost(c *gin.Context) {
|
func DeletePost(c *gin.Context) {
|
||||||
var data models.Post
|
var data models.Post
|
||||||
id, err := tools.StringToInt(c.Param("postId"))
|
|
||||||
data.UpdateBy = tools.GetUserIdStr(c)
|
data.UpdateBy = tools.GetUserIdStr(c)
|
||||||
_, err = data.Delete(id)
|
IDS := tools.IdsStrToIdsIntGroup("postId", c)
|
||||||
|
result, err := data.BatchDelete(IDS)
|
||||||
tools.HasError(err, "删除失败", 500)
|
tools.HasError(err, "删除失败", 500)
|
||||||
app.OK(c,"","删除成功")
|
app.OK(c,result,"删除成功")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,3 +105,11 @@ func (e *SysConfig) Delete() (success bool, err error) {
|
|||||||
success = true
|
success = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *SysConfig) BatchDelete(id []int) (Result bool, err error) {
|
||||||
|
if err = orm.Eloquent.Table(e.TableName()).Where("config_id in (?)", id).Delete(&SysConfig{}).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Result = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -193,7 +193,7 @@ func (e *Dept) Update(id int) (update Dept, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Dept) Delete(id int) (success bool, err error) {
|
func (e *Dept) Delete(id int) (success bool, err error) {
|
||||||
if err = orm.Eloquent.Table(e.TableName()).Where("dept_id = ?", e.DeptId).Delete(&Dept{}).Error; err != nil {
|
if err = orm.Eloquent.Table(e.TableName()).Where("dept_id = ?", id).Delete(&Dept{}).Error; err != nil {
|
||||||
success = false
|
success = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,3 +131,12 @@ func (e *DictData) Delete(id int) (success bool, err error) {
|
|||||||
success = true
|
success = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *DictData) BatchDelete(id []int) (Result bool, err error) {
|
||||||
|
if err = orm.Eloquent.Table(e.TableName()).Where("dict_code in (?)", id).Delete(&DictData{}).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Result = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,3 +119,11 @@ func (e *DictType) Delete(id int) (success bool, err error) {
|
|||||||
success = true
|
success = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *DictType) BatchDelete(id []int) (Result bool, err error) {
|
||||||
|
if err = orm.Eloquent.Table(e.TableName()).Where("dict_id in (?)", id).Delete(&DictType{}).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Result = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -129,3 +129,11 @@ func (e *Post) Delete(id int) (success bool, err error) {
|
|||||||
success = true
|
success = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Post) BatchDelete(id []int) (Result bool, err error) {
|
||||||
|
if err = orm.Eloquent.Table(e.TableName()).Where("post_id in (?)", id).Delete(&Post{}).Error; err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Result = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user