正在显示
2 个修改的文件
包含
44 行增加
和
14 行删除
@@ -16,6 +16,8 @@ class Activity extends Api | @@ -16,6 +16,8 @@ class Activity extends Api | ||
16 | /** | 16 | /** |
17 | * @ApiTitle (活动首页) | 17 | * @ApiTitle (活动首页) |
18 | * @ApiMethod (POST) | 18 | * @ApiMethod (POST) |
19 | + * @ApiParams (name="row", type="string", required=false, description="每页显示行数[非必填]") | ||
20 | + * @ApiParams (name="page", type="string", required=false, description="当前页[非必填]") | ||
19 | * @ApiReturn ({"code":状态码, | 21 | * @ApiReturn ({"code":状态码, |
20 | "msg":"提示信息" | 22 | "msg":"提示信息" |
21 | "time": "时间戳", | 23 | "time": "时间戳", |
@@ -29,16 +31,21 @@ class Activity extends Api | @@ -29,16 +31,21 @@ class Activity extends Api | ||
29 | */ | 31 | */ |
30 | public function index() | 32 | public function index() |
31 | { | 33 | { |
34 | + $row = $this->request->param('row'); | ||
35 | + $page = $this->request->param('page'); | ||
36 | + $row = $row ? $row : 10; | ||
37 | + $page = $page ? $page : 1; | ||
32 | $data = db('activity') | 38 | $data = db('activity') |
33 | ->order('createtime DESC') | 39 | ->order('createtime DESC') |
34 | - ->select(); | 40 | + ->paginate($row,false,['page'=>$page]) |
41 | + ->each(function ($item,$key){ | ||
42 | + $item['images'] = cdnurl($item['images'], true); | ||
43 | + $item['createtime'] = date('Y-m-d', $item['createtime']); | ||
44 | + return $item; | ||
45 | + }); | ||
35 | if (!$data) { | 46 | if (!$data) { |
36 | $this->error('当前还没有活动', ['status' => 2]); | 47 | $this->error('当前还没有活动', ['status' => 2]); |
37 | } | 48 | } |
38 | - foreach ($data as $k => $v) { | ||
39 | - $data[$k]['images'] = cdnurl($v['images'], true); | ||
40 | - $data[$k]['createtime'] = date('Y-m-d', $v['createtime']); | ||
41 | - } | ||
42 | $this->success('全部项目', $data); | 49 | $this->success('全部项目', $data); |
43 | 50 | ||
44 | } | 51 | } |
@@ -58,18 +65,13 @@ class Activity extends Api | @@ -58,18 +65,13 @@ class Activity extends Api | ||
58 | */ | 65 | */ |
59 | public function getSchoolItem() | 66 | public function getSchoolItem() |
60 | { | 67 | { |
61 | - $id = $this->request->param('id'); | ||
62 | - if (empty($id)) { | ||
63 | - $this->error('参数错误', ['status' => 3]); | ||
64 | - } | ||
65 | $data = db('campus c') | 68 | $data = db('campus c') |
66 | ->join('activity a','a.id = c.activity_id') | 69 | ->join('activity a','a.id = c.activity_id') |
67 | ->join('school s','s.id = c.school_id') | 70 | ->join('school s','s.id = c.school_id') |
68 | - ->where('c.activity_id', $id) | ||
69 | ->field('c.*,a.title as activity_name,s.title as school_name') | 71 | ->field('c.*,a.title as activity_name,s.title as school_name') |
70 | ->paginate(10,false); | 72 | ->paginate(10,false); |
71 | if (empty($data)) { | 73 | if (empty($data)) { |
72 | - $this->error('空空', ['status' => 3]); | 74 | + $this->error('当前还没有校区', ['status' => 2]); |
73 | } | 75 | } |
74 | $this->success('项目校区', $data); | 76 | $this->success('项目校区', $data); |
75 | } | 77 | } |
@@ -1816,7 +1816,30 @@ | @@ -1816,7 +1816,30 @@ | ||
1816 | <div class="panel panel-default"> | 1816 | <div class="panel panel-default"> |
1817 | <div class="panel-heading"><strong>参数</strong></div> | 1817 | <div class="panel-heading"><strong>参数</strong></div> |
1818 | <div class="panel-body"> | 1818 | <div class="panel-body"> |
1819 | - 无 | 1819 | + <table class="table table-hover"> |
1820 | + <thead> | ||
1821 | + <tr> | ||
1822 | + <th>名称</th> | ||
1823 | + <th>类型</th> | ||
1824 | + <th>必选</th> | ||
1825 | + <th>描述</th> | ||
1826 | + </tr> | ||
1827 | + </thead> | ||
1828 | + <tbody> | ||
1829 | + <tr> | ||
1830 | + <td>row</td> | ||
1831 | + <td>string</td> | ||
1832 | + <td>否</td> | ||
1833 | + <td>每页显示行数[非必填]</td> | ||
1834 | + </tr> | ||
1835 | + <tr> | ||
1836 | + <td>page</td> | ||
1837 | + <td>string</td> | ||
1838 | + <td>否</td> | ||
1839 | + <td>当前页[非必填]</td> | ||
1840 | + </tr> | ||
1841 | + </tbody> | ||
1842 | + </table> | ||
1820 | </div> | 1843 | </div> |
1821 | </div> | 1844 | </div> |
1822 | <div class="panel panel-default"> | 1845 | <div class="panel panel-default"> |
@@ -1838,7 +1861,12 @@ | @@ -1838,7 +1861,12 @@ | ||
1838 | <div class="panel-body"> | 1861 | <div class="panel-body"> |
1839 | <form enctype="application/x-www-form-urlencoded" role="form" action="/api/activity/index" method="POST" name="form0" id="form0"> | 1862 | <form enctype="application/x-www-form-urlencoded" role="form" action="/api/activity/index" method="POST" name="form0" id="form0"> |
1840 | <div class="form-group"> | 1863 | <div class="form-group"> |
1841 | - 无 | 1864 | + <label class="control-label" for="row">row</label> |
1865 | + <input type="string" class="form-control input-sm" id="row" placeholder="每页显示行数[非必填]" name="row"> | ||
1866 | + </div> | ||
1867 | + <div class="form-group"> | ||
1868 | + <label class="control-label" for="page">page</label> | ||
1869 | + <input type="string" class="form-control input-sm" id="page" placeholder="当前页[非必填]" name="page"> | ||
1842 | </div> | 1870 | </div> |
1843 | <div class="form-group form-group-submit"> | 1871 | <div class="form-group form-group-submit"> |
1844 | <button type="submit" class="btn btn-success send" rel="0">提交</button> | 1872 | <button type="submit" class="btn btn-success send" rel="0">提交</button> |
@@ -4848,7 +4876,7 @@ | @@ -4848,7 +4876,7 @@ | ||
4848 | 4876 | ||
4849 | </div> | 4877 | </div> |
4850 | <div class="col-md-6" align="right"> | 4878 | <div class="col-md-6" align="right"> |
4851 | - Generated on 2023-03-17 09:48:50 <a href="./" target="_blank">校园活动</a> | 4879 | + Generated on 2023-03-17 10:06:23 <a href="./" target="_blank">校园活动</a> |
4852 | </div> | 4880 | </div> |
4853 | </div> | 4881 | </div> |
4854 | 4882 |
-
请 注册 或 登录 后发表评论