12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace app\mobile\logic;
- use app\model\AccountModel;
- use app\model\CommonModel;
- use app\model\ThemeModel;
- use app\model\VideoModel;
- use think\facade\Db;
- use think\response\Json;
- //公共
- class CommonLogic extends BaseLogic
- {
- //视频列表
- public static function getVideoList(array $data = []): Json
- {
- $rs = AccountModel::field('id,video_ids')
- ->where(['id' => self::$aid, 'is_del' => CommonModel::$del_normal])
- ->findOrEmpty()
- ->toArray();
- if (empty($rs)) return json_show(CommonModel::$error_param, '该账户不存在');
- $db = VideoModel::where(['is_del' => CommonModel::$del_normal, 'status' => CommonModel::$status_normal])
- ->whereIn('id', $rs['video_ids']);
- $count = $db->count('id');
- $list = $db
- ->field('id,video_sn,video_name,video_url,video_img')
- ->page($data['page'], $data['size'])
- ->order(['weight' => 'desc', 'id' => 'desc'])
- ->select()
- ->toArray();
- return json_show(CommonModel::$success, '获取视频列表成功', ['count' => $count, 'list' => $list]);
- }
- //手机主题
- public static function theme(): Json
- {
- $rs = ThemeModel::field('id,code')
- ->where(['is_del' => CommonModel::$del_normal, 'group_id' => self::$group_id, 'status' => CommonModel::$status_normal])
- ->append(['modular'])
- ->withAttr('modular', function ($val, $data) {
- return Db::name('theme_modular')
- ->field('id,title,type')
- ->where(['is_del' => CommonModel::$del_normal, 'theme_id' => $data['id'], 'status' => CommonModel::$status_normal])
- ->order(['addtime' => 'desc', 'id' => 'desc'])
- ->append(['data'])
- ->withAttr('data', function ($v, $d) {
- return Db::name('theme_modular_data')
- ->field('id,img,jump_type,jump_param,good_name,good_id,style_type')
- ->where(['is_del' => CommonModel::$del_normal, 'theme_modular_id' => $d['id']])
- ->order(['addtime' => 'desc', 'id' => 'desc'])
- ->select()
- ->toArray();
- })
- ->select()
- ->toArray();
- })
- ->findOrEmpty()
- ->toArray();
- return empty($rs) ? json_show(CommonModel::$error_param, '该手机主题不存在') : json_show(CommonModel::$success, '获取手机主题成功', $rs);
- }
- }
|