Blame view

addons/exam/controller/Cert.php 1.12 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  <?php

  

  namespace addons\exam\controller;

  

  use addons\exam\enum\GeneralStatus;

  use addons\exam\model\CertModel;

  

  

  /**

   * 证书接口

   */

  class Cert extends Base

  {

      protected $noNeedLogin = [];

      protected $noNeedRight = ['*'];

      protected $user;

  

      /**

       * 列表

       */

      public function index()

      {

          $list = CertModel::with(['paper', 'room'])

              ->where('user_id', $this->auth->id)

              ->where('status', GeneralStatus::NORMAL)

              ->order('id desc')

              ->paginate(15, true);

          $this->success('', ['list' => $list]);

      }

  

      /**

       * 详情

       */

      public function detail()

      {

          if (!$id = input('id/d', '0')) {

              $this->error('缺少证书记录ID');

          }

  

          $cert = CertModel::with(['paper', 'room'])

              ->where('id', $id)

              ->where('user_id', $this->auth->id)

              ->where('status', GeneralStatus::NORMAL)

              ->find();

          if (!$cert) {

              $this->error('证书记录信息不存在');

          }

  

          $this->success('', $cert);

      }

  }