Skip to content
切换导航面板
项目
群组
代码片段
帮助
zhangtai
/
zzhnc
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
设置
活动
图像
图表
创建新的问题
作业
提交
问题看板
文件
提交
分支
标签
贡献者
图像
比较
图表
Commit a7a7b264
由
zxt@theyeasy.com
编写于
Jan 02, 2018
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加分类字段
1 个父辈
c848589d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
19 行增加
和
16 行删除
src/com/w1hd/zzhnc/controller/pc/ArticlesController.java
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
src/com/w1hd/zzhnc/model/Articles.java
src/com/w1hd/zzhnc/service/ArticleService.java
src/com/w1hd/zzhnc/controller/pc/ArticlesController.java
查看文件 @
a7a7b26
...
...
@@ -36,18 +36,20 @@ public class ArticlesController extends BaseController {
@ResponseBody
public
Object
getArticlesList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
,
required
=
false
)
Integer
size
,
@RequestParam
(
value
=
"keyword"
,
required
=
false
)
String
keyword
)
{
@RequestParam
(
value
=
"keyword"
,
required
=
false
)
String
keyword
,
@RequestParam
(
value
=
"type"
,
required
=
false
)
Integer
type
)
{
return
new
Vo_msg
(
0
,
articleService
.
getArticlesList
(
page
,
size
,
keyword
));
return
new
Vo_msg
(
0
,
articleService
.
getArticlesList
(
page
,
size
,
keyword
,
type
));
}
// 添加
@RequestMapping
(
value
=
"/addArticle"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
addArticle
(
@RequestParam
(
value
=
"title"
,
required
=
true
)
String
title
,
@RequestParam
(
value
=
"content"
,
required
=
true
)
String
content
,
@RequestParam
(
value
=
"imgurl"
,
required
=
false
)
String
imgurl
)
{
String
result
=
articleService
.
addArticle
(
title
,
content
,
imgurl
);
@RequestParam
(
value
=
"content"
,
required
=
false
)
String
content
,
@RequestParam
(
value
=
"imgurl"
,
required
=
false
)
String
imgurl
,
@RequestParam
(
value
=
"type"
,
required
=
false
)
Integer
type
)
{
String
result
=
articleService
.
addArticle
(
title
,
content
,
imgurl
,
type
);
if
(
result
.
equals
(
"ok"
))
{
return
new
Vo_msg
(
0
,
null
,
"添加成功"
);
}
else
{
...
...
@@ -58,8 +60,9 @@ public class ArticlesController extends BaseController {
// 修改
@RequestMapping
(
value
=
"/updateArticle"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
updateArticle
(
Integer
id
,
String
title
,
String
content
,
String
imgurl
)
{
String
result
=
articleService
.
updateArticle
(
id
,
title
,
content
,
imgurl
);
public
Object
updateArticle
(
Integer
id
,
String
title
,
String
content
,
String
imgurl
,
@RequestParam
(
value
=
"type"
,
required
=
false
)
Integer
type
)
{
String
result
=
articleService
.
updateArticle
(
id
,
title
,
content
,
imgurl
,
type
);
if
(
result
.
equals
(
"ok"
))
{
return
new
Vo_msg
(
0
,
"修改成功"
);
}
else
{
...
...
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
查看文件 @
a7a7b26
...
...
@@ -158,7 +158,7 @@ public class WxMiniController extends BaseController {
@ResponseBody
public
Object
getArticlesList
(
Integer
page
,
Integer
pagesize
)
{
return
new
Vo_msg
(
0
,
articleService
.
getArticlesList
(
page
,
pagesize
,
""
));
return
new
Vo_msg
(
0
,
articleService
.
getArticlesList
(
page
,
pagesize
,
""
,
null
));
}
// 增加文章浏览数
...
...
src/com/w1hd/zzhnc/model/Articles.java
查看文件 @
a7a7b26
此文件的差异被折叠,
点击展开。
src/com/w1hd/zzhnc/service/ArticleService.java
查看文件 @
a7a7b26
...
...
@@ -57,7 +57,7 @@ public class ArticleService{
@Autowired
ArticlesDao
articleDao
;
public
PageResults
<
Articles
>
getArticlesList
(
Integer
page
,
Integer
pagesize
,
String
keyword
)
{
public
PageResults
<
Articles
>
getArticlesList
(
Integer
page
,
Integer
pagesize
,
String
keyword
,
Integer
type
)
{
if
(
StringUtil
.
isZearoOrNull
(
pagesize
))
pagesize
=
10
;
Example
example
=
new
Example
(
Articles
.
class
);
example
.
createCriteria
().
andEqualTo
(
"deleted"
,
false
);
...
...
@@ -65,6 +65,9 @@ public class ArticleService{
if
(!
Strings
.
isNullOrEmpty
(
keyword
)){
example
.
createCriteria
().
andLike
(
"title"
,
"%"
+
keyword
+
"%"
);
}
if
(
type
!=
null
&&
type
>
0
)
{
example
.
createCriteria
().
andEqualTo
(
"type"
,
type
);
}
example
.
setOrderByClause
(
" id desc "
);
List
<
Articles
>
list
=
articleDao
.
selectByExampleAndRowBounds
(
example
,
row
);
int
total
=
articleDao
.
selectCountByExample
(
example
);
...
...
@@ -76,7 +79,7 @@ public class ArticleService{
return
pageresult
;
}
public
String
addArticle
(
String
title
,
String
content
,
String
imgurl
)
{
public
String
addArticle
(
String
title
,
String
content
,
String
imgurl
,
Integer
type
)
{
// TODO Auto-generated method stub
Articles
article
=
new
Articles
();
article
.
setTitle
(
title
);
...
...
@@ -85,22 +88,19 @@ public class ArticleService{
article
.
setCreatedtime
(
CommonUtil
.
getTime
());
article
.
setDeleted
(
false
);
article
.
setViewcount
(
0
);
article
.
setType
(
type
);
int
row
=
articleDao
.
insertSelective
(
article
);
return
row
>
0
?
"ok"
:
"添加失败,数据异常"
;
}
/* (非 Javadoc)
* Description:
* @see com.w1hd.zzhnc.service.ArticleService#updateArticle(java.lang.Integer, java.lang.String, java.lang.String, java.lang.String)
*/
public
String
updateArticle
(
Integer
id
,
String
title
,
String
content
,
String
imgurl
)
{
public
String
updateArticle
(
Integer
id
,
String
title
,
String
content
,
String
imgurl
,
Integer
type
)
{
// TODO Auto-generated method stub
Articles
article
=
articleDao
.
selectByPrimaryKey
(
id
);
if
(
article
==
null
)
return
"修改失败,数据不存在"
;
article
.
setTitle
(
title
);
article
.
setContent
(
content
);
article
.
setImgurl
(
imgurl
);
article
.
setType
(
type
);
int
row
=
articleDao
.
updateByPrimaryKeySelective
(
article
);
return
row
>
0
?
"ok"
:
"修改失败,数据异常"
;
}
...
...
编写
预览
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
请先完成此消息的编辑!
取消
请
注册
或
登录
后发表评论