Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
peizhen-java
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PeiZhen-Java
peizhen-java
Commits
76720341
Commit
76720341
authored
Nov 24, 2023
by
sdif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增官网新闻资讯接口
parent
46e72ef8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
0 deletions
+101
-0
pz-applet/src/main/java/com/pz/applet/AppletInformationController.java
+12
-0
pz-system/src/main/java/com/pz/system/domain/vo/InformationVo.java
+18
-0
pz-system/src/main/java/com/pz/system/domain/vo/OsArticleVo.java
+25
-0
pz-system/src/main/java/com/pz/system/service/IInformationService.java
+6
-0
pz-system/src/main/java/com/pz/system/service/impl/InformationServiceImpl.java
+40
-0
No files found.
pz-applet/src/main/java/com/pz/applet/AppletInformationController.java
View file @
76720341
...
...
@@ -15,6 +15,7 @@ import com.pz.common.enums.BusinessType;
import
com.pz.common.utils.poi.ExcelUtil
;
import
com.pz.system.domain.bo.InformationBo
;
import
com.pz.system.domain.vo.InformationVo
;
import
com.pz.system.domain.vo.OsArticleVo
;
import
com.pz.system.service.IInformationService
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -52,10 +53,21 @@ public class AppletInformationController extends BaseController {
}
/**
* 查询新闻资讯列表官网
*/
@SaIgnore
@GetMapping
(
"/listgw"
)
public
R
<
InformationVo
>
listgw
(
@RequestParam
(
"id"
)
String
id
)
{
//bo.setCityId(CityIdUtils.setCityIdPasLong(reques));
return
R
.
ok
(
iInformationService
.
listgw
(
id
));
}
/**
* 获取新闻资讯详细信息
*
* @param id 主键
*/
@SaIgnore
@GetMapping
(
"/{id}"
)
public
R
<
InformationVo
>
getInfo
(
@NotNull
(
message
=
"主键不能为空"
)
@PathVariable
Integer
id
)
{
...
...
pz-system/src/main/java/com/pz/system/domain/vo/InformationVo.java
View file @
76720341
...
...
@@ -65,4 +65,22 @@ public class InformationVo {
private
Date
createTime
;
private
Date
updateTime
;
/*
* 上一篇文章id
*/
private
String
beforeId
;
/**
* 上一篇文章标题
*/
private
String
beforeTitle
;
/**
* 下一篇文章id
*/
private
String
afterId
;
/**
* 下一篇文章标题
*/
private
String
afterTitle
;
}
pz-system/src/main/java/com/pz/system/domain/vo/OsArticleVo.java
0 → 100644
View file @
76720341
package
com
.
pz
.
system
.
domain
.
vo
;
import
lombok.Data
;
@Data
public
class
OsArticleVo
extends
InformationVo
{
/** */
private
static
final
long
serialVersionUID
=
1L
;
/*
* 上一篇文章id
*/
private
String
beforeId
;
/**
* 上一篇文章标题
*/
private
String
beforeTitle
;
/**
* 下一篇文章id
*/
private
String
afterId
;
/**
* 下一篇文章标题
*/
private
String
afterTitle
;
}
pz-system/src/main/java/com/pz/system/service/IInformationService.java
View file @
76720341
...
...
@@ -5,6 +5,7 @@ import com.pz.system.domain.vo.InformationVo;
import
com.pz.system.domain.bo.InformationBo
;
import
com.pz.common.core.page.TableDataInfo
;
import
com.pz.common.core.domain.PageQuery
;
import
com.pz.system.domain.vo.OsArticleVo
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -33,6 +34,11 @@ public interface IInformationService {
List
<
InformationVo
>
queryList
(
InformationBo
bo
);
/**
* 查询新闻资讯列表官网
*/
InformationVo
listgw
(
String
id
);
/**
* 新增新闻资讯
*/
Boolean
insertByBo
(
InformationBo
bo
);
...
...
pz-system/src/main/java/com/pz/system/service/impl/InformationServiceImpl.java
View file @
76720341
...
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.pz.system.domain.City
;
import
com.pz.system.domain.vo.OsArticleVo
;
import
com.pz.system.mapper.CityMapper
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
...
...
@@ -71,6 +72,45 @@ public class InformationServiceImpl implements IInformationService {
return
baseMapper
.
selectVoList
(
lqw
);
}
@Override
public
InformationVo
listgw
(
String
id
)
{
InformationVo
informationVo
=
baseMapper
.
selectVoById
(
id
);
// 根据当前文章类型查询相关文章
List
<
InformationVo
>
list
=
baseMapper
.
selectVoList
(
new
LambdaQueryWrapper
<>());
Optional
.
ofNullable
(
list
).
ifPresent
(
informationVos
->
{
informationVos
.
forEach
(
informationVo1
->
{
Optional
.
ofNullable
(
cityMapper
.
selectVoById
(
informationVo1
.
getCityId
()))
.
ifPresent
(
cityVo
->
{
informationVo1
.
setCityName
(
cityVo
.
getName
());
});
});
});
// list长度减一(索引值从0开始)
int
count
=
list
.
size
()
-
1
;
list
.
forEach
(
a
->
{
if
(
a
.
getId
().
equals
(
informationVo
.
getId
()))
{
// 当前文章所在索引位置
int
index
=
list
.
indexOf
(
a
);
// 索引为0时且list长度大于0,直接获取索引下一个值
if
(
index
==
0
&&
count
>
0
)
{
informationVo
.
setAfterId
(
list
.
get
(
1
).
getId
().
toString
());
informationVo
.
setAfterTitle
(
list
.
get
(
1
).
getTitle
());
// 索引为最后一个且list长度大于0,,赋值上一篇文章
}
else
if
(
index
==
count
&&
count
>
0
)
{
informationVo
.
setBeforeId
(
list
.
get
(
index
-
1
).
getId
().
toString
());
informationVo
.
setBeforeTitle
(
list
.
get
(
index
-
1
).
getTitle
());
}
else
{
// 索引为中间值时,分别给上下文章赋值
informationVo
.
setBeforeId
(
list
.
get
(
index
-
1
).
getId
().
toString
());
informationVo
.
setBeforeTitle
(
list
.
get
(
index
-
1
).
getTitle
());
informationVo
.
setAfterId
(
list
.
get
(
index
+
1
).
getId
().
toString
());
informationVo
.
setAfterTitle
(
list
.
get
(
index
+
1
).
getTitle
());
}
}
});
return
informationVo
;
}
private
LambdaQueryWrapper
<
Information
>
buildQueryWrapper
(
InformationBo
bo
)
{
Map
<
String
,
Object
>
params
=
bo
.
getParams
();
LambdaQueryWrapper
<
Information
>
lqw
=
Wrappers
.
lambdaQuery
();
...
...
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