Skip to content
切换导航面板
项目
群组
代码片段
帮助
zhangtai
/
zzhnc
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
设置
活动
图像
图表
创建新的问题
作业
提交
问题看板
文件
提交
分支
标签
贡献者
图像
比较
图表
Commit a7a7b264
由
zxt@theyeasy.com
编写于
Jan 02, 2018
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加分类字段
1 个父辈
c848589d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
197 行增加
和
240 行删除
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 {
...
@@ -36,18 +36,20 @@ public class ArticlesController extends BaseController {
@ResponseBody
@ResponseBody
public
Object
getArticlesList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
page
,
public
Object
getArticlesList
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"1"
,
required
=
false
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
,
required
=
false
)
Integer
size
,
@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
)
@RequestMapping
(
value
=
"/addArticle"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@ResponseBody
public
Object
addArticle
(
@RequestParam
(
value
=
"title"
,
required
=
true
)
String
title
,
public
Object
addArticle
(
@RequestParam
(
value
=
"title"
,
required
=
true
)
String
title
,
@RequestParam
(
value
=
"content"
,
required
=
true
)
String
content
,
@RequestParam
(
value
=
"content"
,
required
=
false
)
String
content
,
@RequestParam
(
value
=
"imgurl"
,
required
=
false
)
String
imgurl
)
{
@RequestParam
(
value
=
"imgurl"
,
required
=
false
)
String
imgurl
,
String
result
=
articleService
.
addArticle
(
title
,
content
,
imgurl
);
@RequestParam
(
value
=
"type"
,
required
=
false
)
Integer
type
)
{
String
result
=
articleService
.
addArticle
(
title
,
content
,
imgurl
,
type
);
if
(
result
.
equals
(
"ok"
))
{
if
(
result
.
equals
(
"ok"
))
{
return
new
Vo_msg
(
0
,
null
,
"添加成功"
);
return
new
Vo_msg
(
0
,
null
,
"添加成功"
);
}
else
{
}
else
{
...
@@ -58,8 +60,9 @@ public class ArticlesController extends BaseController {
...
@@ -58,8 +60,9 @@ public class ArticlesController extends BaseController {
// 修改
// 修改
@RequestMapping
(
value
=
"/updateArticle"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/updateArticle"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@ResponseBody
public
Object
updateArticle
(
Integer
id
,
String
title
,
String
content
,
String
imgurl
)
{
public
Object
updateArticle
(
Integer
id
,
String
title
,
String
content
,
String
imgurl
,
String
result
=
articleService
.
updateArticle
(
id
,
title
,
content
,
imgurl
);
@RequestParam
(
value
=
"type"
,
required
=
false
)
Integer
type
)
{
String
result
=
articleService
.
updateArticle
(
id
,
title
,
content
,
imgurl
,
type
);
if
(
result
.
equals
(
"ok"
))
{
if
(
result
.
equals
(
"ok"
))
{
return
new
Vo_msg
(
0
,
"修改成功"
);
return
new
Vo_msg
(
0
,
"修改成功"
);
}
else
{
}
else
{
...
...
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
查看文件 @
a7a7b26
...
@@ -158,7 +158,7 @@ public class WxMiniController extends BaseController {
...
@@ -158,7 +158,7 @@ public class WxMiniController extends BaseController {
@ResponseBody
@ResponseBody
public
Object
getArticlesList
(
Integer
page
,
Integer
pagesize
)
{
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
...
@@ -5,228 +5,182 @@ import java.util.Date;
...
@@ -5,228 +5,182 @@ import java.util.Date;
import
javax.persistence.Id
;
import
javax.persistence.Id
;
public
class
Articles
{
public
class
Articles
{
/**
@Id
* This field was generated by MyBatis Generator.
private
Integer
id
;
* This field corresponds to the database column articles.id
*
private
String
title
;
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
private
String
imgurl
;
*/
@Id
private
Date
createdtime
;
private
Integer
id
;
private
Integer
viewcount
;
/**
private
Boolean
deleted
;
* This field was generated by MyBatis Generator.
private
Integer
type
;
* This field corresponds to the database column articles.title
private
String
content
;
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
public
Integer
getType
()
{
*/
return
type
;
private
String
title
;
}
/**
public
void
setType
(
Integer
type
)
{
* This field was generated by MyBatis Generator.
this
.
type
=
type
;
* This field corresponds to the database column articles.imgurl
}
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
public
Integer
getId
()
{
*/
return
id
;
private
String
imgurl
;
}
/**
public
void
setId
(
Integer
id
)
{
* This field was generated by MyBatis Generator.
this
.
id
=
id
;
* This field corresponds to the database column articles.createdtime
}
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
/**
*/
* This method was generated by MyBatis Generator. This method returns the value
private
Date
createdtime
;
* of the database column articles.title
*
/**
* @return the value of articles.title
* This field was generated by MyBatis Generator.
*
* This field corresponds to the database column articles.viewcount
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*
*/
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
public
String
getTitle
()
{
*/
return
title
;
private
Integer
viewcount
;
}
/**
/**
* This field was generated by MyBatis Generator.
* This method was generated by MyBatis Generator. This method sets the value of
* This field corresponds to the database column articles.deleted
* the database column articles.title
*
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
* @param title
*/
* the value for articles.title
private
Boolean
deleted
;
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
/**
*/
* This field was generated by MyBatis Generator.
public
void
setTitle
(
String
title
)
{
* This field corresponds to the database column articles.content
this
.
title
=
title
==
null
?
null
:
title
.
trim
();
*
}
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
/**
private
String
content
;
* This method was generated by MyBatis Generator. This method returns the value
* of the database column articles.imgurl
/**
*
* This method was generated by MyBatis Generator.
* @return the value of articles.imgurl
* This method returns the value of the database column articles.id
*
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
* @return the value of articles.id
*/
*
public
String
getImgurl
()
{
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
return
imgurl
;
*/
}
public
Integer
getId
()
{
return
id
;
/**
}
* This method was generated by MyBatis Generator. This method sets the value of
* the database column articles.imgurl
/**
*
* This method was generated by MyBatis Generator.
* @param imgurl
* This method sets the value of the database column articles.id
* the value for articles.imgurl
*
*
* @param id the value for articles.id
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*
*/
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
public
void
setImgurl
(
String
imgurl
)
{
*/
this
.
imgurl
=
imgurl
==
null
?
null
:
imgurl
.
trim
();
public
void
setId
(
Integer
id
)
{
}
this
.
id
=
id
;
}
/**
* This method was generated by MyBatis Generator. This method returns the value
/**
* of the database column articles.createdtime
* This method was generated by MyBatis Generator.
*
* This method returns the value of the database column articles.title
* @return the value of articles.createdtime
*
*
* @return the value of articles.title
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*
*/
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
public
Date
getCreatedtime
()
{
*/
return
createdtime
;
public
String
getTitle
()
{
}
return
title
;
}
/**
* This method was generated by MyBatis Generator. This method sets the value of
/**
* the database column articles.createdtime
* This method was generated by MyBatis Generator.
*
* This method sets the value of the database column articles.title
* @param createdtime
*
* the value for articles.createdtime
* @param title the value for articles.title
*
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
*/
public
void
setCreatedtime
(
Date
createdtime
)
{
public
void
setTitle
(
String
title
)
{
this
.
createdtime
=
createdtime
;
this
.
title
=
title
==
null
?
null
:
title
.
trim
();
}
}
/**
/**
* This method was generated by MyBatis Generator. This method returns the value
* This method was generated by MyBatis Generator.
* of the database column articles.viewcount
* This method returns the value of the database column articles.imgurl
*
*
* @return the value of articles.viewcount
* @return the value of articles.imgurl
*
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
*/
public
Integer
getViewcount
()
{
public
String
getImgurl
()
{
return
viewcount
;
return
imgurl
;
}
}
/**
/**
* This method was generated by MyBatis Generator. This method sets the value of
* This method was generated by MyBatis Generator.
* the database column articles.viewcount
* This method sets the value of the database column articles.imgurl
*
*
* @param viewcount
* @param imgurl the value for articles.imgurl
* the value for articles.viewcount
*
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
*/
public
void
setImgurl
(
String
imgurl
)
{
public
void
setViewcount
(
Integer
viewcount
)
{
this
.
imgurl
=
imgurl
==
null
?
null
:
imgurl
.
trim
();
this
.
viewcount
=
viewcount
;
}
}
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator. This method returns the value
* This method returns the value of the database column articles.createdtime
* of the database column articles.deleted
*
*
* @return the value of articles.createdtime
* @return the value of articles.deleted
*
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
*/
public
Date
getCreatedtime
()
{
public
Boolean
getDeleted
()
{
return
createdtime
;
return
deleted
;
}
}
/**
/**
* This method was generated by MyBatis Generator.
* This method was generated by MyBatis Generator. This method sets the value of
* This method sets the value of the database column articles.createdtime
* the database column articles.deleted
*
*
* @param createdtime the value for articles.createdtime
* @param deleted
*
* the value for articles.deleted
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*
*/
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
public
void
setCreatedtime
(
Date
createdtime
)
{
*/
this
.
createdtime
=
createdtime
;
public
void
setDeleted
(
Boolean
deleted
)
{
}
this
.
deleted
=
deleted
;
}
/**
* This method was generated by MyBatis Generator.
/**
* This method returns the value of the database column articles.viewcount
* This method was generated by MyBatis Generator. This method returns the value
*
* of the database column articles.content
* @return the value of articles.viewcount
*
*
* @return the value of articles.content
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*
*/
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
public
Integer
getViewcount
()
{
*/
return
viewcount
;
public
String
getContent
()
{
}
return
content
;
}
/**
* This method was generated by MyBatis Generator.
/**
* This method sets the value of the database column articles.viewcount
* This method was generated by MyBatis Generator. This method sets the value of
*
* the database column articles.content
* @param viewcount the value for articles.viewcount
*
*
* @param content
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
* the value for articles.content
*/
*
public
void
setViewcount
(
Integer
viewcount
)
{
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
this
.
viewcount
=
viewcount
;
*/
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
==
null
?
null
:
content
.
trim
();
/**
}
* This method was generated by MyBatis Generator.
* This method returns the value of the database column articles.deleted
*
* @return the value of articles.deleted
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
public
Boolean
getDeleted
()
{
return
deleted
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column articles.deleted
*
* @param deleted the value for articles.deleted
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
public
void
setDeleted
(
Boolean
deleted
)
{
this
.
deleted
=
deleted
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column articles.content
*
* @return the value of articles.content
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
public
String
getContent
()
{
return
content
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column articles.content
*
* @param content the value for articles.content
*
* @mbggenerated Wed Nov 22 10:09:40 CST 2017
*/
public
void
setContent
(
String
content
)
{
this
.
content
=
content
==
null
?
null
:
content
.
trim
();
}
}
}
\ No newline at end of file
\ No newline at end of file
src/com/w1hd/zzhnc/service/ArticleService.java
查看文件 @
a7a7b26
...
@@ -57,7 +57,7 @@ public class ArticleService{
...
@@ -57,7 +57,7 @@ public class ArticleService{
@Autowired
@Autowired
ArticlesDao
articleDao
;
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
;
if
(
StringUtil
.
isZearoOrNull
(
pagesize
))
pagesize
=
10
;
Example
example
=
new
Example
(
Articles
.
class
);
Example
example
=
new
Example
(
Articles
.
class
);
example
.
createCriteria
().
andEqualTo
(
"deleted"
,
false
);
example
.
createCriteria
().
andEqualTo
(
"deleted"
,
false
);
...
@@ -65,6 +65,9 @@ public class ArticleService{
...
@@ -65,6 +65,9 @@ public class ArticleService{
if
(!
Strings
.
isNullOrEmpty
(
keyword
)){
if
(!
Strings
.
isNullOrEmpty
(
keyword
)){
example
.
createCriteria
().
andLike
(
"title"
,
"%"
+
keyword
+
"%"
);
example
.
createCriteria
().
andLike
(
"title"
,
"%"
+
keyword
+
"%"
);
}
}
if
(
type
!=
null
&&
type
>
0
)
{
example
.
createCriteria
().
andEqualTo
(
"type"
,
type
);
}
example
.
setOrderByClause
(
" id desc "
);
example
.
setOrderByClause
(
" id desc "
);
List
<
Articles
>
list
=
articleDao
.
selectByExampleAndRowBounds
(
example
,
row
);
List
<
Articles
>
list
=
articleDao
.
selectByExampleAndRowBounds
(
example
,
row
);
int
total
=
articleDao
.
selectCountByExample
(
example
);
int
total
=
articleDao
.
selectCountByExample
(
example
);
...
@@ -76,7 +79,7 @@ public class ArticleService{
...
@@ -76,7 +79,7 @@ public class ArticleService{
return
pageresult
;
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
// TODO Auto-generated method stub
Articles
article
=
new
Articles
();
Articles
article
=
new
Articles
();
article
.
setTitle
(
title
);
article
.
setTitle
(
title
);
...
@@ -85,22 +88,19 @@ public class ArticleService{
...
@@ -85,22 +88,19 @@ public class ArticleService{
article
.
setCreatedtime
(
CommonUtil
.
getTime
());
article
.
setCreatedtime
(
CommonUtil
.
getTime
());
article
.
setDeleted
(
false
);
article
.
setDeleted
(
false
);
article
.
setViewcount
(
0
);
article
.
setViewcount
(
0
);
article
.
setType
(
type
);
int
row
=
articleDao
.
insertSelective
(
article
);
int
row
=
articleDao
.
insertSelective
(
article
);
return
row
>
0
?
"ok"
:
"添加失败,数据异常"
;
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
// TODO Auto-generated method stub
Articles
article
=
articleDao
.
selectByPrimaryKey
(
id
);
Articles
article
=
articleDao
.
selectByPrimaryKey
(
id
);
if
(
article
==
null
)
return
"修改失败,数据不存在"
;
if
(
article
==
null
)
return
"修改失败,数据不存在"
;
article
.
setTitle
(
title
);
article
.
setTitle
(
title
);
article
.
setContent
(
content
);
article
.
setContent
(
content
);
article
.
setImgurl
(
imgurl
);
article
.
setImgurl
(
imgurl
);
article
.
setType
(
type
);
int
row
=
articleDao
.
updateByPrimaryKeySelective
(
article
);
int
row
=
articleDao
.
updateByPrimaryKeySelective
(
article
);
return
row
>
0
?
"ok"
:
"修改失败,数据异常"
;
return
row
>
0
?
"ok"
:
"修改失败,数据异常"
;
}
}
...
...
编写
预览
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
请先完成此消息的编辑!
取消
请
注册
或
登录
后发表评论