fix: 修复还有多少天变成负数的问题

This commit is contained in:
jsh
2025-10-12 14:27:19 +08:00
parent 0200382ddf
commit 363bcb83c6
2 changed files with 3 additions and 3 deletions

View File

@@ -36,7 +36,7 @@ create table habit_record
update_time datetime null,
name varchar(100) not null,
date date not null comment '重要的日期',
type enum ('anniversary', 'commemoration') default 'anniversary' not null
type enum ('ANNIVERSARY', 'COMMEMORATION') default 'ANNIVERSARY' not null
)
comment '周年纪念日';

View File

@@ -35,9 +35,9 @@ public class AnniversaryServiceImpl extends ServiceImpl<AnniversaryMapper, Anniv
date = date.withYear(now.getYear() + 1);
}
aList.add(new AnniversaryRecord(anniversary.getName(), date.toString(), (int) ChronoUnit.DAYS.between(date, now)));
aList.add(new AnniversaryRecord(anniversary.getName(), date.toString(), (int) ChronoUnit.DAYS.between(now, date)));
} else if (anniversary.getType() == AnniversaryEnum.COMMEMORATION) {
bList.add(new AnniversaryRecord(anniversary.getName(), anniversary.getDate().toString(), (int) ChronoUnit.DAYS.between(now, anniversary.getDate())));
bList.add(new AnniversaryRecord(anniversary.getName(), anniversary.getDate().toString(), (int) ChronoUnit.DAYS.between(anniversary.getDate(), now)));
}
}