Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
fa4ccfee
Commit
fa4ccfee
authored
Jul 03, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
评论列表
parent
13395d74
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
10 deletions
+150
-10
News.php
application/api_broker/controller/News.php
+73
-9
SNews.php
application/model/SNews.php
+13
-0
SNewsComment.php
application/model/SNewsComment.php
+62
-0
route.php
application/route.php
+2
-1
No files found.
application/api_broker/controller/News.php
View file @
fa4ccfee
...
@@ -8,9 +8,10 @@
...
@@ -8,9 +8,10 @@
namespace
app\api_broker\controller
;
namespace
app\api_broker\controller
;
use
app\
index
\extend\Basic
;
use
app\
api_broker
\extend\Basic
;
use
app\model\SLabel
;
use
app\model\SLabel
;
use
app\model\SNews
;
use
app\model\SNews
;
use
app\model\SNewsComment
;
use
think\Request
;
use
think\Request
;
class
News
extends
Basic
class
News
extends
Basic
...
@@ -34,10 +35,6 @@ class News extends Basic
...
@@ -34,10 +35,6 @@ class News extends Basic
*/
*/
public
function
index
()
public
function
index
()
{
{
if
(
!
$this
->
request
->
isAjax
())
{
return
view
(
'index'
);
}
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
...
@@ -63,7 +60,7 @@ class News extends Basic
...
@@ -63,7 +60,7 @@ class News extends Basic
$field
=
'a.id,a.title,a.content,a.create_time,b.name,c.label_name,a.cover_plan'
;
$field
=
'a.id,a.title,a.content,a.create_time,b.name,c.label_name,a.cover_plan'
;
$where
[
'a.status'
]
=
0
;
$where
[
'a.status'
]
=
0
;
$data
[
'list'
]
=
$this
->
m_news
->
getListAgent
(
$pageNo
,
$pageSize
,
'id DESC'
,
$field
,
$where
);
$data
[
'list'
]
=
$this
->
m_news
->
getListAgent
(
$pageNo
,
$pageSize
,
'
a.
id DESC'
,
$field
,
$where
);
$data
[
'total'
]
=
$this
->
m_news
->
getListAgentTotal
(
$where
);
$data
[
'total'
]
=
$this
->
m_news
->
getListAgentTotal
(
$where
);
return
$this
->
response
(
200
,
""
,
$data
);
return
$this
->
response
(
200
,
""
,
$data
);
}
}
...
@@ -82,7 +79,39 @@ class News extends Basic
...
@@ -82,7 +79,39 @@ class News extends Basic
return
$this
->
response
(
101
,
"Id is null."
);
return
$this
->
response
(
101
,
"Id is null."
);
}
}
$data
=
$this
->
m_news
->
getNewsInfo
(
'id,title,s_label_id,cover_plan,content'
);
$comment
=
new
SNewsComment
();
$data
[
'news'
]
=
$this
->
m_news
->
getNewsInfo
(
'id,title,s_label_id,cover_plan,content'
);
$field
=
'a.id,a.comment_content,a.create_time,b.name,b.img'
;
$where
[
'a.s_news_id'
]
=
$this
->
params
[
'id'
];
$where
[
'a.status'
]
=
0
;
$data
[
'comment'
]
=
$comment
->
getListAgent
(
1
,
3
,
'a.id DESC'
,
$field
,
$where
);
return
$this
->
response
(
200
,
""
,
$data
);
}
/**
* 评论列表
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getComment
()
{
if
(
empty
(
$this
->
params
[
'news_id'
]))
{
return
$this
->
response
(
101
,
"参数错误"
);
}
$pageNo
=
empty
(
$this
->
params
[
'pageNo'
])
?
1
:
$this
->
params
[
'pageNo'
];
$pageSize
=
empty
(
$this
->
params
[
'pageSize'
])
?
10
:
$this
->
params
[
'pageSize'
];
$comment
=
new
SNewsComment
();
$field
=
'a.id,a.comment_content,a.create_time,b.name,b.img'
;
$where
[
'a.s_news_id'
]
=
$this
->
params
[
'news_id'
];
$where
[
'a.status'
]
=
0
;
$data
=
$comment
->
getListAgent
(
$pageNo
,
$pageSize
,
'a.id DESC'
,
$field
,
$where
);
return
$this
->
response
(
200
,
""
,
$data
);
return
$this
->
response
(
200
,
""
,
$data
);
}
}
...
@@ -94,9 +123,43 @@ class News extends Basic
...
@@ -94,9 +123,43 @@ class News extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
public
function
getNewsLabel
()
{
public
function
getNewsLabel
()
{
$label
=
new
SLabel
();
$label
=
new
SLabel
();
$data
=
$label
->
getList
(
1
,
200
,
''
,
'id,label_name'
,
[
'status'
=>
0
]);
$data
=
$label
->
getList
(
1
,
200
,
''
,
'id,label_name'
,
[
'status'
=>
0
]);
return
$this
->
response
(
200
,
''
,
$data
);
return
$this
->
response
(
200
,
''
,
$data
);
}
}
/**
* 评论文章
*
* @return \think\Response
*/
public
function
commentNews
()
{
if
(
empty
(
$this
->
params
[
'news_id'
]))
{
return
$this
->
response
(
101
,
'文章参数错误'
);
}
if
(
empty
(
$this
->
params
[
'content'
]))
{
return
$this
->
response
(
101
,
'文章内容为空'
);
}
$data
[
'agent_id'
]
=
$this
->
agentId
;
$data
[
's_news_id'
]
=
$this
->
params
[
'news_id'
];
$data
[
'comment_content'
]
=
$this
->
params
[
'comment_content'
];
$data
[
'status'
]
=
0
;
$m_new_comment
=
new
SNewsComment
();
$num
=
$m_new_comment
->
editData
(
$data
);
if
(
$num
>
0
)
{
$news
=
new
SNews
();
$news
->
setCommentNumber
(
$this
->
params
[
'news_id'
]);
return
$this
->
response
(
200
,
'评论成功'
);
}
return
$this
->
response
(
101
,
'评论失败'
);
}
}
}
\ No newline at end of file
application/model/SNews.php
View file @
fa4ccfee
...
@@ -72,4 +72,16 @@ class SNews extends BaseModel
...
@@ -72,4 +72,16 @@ class SNews extends BaseModel
$data
[
'cover_plan'
]
=
CURRENT_URL
.
'static/business_school/'
.
$data
[
'cover_plan'
];
$data
[
'cover_plan'
]
=
CURRENT_URL
.
'static/business_school/'
.
$data
[
'cover_plan'
];
return
$data
;
return
$data
;
}
}
/**
* 增加评论数
*
* @param $id
* @return int
*/
public
function
setCommentNumber
(
$id
)
{
$comment_number
=
$this
->
where
(
'id'
,
$id
)
->
value
(
'comment_number'
);
$comment_number
+=
1
;
return
$this
->
where
(
'id'
,
$id
)
->
setField
(
'comment_number'
,
$comment_number
);
}
}
}
\ No newline at end of file
application/model/SNewsComment.php
0 → 100644
View file @
fa4ccfee
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/7/3
* Time: 17:35
*/
namespace
app\model
;
class
SNewsComment
extends
BaseModel
{
/**
* 商学院列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getListAgent
(
$pageNo
=
1
,
$pageSize
=
15
,
$order_
=
'id desc'
,
$field
=
''
,
$params
=
''
)
{
$data
=
$this
->
field
(
$field
)
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.agent_id = b.id'
,
'left'
)
->
where
(
$params
)
->
order
(
$order_
)
->
limit
(
$pageSize
)
->
page
(
$pageNo
)
->
select
();
foreach
(
$data
as
$k
=>
$v
)
{
if
(
isset
(
$v
[
'img'
]))
{
$data
[
$k
][
'img'
]
=
AGENTHEADERIMGURL
.
$v
[
'img'
];
}
}
return
$data
;
}
/**
* 商学院列表总数
*
* @param $params
* @return int|string
*/
public
function
getListAgentTotal
(
$params
)
{
return
$this
->
alias
(
'a'
)
->
join
(
'a_agents b'
,
'a.publisher_id = b.id'
,
'left'
)
->
where
(
$params
)
->
count
();
}
}
\ No newline at end of file
application/route.php
View file @
fa4ccfee
...
@@ -493,7 +493,8 @@ Route::group('broker', [
...
@@ -493,7 +493,8 @@ Route::group('broker', [
'uploadImg'
=>
[
'api_broker/UploadImg/uploadImg'
,
[
'method'
=>
'POST|GET'
]
],
//图片上传
'uploadImg'
=>
[
'api_broker/UploadImg/uploadImg'
,
[
'method'
=>
'POST|GET'
]
],
//图片上传
'business_school'
=>
[
'api_broker/news/index'
,
[
'method'
=>
'GET'
]
],
//商学院资讯列表
'business_school'
=>
[
'api_broker/news/index'
,
[
'method'
=>
'GET'
]
],
//商学院资讯列表
'getNewsInfo'
=>
[
'api_broker/news/getNewsInfo'
,
[
'method'
=>
'GET'
]
],
//商学院资讯详情
'getNewsInfo'
=>
[
'api_broker/news/getNewsInfo'
,
[
'method'
=>
'GET'
]
],
//商学院资讯详情
'getNewsLabel'
=>
[
'api_broker/news/getNewsLabel'
,
[
'method'
=>
'GET'
]
],
//商学院资标签
'getNewsLabel'
=>
[
'api_broker/news/getNewsLabel'
,
[
'method'
=>
'GET'
]
],
//商学院标签
'getComment'
=>
[
'api_broker/news/getComment'
,
[
'method'
=>
'GET'
]
],
//商学院评论列表
]);
]);
...
...
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