|
@@ -4,7 +4,9 @@ namespace app\admin\logic;
|
|
|
|
|
|
use app\model\CommonModel;
|
|
|
use app\model\VideoGroupModel;
|
|
|
+use think\Exception;
|
|
|
use think\exception\ValidateException;
|
|
|
+use think\facade\Db;
|
|
|
use think\response\Json;
|
|
|
|
|
|
class VideoGroupLogic extends BaseLogic
|
|
@@ -128,17 +130,32 @@ class VideoGroupLogic extends BaseLogic
|
|
|
//删除视频分组
|
|
|
public static function delete(array $ids = []): Json
|
|
|
{
|
|
|
- $res = VideoGroupModel::whereIn('id', $ids)
|
|
|
- ->where('is_del', CommonModel::$del_normal)
|
|
|
- ->save([
|
|
|
- 'is_del' => CommonModel::$del_deleted,
|
|
|
- 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
- 'updaterid' => self::$uid,
|
|
|
- 'updater' => self::$uid
|
|
|
- ]);
|
|
|
-
|
|
|
- return $res ? json_show(CommonModel::$success, '删除成功') : json_show(CommonModel::$error_param, '删除失败,该视频分组不存在');
|
|
|
-
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ VideoGroupModel::whereIn('id', $ids)
|
|
|
+ ->where('is_del', CommonModel::$del_normal)
|
|
|
+ ->save([
|
|
|
+ 'is_del' => CommonModel::$del_deleted,
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
+ 'updaterid' => self::$uid,
|
|
|
+ 'updater' => self::$uid
|
|
|
+ ]);
|
|
|
+
|
|
|
+ Db::name('video_group_item')
|
|
|
+ ->whereIn('video_group_id', $ids)
|
|
|
+ ->where('is_del', CommonModel::$del_normal)
|
|
|
+ ->save([
|
|
|
+ 'is_del' => CommonModel::$del_deleted,
|
|
|
+ 'updatetime' => date('Y-m-d H:i:s'),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ return json_show(CommonModel::$success, '删除成功');
|
|
|
+ } catch (Exception $exception) {
|
|
|
+ Db::rollback();
|
|
|
+ return json_show(CommonModel::$error_param, '删除失败,' . $exception->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//视频分组置顶
|