Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-Server
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
李帅
2022-05-26 00:51:48 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8f1241b3f383c19a639865495ef866c88b127635
8f1241b3
1 parent
804fed8f
1.点赞收藏接口
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
app/Http/Controllers/V1/HomeController.php
app/Models/Immerse.php
app/Http/Controllers/V1/HomeController.php
View file @
8f1241b
...
...
@@ -7,6 +7,7 @@ use App\Models\Immerse;
use
App\Models\PackPoem
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
use
Laravel\Sanctum\Sanctum
;
class
HomeController
extends
Controller
{
...
...
@@ -21,6 +22,10 @@ class HomeController extends Controller
$page
=
$request
->
get
(
'page'
,
1
);
$page_size
=
$request
->
get
(
'page_size'
,
20
);
$lists
=
Immerse
::
query
()
->
skip
((
$page
-
1
)
*
$page_size
)
->
take
(
$page_size
+
1
)
->
get
();
$token
=
$request
->
bearerToken
();
$user_id
=
$token
?
((
Sanctum
::
$personalAccessTokenModel
)
::
findToken
(
$token
))
->
tokenable_id
:
'asdasd'
;
$data
=
[];
foreach
(
$lists
as
$list
)
{
$data
[]
=
[
...
...
@@ -37,8 +42,12 @@ class HomeController extends Controller
'view'
=>
$list
->
view
,
'collect'
=>
$list
->
collect
,
'share'
=>
$list
->
share
,
'is_praise'
=>
$list
->
isPraise
(
$list
->
id
,
$user_id
),
'is_collect'
=>
$list
->
isCollect
(
$list
->
id
,
$user_id
),
];
}
return
Response
::
success
(
$data
);
}
...
...
app/Models/Immerse.php
View file @
8f1241b
...
...
@@ -62,4 +62,20 @@ class Immerse extends Model
return
VideoTemp
::
POSITION_FFMPEG
[
$component
->
position
];
}
public
function
isPraise
(
$immerse_id
,
$user_id
)
{
return
Praise
::
query
()
->
where
(
'immerse_id'
,
$immerse_id
)
->
where
(
'user_id'
,
$user_id
)
->
where
(
'state'
,
1
)
->
exists
();
}
public
function
isCollect
(
$immerse_id
,
$user_id
)
{
return
Collect
::
query
()
->
where
(
'immerse_id'
,
$immerse_id
)
->
where
(
'user_id'
,
$user_id
)
->
where
(
'state'
,
1
)
->
exists
();
}
}
...
...
Please
register
or
login
to post a comment