Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_api_news
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ede15da2
authored
Nov 27, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
添加公告接口
parent
db636d68
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
115 additions
and
1 deletions
app/Http/Controllers/CaseController.php
app/Http/Controllers/NoticeController.php
app/Model/ArticleModel.php
app/Services/NoticeService.php
config/config.php
routes/web.php
app/Http/Controllers/CaseController.php
View file @
ede15da2
...
@@ -12,7 +12,7 @@ class CaseController extends Controller
...
@@ -12,7 +12,7 @@ class CaseController extends Controller
public
function
index
(
Request
$request
,
CaseService
$service
)
public
function
index
(
Request
$request
,
CaseService
$service
)
{
{
$page
=
$request
->
get
(
'page'
);
$page
=
$request
->
get
(
'page'
);
$pageSize
=
$request
->
get
(
'page
S
ize'
);
$pageSize
=
$request
->
get
(
'page
_s
ize'
);
$list
=
$service
->
getCaseList
(
$page
,
$pageSize
);
$list
=
$service
->
getCaseList
(
$page
,
$pageSize
);
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$list
]);
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$list
]);
...
...
app/Http/Controllers/NoticeController.php
0 → 100644
View file @
ede15da2
<?php
namespace
App\Http\Controllers
;
use
App\Model\ArticleModel
;
use
App\Services\NoticeService
;
use
Illuminate\Http\Request
;
//faq
class
NoticeController
extends
Controller
{
public
function
index
(
Request
$request
,
NoticeService
$service
)
{
$page
=
$request
->
get
(
'page'
);
$pageSize
=
$request
->
get
(
'page_size'
);
$list
=
$service
->
getNoticeList
(
$page
,
$pageSize
);
return
$this
->
Export
(
0
,
'ok'
,
[
'data'
=>
$list
]);
}
public
function
show
(
Request
$request
,
NoticeService
$service
)
{
$faq
=
$service
->
getNotice
(
$request
->
get
(
'id'
));
return
$faq
;
}
}
\ No newline at end of file
app/Model/ArticleModel.php
View file @
ede15da2
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
namespace
App\Model
;
namespace
App\Model
;
use
App\Services\NoticeService
;
use
http\Env\Request
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
class
ArticleModel
extends
BaseModel
class
ArticleModel
extends
BaseModel
...
@@ -109,4 +111,29 @@ class ArticleModel extends BaseModel
...
@@ -109,4 +111,29 @@ class ArticleModel extends BaseModel
return
$data
;
return
$data
;
}
}
//获取公告列表
public
function
getNoticeList
(
$page
,
$pageSize
)
{
$noticeTypeId
=
config
(
'config.notice_type_id'
);
$data
=
$this
->
select
([
'art_id'
,
'type_id'
,
'title'
])
->
with
([
'type'
,
])
->
where
(
'top_type_id'
,
$noticeTypeId
)
->
orderBy
(
'art_id'
,
'desc'
)
->
page
(
$page
,
$pageSize
)
->
get
();
return
$data
;
}
//获取公告信息
public
function
getNotice
(
$id
)
{
$data
=
$this
->
select
([
'art_id'
,
'type_id'
,
'title'
])
->
with
([
'article_addon'
])
->
where
(
'art_id'
,
$id
)
->
first
();
return
$data
;
}
}
}
\ No newline at end of file
app/Services/NoticeService.php
0 → 100644
View file @
ede15da2
<?php
namespace
App\Services
;
use
App\Model\ArctypeModel
;
use
App\Model\ArticleModel
;
class
NoticeService
extends
BaseService
{
public
function
getNoticeList
(
$page
,
$pageSize
)
{
$model
=
new
ArticleModel
();
//获取所有faq相关的文章,50应该差不多了
$list
=
$model
->
getNoticeList
(
$page
,
$pageSize
);
$list
=
$this
->
transform
(
$list
);
return
$list
;
}
private
function
transform
(
$data
)
{
foreach
(
$data
as
$key
=>
&
$item
)
{
$item
[
'type_name'
]
=
array_get
(
$item
[
'type'
],
'type_name'
);
unset
(
$item
[
'type'
]);
}
unset
(
$item
);
return
$data
;
}
public
function
getNotice
(
$id
)
{
$model
=
new
ArticleModel
();
$faq
=
$model
->
getNotice
(
$id
);
$faq
=
$this
->
transformNotice
(
$faq
);
return
$faq
;
}
private
function
transformNotice
(
$data
)
{
$data
[
'body'
]
=
array_get
(
$data
[
'article_addon'
],
'body'
);
unset
(
$data
[
'article_addon'
]);
return
$data
;
}
}
\ No newline at end of file
config/config.php
View file @
ede15da2
...
@@ -14,4 +14,5 @@ return [
...
@@ -14,4 +14,5 @@ return [
4
=>
'处理失败'
4
=>
'处理失败'
],
],
'faq_type_id'
=>
10
,
'faq_type_id'
=>
10
,
'notice_type_id'
=>
10
,
];
];
\ No newline at end of file
routes/web.php
View file @
ede15da2
...
@@ -23,6 +23,8 @@ $router->group(['middleware' => []], function () use ($router) {
...
@@ -23,6 +23,8 @@ $router->group(['middleware' => []], function () use ($router) {
$router
->
addRoute
([
'GET'
,
'POST'
],
'/case/info'
,
'CaseController@show'
);
$router
->
addRoute
([
'GET'
,
'POST'
],
'/case/info'
,
'CaseController@show'
);
$router
->
addRoute
([
'GET'
,
'POST'
],
'/faq/list'
,
'FaqController@index'
);
$router
->
addRoute
([
'GET'
,
'POST'
],
'/faq/list'
,
'FaqController@index'
);
$router
->
addRoute
([
'GET'
,
'POST'
],
'/faq/info'
,
'FaqController@show'
);
$router
->
addRoute
([
'GET'
,
'POST'
],
'/faq/info'
,
'FaqController@show'
);
$router
->
addRoute
([
'GET'
,
'POST'
],
'/notice/list'
,
'NoticeController@index'
);
$router
->
addRoute
([
'GET'
,
'POST'
],
'/notice/info'
,
'NoticeController@show'
);
});
});
$router
->
group
([
'middleware'
=>
[
'web'
,
'login'
]],
function
()
use
(
$router
)
{
$router
->
group
([
'middleware'
=>
[
'web'
,
'login'
]],
function
()
use
(
$router
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment