Skip to content

Commit 283a711

Browse files
committed
fix: modify AppMapper
1 parent 4d12efd commit 283a711

File tree

8 files changed

+49
-16
lines changed

8 files changed

+49
-16
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public Result<List<App>> getAllApp() {
8989
@Parameter(name = "industry", description = "行业"),
9090
@Parameter(name = "scene", description = "场景"),
9191
@Parameter(name = "framework", description = "技术栈"),
92+
@Parameter(name = "orderBy", description = "排序方式"),
93+
@Parameter(name = "createdBy", description = "创建人"),
9294
}, responses = {
9395
@ApiResponse(responseCode = "200", description = "返回信息",
9496
content = @Content(mediaType = "application/json",
@@ -99,13 +101,15 @@ public Result<List<App>> getAllApp() {
99101
public Result<AppDto> getAllAppByPage(@RequestParam Integer currentPage,
100102
@RequestParam Integer pageSize, @RequestParam(required = false) String name,
101103
@RequestParam(required = false) Integer industryId, @RequestParam(required = false) Integer sceneId,
102-
@RequestParam(required = false) String framework) {
104+
@RequestParam(required = false) String framework, @RequestParam(required = false) String orderBy,
105+
@RequestParam(required = false) String createdBy) {
103106
App app = new App();
104107
app.setName(name);
105108
app.setSceneId(sceneId);
106109
app.setId(industryId);
107110
app.setFramework(framework);
108-
AppDto appDto = appService.queryAllAppByPage(currentPage, pageSize, app);
111+
app.setCreatedBy(createdBy);
112+
AppDto appDto = appService.queryAllAppByPage(currentPage, pageSize, orderBy, app);
109113
return Result.success(appDto);
110114
}
111115

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public class AppTemplateController {
6565
@Parameter(name = "industry", description = "行业"),
6666
@Parameter(name = "scene", description = "场景"),
6767
@Parameter(name = "framework", description = "技术栈"),
68+
@Parameter(name = "orderBy", description = "排序方式"),
69+
@Parameter(name = "createBy", description = "创建人"),
6870
}, responses = {
6971
@ApiResponse(responseCode = "200", description = "返回信息",
7072
content = @Content(mediaType = "application/json",
@@ -75,13 +77,15 @@ public class AppTemplateController {
7577
public Result<AppDto> getAllAppTemplateByPage(@RequestParam Integer currentPage,
7678
@RequestParam Integer pageSize, @RequestParam(required = false) String name,
7779
@RequestParam(required = false) Integer industryId, @RequestParam(required = false) Integer sceneId,
78-
@RequestParam(required = false) String framework) {
80+
@RequestParam(required = false) String framework, @RequestParam(required = false) String orderBy,
81+
@RequestParam(required = false) String createBy) {
7982
App app = new App();
8083
app.setName(name);
8184
app.setSceneId(sceneId);
8285
app.setId(industryId);
8386
app.setFramework(framework);
84-
AppDto appDto = appTemplateService.queryAllAppTemplate(currentPage, pageSize, app);
87+
app.setCreatedBy(createBy);
88+
AppDto appDto = appTemplateService.queryAllAppTemplate(currentPage, pageSize, orderBy, app);
8589
return Result.success(appDto);
8690
}
8791

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public interface AppMapper extends BaseMapper<App> {
4141
* @param industryId the industryId
4242
* @param sceneId the sceneId
4343
* @param framework the framework
44+
* @param orderBy the orderBy
45+
* @param createdBy the createdBy
4446
* @return the list
4547
*/
4648
List<App> queryAllAppByPage(Integer pageSize, Integer offset, String name,
47-
Integer industryId, Integer sceneId, String framework);
49+
Integer industryId, Integer sceneId, String framework, String orderBy, String createdBy);
4850

4951
/**
5052
* 查询表t_app 应用总数
@@ -70,10 +72,12 @@ List<App> queryAllAppByPage(Integer pageSize, Integer offset, String name,
7072
* @param industryId the industryId
7173
* @param sceneId the sceneId
7274
* @param framework the framework
75+
* @param orderBy the orderBy
76+
* @param createdBy the createdBy
7377
* @return the list
7478
*/
7579
List<App> queryAllAppTemplate(Integer pageSize, Integer offset, String name,
76-
Integer industryId, Integer sceneId, String framework);
80+
Integer industryId, Integer sceneId, String framework, String orderBy, String createdBy);
7781

7882
/**
7983
* 根据主键id查询应用模版数据

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ public interface AppService extends IService<App> {
3939
* 分页查询应用模版所有信息
4040
* @param currentPage the currentPage
4141
* @param pageSize the pageSize
42+
* @param orderBy the orderBy
4243
* @param app the app
4344
* @return the AppDto
4445
*/
45-
AppDto queryAllAppByPage(Integer currentPage, Integer pageSize, App app);
46+
AppDto queryAllAppByPage(Integer currentPage, Integer pageSize, String orderBy, App app);
4647

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ public interface AppTemplateService {
2323
* 分页查询应用模版所有信息
2424
* @param currentPage the currentPage
2525
* @param pageSize the pageSize
26+
* @param orderBy the orderBy
2627
* @param app the app
2728
* @return the AppDto
2829
*/
29-
AppDto queryAllAppTemplate(Integer currentPage, Integer pageSize, App app);
30+
AppDto queryAllAppTemplate(Integer currentPage, Integer pageSize, String orderBy, App app);
3031

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

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ public List<App> queryAllApp() {
8989
*
9090
* @param pageSize
9191
* @param currentPage
92+
* @param orderBy the orderBy
9293
* @return the AppDto
9394
*/
9495
@Override
95-
public AppDto queryAllAppByPage(Integer currentPage, Integer pageSize, App app) {
96+
public AppDto queryAllAppByPage(Integer currentPage, Integer pageSize, String orderBy, App app) {
9697
if (currentPage < 1) {
9798
currentPage = 1; // 默认第一页
9899
}
@@ -104,7 +105,7 @@ public AppDto queryAllAppByPage(Integer currentPage, Integer pageSize, App app)
104105
}
105106
int offset = (currentPage - 1) * pageSize;
106107
List<App> apps = this.baseMapper.queryAllAppByPage(pageSize, offset, app.getName(),
107-
app.getIndustryId(), app.getSceneId(), app.getFramework());
108+
app.getIndustryId(), app.getSceneId(), app.getFramework(), orderBy, app.getCreatedBy());
108109
Integer total = this.baseMapper.queryAppTotal();
109110
AppDto appDto = new AppDto();
110111
appDto.setApps(apps);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ public class AppTemplateServiceImpl extends ServiceImpl<AppMapper, App> implemen
9494
* 分页查询应用模版所有信息
9595
* @param currentPage the currentPage
9696
* @param pageSize the pageSize
97+
* @param orderBy the orderBy
9798
* @param app the app
9899
* @return the AppDto
99100
*/
100101
@Override
101-
public AppDto queryAllAppTemplate(Integer currentPage, Integer pageSize, App app) {
102+
public AppDto queryAllAppTemplate(Integer currentPage, Integer pageSize, String orderBy, App app) {
102103
if (currentPage < 1) {
103104
currentPage = 1; // 默认第一页
104105
}
@@ -111,7 +112,7 @@ public AppDto queryAllAppTemplate(Integer currentPage, Integer pageSize, App app
111112
int offset = (currentPage - 1) * pageSize;
112113

113114
List<App> apps = this.baseMapper.queryAllAppTemplate(pageSize, offset, app.getName(),
114-
app.getIndustryId(), app.getSceneId(), app.getFramework());
115+
app.getIndustryId(), app.getSceneId(), app.getFramework(), orderBy, app.getCreatedBy());
115116
Integer total = this.baseMapper.queryAppTemplateTotal();
116117
AppDto appDto = new AppDto();
117118
appDto.setApps(apps);

base/src/main/resources/mappers/AppMapper.xml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@
430430
SELECT
431431
<include refid="Common_Column_List"/>
432432
<include refid="Common_Join"/>
433-
WHERE A.is_template != true
433+
WHERE IS NOT TRUE
434434
ORDER BY A.created_time DESC
435435
</select>
436436

@@ -439,7 +439,7 @@
439439
<include refid="Common_Column_List"/>
440440
<include refid="Common_Join"/>
441441
<where>
442-
A.is_template != true
442+
A.is_template IS NOT TRUE
443443
<if test="name != null and name != ''">
444444
AND A.name LIKE CONCAT('%', #{name}, '%')
445445
</if>
@@ -452,8 +452,16 @@
452452
<if test="framework != null">
453453
AND A.framework = #{framework}
454454
</if>
455+
<if test="createdBy != null">
456+
AND A.created_by = #{createdBy}
457+
</if>
455458
</where>
456-
ORDER BY A.created_time DESC
459+
ORDER BY
460+
<choose>
461+
<when test="orderBy == 'create_time'">A.created_time</when>
462+
<when test="orderBy == 'last_updated_time'">A.last_updated_time</when>
463+
<otherwise>A.id</otherwise>
464+
</choose>
457465
LIMIT #{pageSize} OFFSET #{offset}
458466
</select>
459467

@@ -476,8 +484,17 @@
476484
<if test="framework != null">
477485
AND A.framework = #{framework}
478486
</if>
487+
<if test="createdBy != null">
488+
AND A.created_by = #{createdBy}
489+
</if>
479490
</where>
480-
ORDER BY A.created_time DESC
491+
ORDER BY
492+
<choose>
493+
<when test="orderBy == 'created_time'">A.created_time</when>
494+
<when test="orderBy == 'last_updated_time'">A.last_updated_time</when>
495+
<otherwise>A.id</otherwise>
496+
</choose>
497+
DESC
481498
LIMIT #{pageSize} OFFSET #{offset}
482499
</select>
483500

0 commit comments

Comments
 (0)