Commit 07d292e 1 parent 91a00da commit 07d292e Copy full SHA for 07d292e
File tree 2 files changed +5
-31
lines changed
2 files changed +5
-31
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public function all()
24
24
return error ($ validate ->getError ());
25
25
}
26
26
27
- $ select = \app \model \User:: pagination ($ params );
27
+ $ select = ( new \app \model \User )-> pagination ($ params );
28
28
29
29
return msg ("ok " , "success " , $ select );
30
30
}
Original file line number Diff line number Diff line change 18
18
* @property string $username 用户名
19
19
* @mixin \think\Model
20
20
*/
21
- class User extends Model
21
+ class User extends Base
22
22
{
23
23
protected $ json = ['stars ' , 'oauth ' ];
24
24
protected $ jsonAssoc = true ;
25
25
26
+ protected $ searchField = ['username ' ];
27
+
28
+
26
29
public static function onAfterRead (Model $ model )
27
30
{
28
31
$ model ->avatar = avatar_cdn ($ model ->avatar );
29
32
}
30
33
31
- public static function pagination ($ param )
32
- {
33
- $ where = [];
34
- if (!empty ($ param ['username ' ])) {
35
- $ where [] = ["username " , 'like ' , '% ' . $ param ['username ' ] . '% ' ];
36
- }
37
- if (!empty ($ param ['id ' ])) {
38
- $ where [] = ["id " , 'like ' , '% ' . $ param ['id ' ] . '% ' ];
39
- }
40
- $ page = 1 ;
41
- $ limit = 10 ;
42
- if (!empty ($ param ['page ' ])) {
43
- $ page = intval ($ param ['page ' ]);
44
- }
45
- if (!empty ($ param ['limit ' ])) {
46
- $ limit = intval ($ param ['limit ' ]);
47
- }
48
-
49
- $ plugin = new User ();
50
- $ total = $ plugin ->count ();
51
- $ select = $ plugin ->page ($ page )->limit ($ limit )->where ($ where )->select ();
52
-
53
- $ data = [
54
- 'total ' => $ total ,
55
- 'items ' => $ select ,
56
- ];
57
- return $ data ;
58
- }
59
-
60
34
public static function get ($ id )
61
35
{
62
36
return User::where ('id ' , $ id )->cache (30 )->findOrEmpty ();
You can’t perform that action at this time.
0 commit comments