Skip to content

Commit aedcf4d

Browse files
committed
feat: add AppDto
1 parent efd578f commit aedcf4d

File tree

8 files changed

+81
-18
lines changed

8 files changed

+81
-18
lines changed

base/src/main/java/com/tinyengine/it/controller/AppController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import com.tinyengine.it.common.base.Result;
1616
import com.tinyengine.it.common.log.SystemControllerLog;
17+
import com.tinyengine.it.model.dto.AppDto;
1718
import com.tinyengine.it.model.entity.App;
1819
import com.tinyengine.it.service.app.AppService;
1920

@@ -95,7 +96,7 @@ public Result<List<App>> getAllApp() {
9596
@ApiResponse(responseCode = "400", description = "请求失败")})
9697
@SystemControllerLog(description = "分页查询表App信息")
9798
@GetMapping("/apps/page")
98-
public Result<List<App>> getAllAppByPage(@RequestParam Integer currentPage,
99+
public Result<AppDto> getAllAppByPage(@RequestParam Integer currentPage,
99100
@RequestParam Integer pageSize, @RequestParam(required = false) String name,
100101
@RequestParam(required = false) Integer industryId, @RequestParam(required = false) Integer sceneId,
101102
@RequestParam(required = false) String framework) {
@@ -104,8 +105,8 @@ public Result<List<App>> getAllAppByPage(@RequestParam Integer currentPage,
104105
app.setSceneId(sceneId);
105106
app.setId(industryId);
106107
app.setFramework(framework);
107-
List<App> appList = appService.queryAllAppByPage(currentPage, pageSize, app);
108-
return Result.success(appList);
108+
AppDto appDto = appService.queryAllAppByPage(currentPage, pageSize, app);
109+
return Result.success(appDto);
109110
}
110111

111112
/**

base/src/main/java/com/tinyengine/it/controller/AppTemplateController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import com.tinyengine.it.common.base.Result;
1616
import com.tinyengine.it.common.log.SystemControllerLog;
17+
import com.tinyengine.it.model.dto.AppDto;
1718
import com.tinyengine.it.model.entity.App;
1819
import com.tinyengine.it.service.app.AppTemplateService;
1920
import io.swagger.v3.oas.annotations.Operation;
@@ -71,7 +72,7 @@ public class AppTemplateController {
7172
@ApiResponse(responseCode = "400", description = "请求失败")})
7273
@SystemControllerLog(description = "分页查询应用模版信息")
7374
@GetMapping("/app-template/list")
74-
public Result<List<App>> getAllAppTemplateByPage(@RequestParam Integer currentPage,
75+
public Result<AppDto> getAllAppTemplateByPage(@RequestParam Integer currentPage,
7576
@RequestParam Integer pageSize, @RequestParam(required = false) String name,
7677
@RequestParam(required = false) Integer industryId, @RequestParam(required = false) Integer sceneId,
7778
@RequestParam(required = false) String framework) {
@@ -80,8 +81,8 @@ public Result<List<App>> getAllAppTemplateByPage(@RequestParam Integer currentPa
8081
app.setSceneId(sceneId);
8182
app.setId(industryId);
8283
app.setFramework(framework);
83-
List<App> appList = appTemplateService.queryAllAppTemplate(currentPage, pageSize, app);
84-
return Result.success(appList);
84+
AppDto appDto = appTemplateService.queryAllAppTemplate(currentPage, pageSize, app);
85+
return Result.success(appDto);
8586
}
8687

8788
/**

base/src/main/java/com/tinyengine/it/mapper/AppMapper.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.tinyengine.it.model.entity.App;
1717

1818
import org.apache.ibatis.annotations.Param;
19+
import org.apache.ibatis.annotations.Select;
1920

2021
import java.util.List;
2122

@@ -43,7 +44,23 @@ public interface AppMapper extends BaseMapper<App> {
4344
* @return the list
4445
*/
4546
List<App> queryAllAppByPage(Integer pageSize, Integer offset, String name,
46-
Integer industryId, Integer sceneId, String framework);
47+
Integer industryId, Integer sceneId, String framework);
48+
49+
/**
50+
* 查询表t_app 应用总数
51+
*
52+
* @return the int
53+
*/
54+
@Select("select count(id) from t_app where is_template != true")
55+
int queryAppTotal();
56+
57+
/**
58+
* 查询表t_app 模版总数
59+
*
60+
* @return the int
61+
*/
62+
@Select("select count(id) from t_app where is_template = true")
63+
int queryAppTemplateTotal();
4764

4865
/**
4966
* 分页查询应用模版所有信息
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright (c) 2023 - present TinyEngine Authors.
3+
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4+
*
5+
* Use of this source code is governed by an MIT-style license.
6+
*
7+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10+
*
11+
*/
12+
13+
package com.tinyengine.it.model.dto;
14+
15+
import com.tinyengine.it.model.entity.App;
16+
import lombok.Data;
17+
18+
import java.util.List;
19+
20+
/**
21+
* The type App dto.
22+
*
23+
* @since 2024-10-20
24+
*/
25+
@Data
26+
public class AppDto {
27+
private List<App> apps;
28+
private Integer total;
29+
}

base/src/main/java/com/tinyengine/it/service/app/AppService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import com.baomidou.mybatisplus.extension.service.IService;
1616
import com.tinyengine.it.common.base.Result;
17+
import com.tinyengine.it.model.dto.AppDto;
1718
import com.tinyengine.it.model.dto.I18nEntryDto;
1819
import com.tinyengine.it.model.dto.PreviewDto;
1920
import com.tinyengine.it.model.dto.SchemaI18n;
@@ -39,9 +40,9 @@ public interface AppService extends IService<App> {
3940
* @param currentPage the currentPage
4041
* @param pageSize the pageSize
4142
* @param app the app
42-
* @return the list
43+
* @return the AppDto
4344
*/
44-
List<App> queryAllAppByPage(Integer currentPage, Integer pageSize, App app);
45+
AppDto queryAllAppByPage(Integer currentPage, Integer pageSize, App app);
4546

4647
/**
4748
* 根据主键id查询表t_app信息

base/src/main/java/com/tinyengine/it/service/app/AppTemplateService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package com.tinyengine.it.service.app;
1414

1515
import com.tinyengine.it.common.base.Result;
16+
import com.tinyengine.it.model.dto.AppDto;
1617
import com.tinyengine.it.model.entity.App;
1718

1819
import java.util.List;
@@ -23,9 +24,9 @@ public interface AppTemplateService {
2324
* @param currentPage the currentPage
2425
* @param pageSize the pageSize
2526
* @param app the app
26-
* @return the list
27+
* @return the AppDto
2728
*/
28-
List<App> queryAllAppTemplate(Integer currentPage, Integer pageSize, App app);
29+
AppDto queryAllAppTemplate(Integer currentPage, Integer pageSize, App app);
2930

3031
/**
3132
* 根据主键id查询应用模版信息

base/src/main/java/com/tinyengine/it/service/app/impl/AppServiceImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.tinyengine.it.common.log.SystemServiceLog;
2020
import com.tinyengine.it.mapper.AppMapper;
2121
import com.tinyengine.it.mapper.I18nEntryMapper;
22+
import com.tinyengine.it.model.dto.AppDto;
2223
import com.tinyengine.it.model.dto.I18nEntryDto;
2324
import com.tinyengine.it.model.dto.MetaDto;
2425
import com.tinyengine.it.model.dto.PreviewDto;
@@ -88,10 +89,10 @@ public List<App> queryAllApp() {
8889
*
8990
* @param pageSize
9091
* @param currentPage
91-
* @return the list
92+
* @return the AppDto
9293
*/
9394
@Override
94-
public List<App> queryAllAppByPage(Integer currentPage, Integer pageSize, App app) {
95+
public AppDto queryAllAppByPage(Integer currentPage, Integer pageSize, App app) {
9596
if (currentPage < 1) {
9697
currentPage = 1; // 默认第一页
9798
}
@@ -102,8 +103,13 @@ public List<App> queryAllAppByPage(Integer currentPage, Integer pageSize, App ap
102103
pageSize = 1000; // 限制最大页大小
103104
}
104105
int offset = (currentPage - 1) * pageSize;
105-
return this.baseMapper.queryAllAppByPage(pageSize, offset, app.getName(),
106-
app.getIndustryId(), app.getSceneId(), app.getFramework());
106+
List<App> apps = this.baseMapper.queryAllAppByPage(pageSize, offset, app.getName(),
107+
app.getIndustryId(), app.getSceneId(), app.getFramework());
108+
Integer total = this.baseMapper.queryAppTotal();
109+
AppDto appDto = new AppDto();
110+
appDto.setApps(apps);
111+
appDto.setTotal(total);
112+
return appDto;
107113
}
108114

109115
/**

base/src/main/java/com/tinyengine/it/service/app/impl/AppTemplateServiceImpl.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.tinyengine.it.mapper.I18nEntryMapper;
2424
import com.tinyengine.it.mapper.ModelMapper;
2525
import com.tinyengine.it.mapper.PageHistoryMapper;
26+
import com.tinyengine.it.model.dto.AppDto;
2627
import com.tinyengine.it.model.dto.I18nEntryDto;
2728
import com.tinyengine.it.model.entity.App;
2829
import com.tinyengine.it.model.entity.AppExtension;
@@ -94,10 +95,10 @@ public class AppTemplateServiceImpl extends ServiceImpl<AppMapper, App> implemen
9495
* @param currentPage the currentPage
9596
* @param pageSize the pageSize
9697
* @param app the app
97-
* @return the list
98+
* @return the AppDto
9899
*/
99100
@Override
100-
public List<App> queryAllAppTemplate(Integer currentPage, Integer pageSize, App app) {
101+
public AppDto queryAllAppTemplate(Integer currentPage, Integer pageSize, App app) {
101102
if (currentPage < 1) {
102103
currentPage = 1; // 默认第一页
103104
}
@@ -108,8 +109,14 @@ public List<App> queryAllAppTemplate(Integer currentPage, Integer pageSize, App
108109
pageSize = 1000; // 限制最大页大小
109110
}
110111
int offset = (currentPage - 1) * pageSize;
111-
return this.baseMapper.queryAllAppTemplate(pageSize, offset, app.getName(),
112+
113+
List<App> apps = this.baseMapper.queryAllAppTemplate(pageSize, offset, app.getName(),
112114
app.getIndustryId(), app.getSceneId(), app.getFramework());
115+
Integer total = this.baseMapper.queryAppTemplateTotal();
116+
AppDto appDto = new AppDto();
117+
appDto.setApps(apps);
118+
appDto.setTotal(total);
119+
return appDto;
113120
}
114121

115122
/**

0 commit comments

Comments
 (0)