修改排序的 bug。

This commit is contained in:
zhouxy108 2023-12-06 18:13:34 +08:00
parent 86fcd7a255
commit 81cefdca83
2 changed files with 40 additions and 4 deletions

View File

@ -0,0 +1,33 @@
package xyz.zhouxy.plusone;
import java.util.Collections;
import java.util.List;
import javax.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.system.application.query.AccountQueries;
import xyz.zhouxy.plusone.system.application.query.params.AccountQueryParams;
import xyz.zhouxy.plusone.system.application.query.result.AccountOverview;
@Slf4j
@SpringBootTest(classes = PlusoneApplication.class)
class AccountQueriesTests {
@Resource
AccountQueries accountQueries;
@Test
void testQueryPage() {
AccountQueryParams queryParams = new AccountQueryParams();
// queryParams.setOrderBy(List.of("email", "mobile_phone", "id"));
queryParams.setSize(20);
queryParams.setPageNum(1L);
queryParams.setOrderBy(Collections.emptyList());
List<AccountOverview> l = accountQueries.queryAccountOverview(queryParams);
log.info("l: {}", l);
}
}

View File

@ -87,10 +87,13 @@
AND sar.role_id = #{roleId}
AND sr.deleted = 0
</if>
<if test="orderBy != null">
ORDER BY sa.${orderBy}, sa.id
<if test="orderBy != null and !orderBy.isEmpty()">
ORDER BY
<foreach item="col" index="index" collection="orderBy" open="" separator="," close="">
sa.${col}
</foreach>
</if>
<if test="orderBy == null">
<if test="orderBy == null or orderBy.isEmpty()">
ORDER BY sa.id
</if>
LIMIT #{size} OFFSET #{offset}
@ -99,7 +102,7 @@
</select>
<!--
long count(SysAccountQuery queryParams);
long count(AccountQueryParams queryParams);
-->
<select id="count" resultType="long">
SELECT COUNT(*)