diff --git a/mateclaw-server/src/main/java/vip/mate/MateClawApplication.java b/mateclaw-server/src/main/java/vip/mate/MateClawApplication.java index bd54f768..0d699cbb 100644 --- a/mateclaw-server/src/main/java/vip/mate/MateClawApplication.java +++ b/mateclaw-server/src/main/java/vip/mate/MateClawApplication.java @@ -1,6 +1,5 @@ package vip.mate; -import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.mybatis.spring.annotation.MapperScan; @@ -33,12 +32,17 @@ public class MateClawApplication { } /** - * MyBatis Plus 分页插件 + * MyBatis Plus pagination plugin. + * + *
DbType is auto-detected from the JDBC connection at runtime rather + * than hardcoded. Hardcoding H2 here meant the MySQL deployment used + * the H2 dialect for the count query, which silently returned 0 — + * frontends saw records but total=0 and couldn't paginate (RFC-042 P0). */ @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); - interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2)); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); return interceptor; } } diff --git a/mateclaw-ui/src/views/SkillMarket.vue b/mateclaw-ui/src/views/SkillMarket.vue index 7d4779b7..c8b30ec5 100644 --- a/mateclaw-ui/src/views/SkillMarket.vue +++ b/mateclaw-ui/src/views/SkillMarket.vue @@ -416,8 +416,20 @@ async function loadSkills() { const res: any = await skillApi.page(params) const data = res.data || {} - skills.value = data.records || [] - total.value = data.total || 0 + const records: Skill[] = Array.isArray(data.records) ? data.records : [] + skills.value = records + // Defensive total: if the backend pagination count is broken (seen with the + // old hardcoded-H2 MyBatisPlus interceptor on MySQL), infer a floor so the + // user can at least reach the next page. The real total overrides this. + const reportedTotal = Number(data.total) || 0 + const inferredMin = records.length >= query.size + ? query.page * query.size + 1 // at least one more page exists + : (query.page - 1) * query.size + records.length + total.value = Math.max(reportedTotal, inferredMin) + if (records.length > 0 && reportedTotal === 0) { + // eslint-disable-next-line no-console + console.warn('[SkillMarket] backend returned records but total=0; rebuild server JAR to pick up the DbType fix') + } } catch (e) { skills.value = [] total.value = 0