Commit e74d197d by 杨树贤

添加最大page_size的限制

parent 8a1d4a72
......@@ -42,4 +42,6 @@ REDIS_READ_HOST=192.168.1.235
REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379
RobotUrl=https://oapi.dingtalk.com/robot/send?access_token=a7255513c160f20d65c0c00d939fe88712233bbda0dc520563705bf721072d11
......@@ -19,6 +19,8 @@ class Assist extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -20,6 +20,8 @@ class CheckIn extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -4,6 +4,7 @@
namespace App\Models;
use App\Http\Filters\QueryFilter;
use Common\Model\RedisModel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
......@@ -13,6 +14,28 @@ class Code extends Model
{
public $timestamps = false;
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
public function scopeFilter($query, QueryFilter $filters)
{
return $filters->apply($query);
}
//获取红包码兑换记录
public function getCodeList($page, $pageSize, $filter)
{
$codes = Code::filter($filter)->page($page, $pageSize)
->orderBy('id', 'desc')->get()->toArray();
$count = Code::filter($filter)->count();
return ['data' => $codes, 'count' => $count];
}
//判断是否可以输入红包码,因为每个人只能输入一次红包码
public function checkCanExchangeCode($data = [])
{
......
......@@ -16,6 +16,8 @@ class ExchangeSetting extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -27,6 +27,8 @@ class Integral extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -25,6 +25,8 @@ class IntegralBill extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -19,6 +19,8 @@ class Invite extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -16,6 +16,8 @@ class UserExchange extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -14,6 +14,8 @@ class UserIntegral extends Model
public function scopePage($query, $page = 1, $pageSize = 10)
{
$pageSize = $pageSize < 50 ? $pageSize : 50;
return $query->offset(($page - 1) * $pageSize)->limit($pageSize);
}
......
......@@ -77,6 +77,7 @@ $router->post('/invites/add', 'InvitesController@store');
$router->post('/invites/info', 'InvitesController@info');
//红包码兑换(添加)
$router->post('/codes/list', 'CodesController@index');
$router->post('/codes/add', 'CodesController@store');
//好友助力
......
4194
\ No newline at end of file
4199
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment