count(); if($result){ throw new ParamException([ 'code' => 401, 'msg' => '已收藏过该院校', 'errorCode' => 10001 ]); } return $result; } /* * 根据用户id查询用户收藏的全部专业学校id * */ public static function getNewUserSch($userID) { $result = self::field('plan_id')->where([['user_id', '=', $userID], ['is_collect', '=', 1]])->select()->toArray(); if ($result) { $result = array_column($result, 'plan_id'); } return $result; } /* * 新高考移除收藏的院校 * */ public static function delMyNewSch($id, $userID) { $result = self::where([['id', '=', $id], ['user_id', '=', $userID]])->update(['is_collect' => 2]); return $result; } /* * 新高考查询我收藏的院校 * */ public static function getMyNewSch($data,$userID,$page = 1, $limit = 10) { $where [] = empty($data['score'])? [['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1]]:[['user_id','=',$userID],['userPro','=',$data['userPro']],['is_collect','=',1],['score','=',$data['score']]]; //统计收藏院校数量 $count = self::where($where)->count(); //查询院校数据 $result = self::where($where) ->page($page, $limit)->select(); empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!'; //分页数据 $info = [ 'limit' => $limit, 'page_current' => $page, 'page_sum' => ceil($count / $limit), ]; //组合返回 $list = [ 'msg' => $msg, 'count' => $count, 'info' => $info, 'res' => $result, ]; return $list; } }