修复bug

This commit is contained in:
lulz1 2024-03-13 19:35:31 +08:00
parent 1b23c2c5a6
commit fb37fdb423
4 changed files with 25 additions and 3 deletions

View File

@ -43,7 +43,7 @@ public class OrderDetailQuery {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter);
LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter);
List<OrderDetail> orderDetailList = orderDetailRepository.findByCreateTimeBetween(targetTimeBegin,
List<OrderDetail> orderDetailList = orderDetailRepository.findByUpdateTimeBetween(targetTimeBegin,
targetTimeEnd);
List<Object> orderDetailResList = new ArrayList<>();
for (OrderDetail orderDetail : orderDetailList) {

View File

@ -22,5 +22,5 @@ public interface OrderDetailRepository {
void deleteById(Long id);
List<OrderDetail> findByCreateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd);
List<OrderDetail> findByUpdateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd);
}

View File

@ -62,8 +62,10 @@ public class OrderDetailRepositoryImpl implements OrderDetailRepository {
orderDetailRepository.deleteById(id);
}
@Override
public List<OrderDetail> findByCreateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd){
public List<OrderDetail> findByUpdateTimeBetween(LocalDateTime createTimeStart, LocalDateTime createTimeEnd){
return orderDetailRepository.findByCreateTimeBetween(createTimeStart,createTimeEnd);
}
}

View File

@ -0,0 +1,20 @@
package com.chint.infrastructure.repository.config;
import com.chint.domain.aggregates.base.BaseEntity;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.infrastructure.util.BaseContext;
import org.springframework.data.relational.core.conversion.MutableAggregateChange;
import org.springframework.data.relational.core.mapping.event.BeforeSaveCallback;
import java.time.LocalDateTime;
public class OrderDetailCallBackImpl implements BeforeSaveCallback<OrderDetail> {
@Override
public OrderDetail onBeforeSave(OrderDetail entity, MutableAggregateChange<OrderDetail> aggregateChange) {
if (entity.getCreateTime() == null) {
entity.setCreateTime(LocalDateTime.now());
}
entity.setUpdateTime(LocalDateTime.now());
return entity;
}
}