Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
bd21410b
Commit
bd21410b
authored
Aug 26, 2019
by
hanfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文章列表
parent
a0363c21
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
20 deletions
+137
-20
Article.java
.../src/main/java/com/xxfc/platform/uccn/entity/Article.java
+8
-3
UccnApplication.java
...src/main/java/com/xxfc/platform/uccn/UccnApplication.java
+3
-2
ArticleBiz.java
.../src/main/java/com/xxfc/platform/uccn/biz/ArticleBiz.java
+87
-4
ArticleMapper.java
...ain/java/com/xxfc/platform/uccn/mapper/ArticleMapper.java
+7
-1
ArticleController.java
...n/java/com/xxfc/platform/uccn/rest/ArticleController.java
+30
-9
ArticleMapper.xml
...x-uccn-server/src/main/resources/mapper/ArticleMapper.xml
+2
-1
No files found.
xx-uccn/xx-uccn-api/src/main/java/com/xxfc/platform/uccn/entity/Article.java
View file @
bd21410b
...
...
@@ -68,21 +68,21 @@ public class Article {
*/
@Column
(
name
=
"author"
)
@ApiModelProperty
(
value
=
"作者"
)
private
Integer
author
;
private
String
author
;
/**
* 发布人
*/
@Column
(
name
=
"publisher"
)
@ApiModelProperty
(
value
=
"发布人"
)
private
Integer
publisher
;
private
String
publisher
;
/**
* 封面图
*/
@Column
(
name
=
"cover_image"
)
@ApiModelProperty
(
value
=
"封面图"
)
private
Integer
coverImage
;
private
String
coverImage
;
/**
* 权重
...
...
@@ -105,6 +105,11 @@ public class Article {
@ApiModelProperty
(
value
=
"是否上下架:0-否,1-是"
)
private
Integer
status
;
@Column
(
name
=
"type"
)
@ApiModelProperty
(
value
=
"文章发布网站:0-所有,1-新欣房车官网,2-滴房车官网"
)
private
Integer
type
;
/**
* 创建时间
*/
...
...
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/UccnApplication.java
View file @
bd21410b
...
...
@@ -12,11 +12,12 @@ import tk.mybatis.spring.annotation.MapperScan;
* @author Administrator
*/
@SpringBootApplication
(
scanBasePackages
={
"com.github.wxiaoqi"
"com.github.wxiaoqi"
,
"com.xxfc.platform"
})
@EnableDiscoveryClient
@EnableAceAuthClient
@EnableFeignClients
(
value
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.security"
})
@EnableFeignClients
(
basePackages
=
{
"com.xxfc.platform"
,
"com.github.wxiaoqi.security"
})
@MapperScan
(
basePackages
=
"com.xxfc.platform.uccn.mapper"
)
public
class
UccnApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/biz/ArticleBiz.java
View file @
bd21410b
...
...
@@ -7,18 +7,101 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import
com.xxfc.platform.uccn.entity.Article
;
import
com.xxfc.platform.uccn.mapper.ArticleMapper
;
import
org.springframework.stereotype.Service
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.weekend.WeekendSqls
;
import
java.util.*
;
import
java.util.List
;
/**
* @author Administrator
*/
@Service
public
class
ArticleBiz
extends
BaseBiz
<
ArticleMapper
,
Article
>
{
/**
* 随机文章条数
*/
private
final
Integer
RANDOM_NUMBER
=
3
;
/**
* 首页文章条数
*/
private
final
Integer
HOME_PAGE_NUMBER
=
4
;
public
PageInfo
getArticleList
(
Integer
page
,
Integer
limit
)
{
PageHelper
.
startPage
(
page
,
limit
);
List
articleList
=
mapper
.
getArticleList
();
/**
* 文章列表
* @param page
* @param limit
* @param type
* @return
*/
public
PageInfo
getArticleList
(
Integer
page
,
Integer
limit
,
Integer
type
)
{
PageHelper
.
startPage
(
page
,
limit
);
List
articleList
=
mapper
.
getArticleList
(
type
);
return
PageInfo
.
of
(
articleList
);
}
/**
* 获取一条数据
* @param id
* @return
*/
public
Article
getOne
(
Integer
id
)
{
Example
example
=
Example
.
builder
(
Article
.
class
).
where
(
WeekendSqls
.<
Article
>
custom
()
.
andEqualTo
(
Article:
:
getId
,
id
)
.
andEqualTo
(
Article:
:
getIsDel
,
0
)
.
andEqualTo
(
Article:
:
getStatus
,
1
)
).
build
();
Article
article
=
mapper
.
selectOneByExample
(
example
);
return
article
;
}
/**
* 随机获取三条连续的文章
* @param type
* @return
*/
public
List
getThree
(
Integer
type
)
{
List
<
Article
>
articleList
=
mapper
.
getArticleList
(
type
);
if
(!
Objects
.
isNull
(
articleList
))
{
int
size
=
articleList
.
size
();
if
(
RANDOM_NUMBER
>=
size
)
{
return
articleList
;
}
else
{
Random
random
=
new
Random
();
int
r
=
random
.
nextInt
(
size
-
RANDOM_NUMBER
+
1
);
List
<
Article
>
result
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
RANDOM_NUMBER
.
intValue
();
i
++){
int
index
=
i
+
r
;
result
.
add
(
articleList
.
get
(
index
));
}
return
result
;
}
}
return
new
ArrayList
();
}
/**
* 首页文章列表
* @param type
* @return
*/
public
List
getHomePageArticle
(
Integer
type
){
List
<
Article
>
articleList
=
mapper
.
getArticleList
(
type
);
if
(
Objects
.
isNull
(
articleList
))
{
return
new
ArrayList
();
}
else
{
if
(
articleList
.
size
()>
HOME_PAGE_NUMBER
)
{
return
articleList
.
subList
(
0
,
HOME_PAGE_NUMBER
);
}
else
{
return
articleList
;
}
}
}
}
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/mapper/ArticleMapper.java
View file @
bd21410b
package
com
.
xxfc
.
platform
.
uccn
.
mapper
;
import
com.xxfc.platform.uccn.entity.Article
;
import
org.apache.ibatis.annotations.Param
;
import
tk.mybatis.mapper.common.Mapper
;
import
java.util.List
;
...
...
@@ -9,5 +10,10 @@ import java.util.List;
* @author Administrator
*/
public
interface
ArticleMapper
extends
Mapper
<
Article
>
{
List
getArticleList
();
/**
* 根据网站类型查询文章
* @param type
* @return
*/
List
<
Article
>
getArticleList
(
@Param
(
"type"
)
Integer
type
);
}
xx-uccn/xx-uccn-server/src/main/java/com/xxfc/platform/uccn/rest/ArticleController.java
View file @
bd21410b
...
...
@@ -5,14 +5,15 @@ import com.github.wxiaoqi.security.common.rest.BaseController;
import
com.xxfc.platform.uccn.biz.ArticleBiz
;
import
com.xxfc.platform.uccn.entity.Article
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
/**
* 文章
*
* @author Administrator
*/
@RestController
...
...
@@ -22,9 +23,29 @@ public class ArticleController extends BaseController<ArticleBiz, Article> {
@GetMapping
(
"/list"
)
@ApiOperation
(
value
=
"获取文章列表"
)
public
ObjectRestResponse
getArticleList
(
@RequestParam
(
name
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
name
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
){
return
ObjectRestResponse
.
succ
(
baseBiz
.
getArticleList
(
page
,
limit
));
}
public
ObjectRestResponse
getArticleList
(
@RequestParam
(
name
=
"page"
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
name
=
"limit"
,
defaultValue
=
"10"
)
Integer
limit
,
@RequestParam
(
name
=
"type"
,
defaultValue
=
"0"
)
Integer
type
)
{
return
ObjectRestResponse
.
succ
(
baseBiz
.
getArticleList
(
page
,
limit
,
type
));
}
@GetMapping
(
"/one/{id}"
)
@ApiOperation
(
value
=
"获取一条数据"
)
public
ObjectRestResponse
getOne
(
@PathVariable
Integer
id
)
{
return
ObjectRestResponse
.
succ
(
baseBiz
.
getOne
(
id
));
}
@GetMapping
(
"/three/{type}"
)
@ApiOperation
(
value
=
"随机获取三条数据"
)
public
ObjectRestResponse
randomAccessToThreeData
(
@PathVariable
Integer
type
){
return
ObjectRestResponse
.
succ
(
baseBiz
.
getThree
(
type
));
}
@GetMapping
(
"/homePage/{type}"
)
@ApiOperation
(
value
=
"获取首页文章列表"
)
public
ObjectRestResponse
getHomePageArticle
(
@PathVariable
Integer
type
){
return
ObjectRestResponse
.
succ
(
baseBiz
.
getHomePageArticle
(
type
));
}
}
xx-uccn/xx-uccn-server/src/main/resources/mapper/ArticleMapper.xml
View file @
bd21410b
...
...
@@ -4,7 +4,8 @@
<mapper
namespace=
"com.xxfc.platform.uccn.mapper.ArticleMapper"
>
<select
id=
"getArticleList"
resultType=
"com.xxfc.platform.uccn.entity.Article"
>
select title,epitome,add_time,cover_image from article where is_del=0 and status=1 order by weight,add_time DESC
select title,epitome,add_time,cover_image from article
where is_del=0 and status=1 and (type=#{type} or type=0) order by weight DESC,add_time DESC
</select>
</mapper>
\ No newline at end of file
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