|
@@ -3,19 +3,19 @@
|
|
|
namespace app\admin\logic;
|
|
|
|
|
|
use app\model\CommonModel;
|
|
|
-use app\model\VideoGroupModel;
|
|
|
+use app\model\GroupModel;
|
|
|
use think\Exception;
|
|
|
use think\exception\ValidateException;
|
|
|
use think\facade\Db;
|
|
|
use think\response\Json;
|
|
|
|
|
|
-class VideoGroupLogic extends BaseLogic
|
|
|
+class GroupLogic extends BaseLogic
|
|
|
{
|
|
|
|
|
|
- //获取视频分组列表
|
|
|
+ //获取列表
|
|
|
public static function list(array $data = []): Json
|
|
|
{
|
|
|
- $db = VideoGroupModel::alias('a')
|
|
|
+ $db = GroupModel::alias('a')
|
|
|
->leftJoin('company b', 'b.id=a.company_id AND b.is_del=' . CommonModel::$del_normal)
|
|
|
->leftJoin('card c', 'c.id=a.card_id AND c.is_del=' . CommonModel::$del_normal)
|
|
|
->where('a.is_del', CommonModel::$del_normal);
|
|
@@ -26,20 +26,20 @@ class VideoGroupLogic extends BaseLogic
|
|
|
|
|
|
$count = $db->count('a.id');
|
|
|
|
|
|
- $list = $db->field('a.id,b.title company_title,c.title card_title,a.num,a.status,a.addtime,a.is_top')
|
|
|
+ $list = $db->field('a.id,b.title company_title,c.title card_title,a.video_num,a.good_num,a.status,a.addtime')
|
|
|
->page($data['page'], $data['size'])
|
|
|
- ->order(['a.is_top' => 'desc', 'a.id' => 'desc'])
|
|
|
+ ->order(['a.id' => 'desc'])
|
|
|
->select()
|
|
|
->toArray();
|
|
|
|
|
|
- return json_show(CommonModel::$success, '获取视频分组列表成功', ['count' => $count, 'list' => $list]);
|
|
|
+ return json_show(CommonModel::$success, '获取列表成功', ['count' => $count, 'list' => $list]);
|
|
|
}
|
|
|
|
|
|
- //添加视频分组
|
|
|
+ //添加
|
|
|
public static function add(array $data = []): Json
|
|
|
{
|
|
|
|
|
|
- $rs = VideoGroupModel::field('id')
|
|
|
+ $rs = GroupModel::field('id')
|
|
|
->where([
|
|
|
'is_del' => CommonModel::$del_normal,
|
|
|
'company_id' => $data['company_id'],
|
|
@@ -49,9 +49,9 @@ class VideoGroupLogic extends BaseLogic
|
|
|
->isEmpty();
|
|
|
if (!$rs) return json_show(CommonModel::$error_param, '该分组已存在');
|
|
|
|
|
|
- $res = VideoGroupModel::create(array_merge($data, [
|
|
|
- 'num' => 0,
|
|
|
- 'is_top' => CommonModel::$top_no,
|
|
|
+ $res = GroupModel::create(array_merge($data, [
|
|
|
+ 'video_num' => 0,
|
|
|
+ 'good_num' => 0,
|
|
|
'status' => CommonModel::$status_normal,
|
|
|
'is_del' => CommonModel::$del_normal,
|
|
|
'createrid' => self::$uid,
|
|
@@ -62,38 +62,38 @@ class VideoGroupLogic extends BaseLogic
|
|
|
'updatetime' => date('Y-m-d H:i:s'),
|
|
|
]))->save();
|
|
|
|
|
|
- return $res ? json_show(CommonModel::$success, '添加视频分组成功') : json_show(CommonModel::$success, '添加视频分组失败');
|
|
|
+ return $res ? json_show(CommonModel::$success, '添加成功') : json_show(CommonModel::$success, '添加失败');
|
|
|
|
|
|
}
|
|
|
|
|
|
- //获取视频分组详情
|
|
|
+ //获取详情
|
|
|
public static function read(int $id = 0): Json
|
|
|
{
|
|
|
- $res = VideoGroupModel::field(true)
|
|
|
+ $res = GroupModel::field(true)
|
|
|
->where(['id' => $id, 'is_del' => CommonModel::$del_normal])
|
|
|
->findOrEmpty()
|
|
|
->toArray();
|
|
|
|
|
|
- if (empty($res)) throw new ValidateException('该视频分组为空');
|
|
|
+ if (empty($res)) throw new ValidateException('该分组为空');
|
|
|
|
|
|
- return json_show(CommonModel::$success, '获取视频分组详情成功', $res);
|
|
|
+ return json_show(CommonModel::$success, '获取详情成功', $res);
|
|
|
}
|
|
|
|
|
|
- //编辑视频分组
|
|
|
+ //编辑
|
|
|
public static function edit(array $data = []): Json
|
|
|
{
|
|
|
|
|
|
- $rs = VideoGroupModel::field('id,company_id,card_id')
|
|
|
+ $rs = GroupModel::field('id,company_id,card_id')
|
|
|
->where([
|
|
|
'id' => $data['id'],
|
|
|
'is_del' => CommonModel::$del_normal,
|
|
|
])
|
|
|
->findOrEmpty();
|
|
|
- if ($rs->isEmpty()) return json_show(CommonModel::$error_param, '该视频分组不存在');
|
|
|
+ if ($rs->isEmpty()) return json_show(CommonModel::$error_param, '该分组不存在');
|
|
|
|
|
|
if (($rs->company_id != $data['company_id']) || ($rs->card_id != $data['card_id'])) {
|
|
|
|
|
|
- $temp = VideoGroupModel::field('id')
|
|
|
+ $temp = GroupModel::field('id')
|
|
|
->where([
|
|
|
'is_del' => CommonModel::$del_normal,
|
|
|
'company_id' => $data['company_id'],
|
|
@@ -101,20 +101,20 @@ class VideoGroupLogic extends BaseLogic
|
|
|
])
|
|
|
->findOrEmpty()
|
|
|
->isEmpty();
|
|
|
- if (!$temp) return json_show(CommonModel::$error_param, '该视频分组已存在');
|
|
|
+ if (!$temp) return json_show(CommonModel::$error_param, '该分组已存在');
|
|
|
}
|
|
|
|
|
|
- $res = VideoGroupModel::where(['id' => $data['id'], 'is_del' => CommonModel::$del_normal])
|
|
|
+ $res = GroupModel::where(['id' => $data['id'], 'is_del' => CommonModel::$del_normal])
|
|
|
->save(array_merge($data, ['updatetime' => date('Y-m-d H:i:s'), 'updaterid' => self::$uid, 'updater' => self::$uname]));
|
|
|
|
|
|
- return $res ? json_show(CommonModel::$success, '编辑视频分组成功') : json_show(CommonModel::$error_param, '编辑视频分组失败');
|
|
|
+ return $res ? json_show(CommonModel::$success, '编辑成功') : json_show(CommonModel::$error_param, '编辑失败');
|
|
|
|
|
|
}
|
|
|
|
|
|
- //视频分组启禁用
|
|
|
+ //启禁用
|
|
|
public static function status(array $data = []): Json
|
|
|
{
|
|
|
- $res = VideoGroupModel::where('id', $data['id'])
|
|
|
+ $res = GroupModel::where('id', $data['id'])
|
|
|
->where('status', '<>', $data['status'])
|
|
|
->save([
|
|
|
'status' => $data['status'],
|
|
@@ -123,17 +123,17 @@ class VideoGroupLogic extends BaseLogic
|
|
|
'updater' => self::$uname
|
|
|
]);
|
|
|
|
|
|
- return $res ? json_show(CommonModel::$success, '操作成功') : json_show(CommonModel::$success, '操作失败,该视频分组不存在或重复操作');
|
|
|
+ return $res ? json_show(CommonModel::$success, '操作成功') : json_show(CommonModel::$success, '操作失败,该分组不存在或重复操作');
|
|
|
|
|
|
}
|
|
|
|
|
|
- //删除视频分组
|
|
|
+ //删除
|
|
|
public static function delete(array $ids = []): Json
|
|
|
{
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
|
|
|
- VideoGroupModel::whereIn('id', $ids)
|
|
|
+ GroupModel::whereIn('id', $ids)
|
|
|
->where('is_del', CommonModel::$del_normal)
|
|
|
->save([
|
|
|
'is_del' => CommonModel::$del_deleted,
|
|
@@ -142,9 +142,9 @@ class VideoGroupLogic extends BaseLogic
|
|
|
'updater' => self::$uname
|
|
|
]);
|
|
|
|
|
|
- Db::name('video_group_item')
|
|
|
- ->whereIn('video_group_id', $ids)
|
|
|
+ Db::name('group_item')
|
|
|
->where('is_del', CommonModel::$del_normal)
|
|
|
+ ->whereIn('group_id', $ids)
|
|
|
->save([
|
|
|
'is_del' => CommonModel::$del_deleted,
|
|
|
'updatetime' => date('Y-m-d H:i:s'),
|
|
@@ -158,10 +158,10 @@ class VideoGroupLogic extends BaseLogic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //视频分组置顶
|
|
|
+ //置顶
|
|
|
public static function top(array $data = []): Json
|
|
|
{
|
|
|
- $res = VideoGroupModel::where('id', $data['id'])
|
|
|
+ $res = GroupModel::where('id', $data['id'])
|
|
|
->where('is_top', '<>', $data['is_top'])
|
|
|
->save([
|
|
|
'is_top' => $data['is_top'],
|
|
@@ -170,7 +170,7 @@ class VideoGroupLogic extends BaseLogic
|
|
|
'updater' => self::$uname
|
|
|
]);
|
|
|
|
|
|
- return $res ? json_show(CommonModel::$success, '操作成功') : json_show(CommonModel::$success, '操作失败,该视频分组不存在或重复操作');
|
|
|
+ return $res ? json_show(CommonModel::$success, '操作成功') : json_show(CommonModel::$success, '操作失败,该不存在或重复操作');
|
|
|
|
|
|
}
|
|
|
|