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
李帅
2023-03-24 23:56:21 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b9306566603f89ef7217bec80a0ea10eebbd4945
b9306566
1 parent
932a3028
1.优化一言
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
app/Http/Controllers/V1/HomeController.php
app/Http/Controllers/V1/HomeController.php
View file @
b930656
...
...
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\V1;
use
App\Http\Controllers\Controller
;
use
App\Models\Immerse
;
use
App\Models\OnePoem
;
use
App\Models\OnePoem2
;
use
App\Models\PackPoem
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
...
...
@@ -73,9 +74,21 @@ class HomeController extends Controller
public
function
poem
(
$id
)
{
//
todo 多对多关系
//
一对多临时方案,下版本会改为数组结构
try
{
return
Response
::
success
(
OnePoem
::
query
()
->
find
(
$id
));
$poem2
=
OnePoem2
::
query
()
->
find
(
$id
);
$data
=
[
'title'
=>
$poem2
->
title
,
'author'
=>
$poem2
->
author
,
'state'
=>
0
,
];
foreach
(
$poem2
->
verses
as
$item
){
$data
[
'content'
]
.=
$item
->
content
.
"
\n
"
;
$data
[
'annotate'
]
.=
$item
->
annotate
.
"
\n
"
;
$data
[
'spelling'
]
.=
$item
->
spelling
.
"
\n
"
;
$data
[
'en'
]
.=
$item
->
en
.
"
\n
"
;
}
return
Response
::
success
(
$data
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
());
}
...
...
Please
register
or
login
to post a comment