优化国标级联

结构优化
648540858 2024-01-23 00:07:17 +08:00
parent a8ba1630d2
commit be8d66423f
7 changed files with 36 additions and 14 deletions

View File

@ -21,7 +21,7 @@ public interface IPlatformService {
* @param count
* @return
*/
PageInfo<ParentPlatform> queryParentPlatformList(int page, int count);
PageInfo<ParentPlatform> queryParentPlatformList(int page, int count, String query, Boolean online);
/**
*

View File

@ -57,6 +57,9 @@ public class PlatformServiceImpl implements IPlatformService {
@Autowired
private ParentPlatformMapper platformMapper;
@Autowired
private CommonChannelMapper commonChannelMapper;
@Autowired
private IRedisCatchStorage redisCatchStorage;
@ -92,10 +95,17 @@ public class PlatformServiceImpl implements IPlatformService {
}
@Override
public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count) {
public PageInfo<ParentPlatform> queryParentPlatformList(int page, int count, String query, Boolean online) {
PageHelper.startPage(page, count);
List<ParentPlatform> all = platformMapper.getParentPlatformList();
return new PageInfo<>(all);
List<ParentPlatform> all = platformMapper.getParentPlatformList(query, online);
PageInfo<ParentPlatform> platformPageInfo = new PageInfo<>(all);
int allCount = commonChannelMapper.getAllCount();
platformPageInfo.getList().stream().forEach(parentPlatform -> {
if (parentPlatform.isShareAllChannel()) {
parentPlatform.setChannelCount(allCount);
}
});
return platformPageInfo;
}
@Override

View File

@ -655,4 +655,10 @@ public interface CommonChannelMapper {
@Select("SELECT common_gb_id FROM wvp_common_channel WHERE common_gb_id = #{commonGbChannelId}")
CommonGbChannel getOne(@Param("commonGbChannelId") int commonGbChannelId);
@Select("<script> "+
"SELECT count(0) FROM wvp_common_channel" +
"</script>")
int getAllCount();
}

View File

@ -63,16 +63,17 @@ public interface ParentPlatformMapper {
int delParentPlatform(ParentPlatform parentPlatform);
@Select("<script>" +
"SELECT * " +
"<if test='shareAllChannel == false'> " +
"SELECT *, " +
"(SELECT count(0) as channel_count FROM wvp_common_channel_platform wccp WHERE wccp.platform_id = pp.id) " +
"FROM wvp_platform pp where 1=1 " +
"<if test='query != null'> " +
"and (pp.name LIKE '%${query}%' OR de.server_gb_id LIKE '%${query}%' OR de.device_gb_id LIKE '%${query}%')" +
"</if>" +
"<if test='shareAllChannel == true'> " +
"(SELECT count(0) as channel_count FROM wvp_common_channel ) " +
"<if test='online != null'> " +
"and status = #{online}" +
"</if>" +
"FROM wvp_platform pp " +
"</script>")
List<ParentPlatform> getParentPlatformList();
List<ParentPlatform> getParentPlatformList(@Param("query") String query, @Param("online") Boolean online);
@Select("SELECT * FROM wvp_platform WHERE enable=#{enable} ")
List<ParentPlatform> getEnableParentPlatformList(boolean enable);

View File

@ -84,14 +84,19 @@ public class PlatformController {
* @param count
* @return
*/
@GetMapping("/query/{count}/{page}")
@GetMapping("/list/{count}/{page}")
@Operation(summary = "分页查询级联平台", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页条数", required = true)
public PageInfo<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count) {
public PageInfo<ParentPlatform> platforms(int page, int count,
@RequestParam(required = false)String query,
@RequestParam(required = false)Boolean online) {
PageInfo<ParentPlatform> parentPlatformPageInfo = platformService.queryParentPlatformList(page, count);
if (parentPlatformPageInfo.getList().size() > 0) {
if (ObjectUtils.isEmpty(query)) {
query = null;
}
PageInfo<ParentPlatform> parentPlatformPageInfo = platformService.queryParentPlatformList(page, count, query, online);
if (!parentPlatformPageInfo.getList().isEmpty()) {
for (ParentPlatform platform : parentPlatformPageInfo.getList()) {
platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getId()) != null);
platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getId()) != null);