Version: 0.2.5.dev.260211
feat: 🗑️ 新增删除任务类接口并实现级联删除 - 通过 task_class 与 task_item 两张表建立级联关系 🔗 - 删除 task_class 时自动删除关联的 task_item - 保证数据一致性,避免产生孤立数据 ✅
This commit is contained in:
@@ -218,3 +218,16 @@ func (dao *TaskClassDAO) DeleteTaskClassItemByID(ctx context.Context, id int) er
|
||||
Delete(&model.TaskClassItem{}).Error
|
||||
return err
|
||||
}
|
||||
|
||||
func (dao *TaskClassDAO) DeleteTaskClassByID(ctx context.Context, id int) error {
|
||||
res := dao.db.WithContext(ctx).
|
||||
Where("id = ?", id).
|
||||
Delete(&model.TaskClass{})
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
if res.RowsAffected == 0 {
|
||||
return respond.WrongTaskClassID
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user