【add】订单下载记录管理功能实现,实体类转换工具类新增
This commit is contained in:
parent
2185a22d62
commit
f3c27b8291
|
@ -1,5 +1,6 @@
|
|||
package com.chint.manage.controller;
|
||||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
|
@ -102,10 +103,9 @@ public class ManageController {
|
|||
}
|
||||
|
||||
@ApiOperation("订单下载记录查询接口")
|
||||
@PostMapping("/order/downloadRecord")
|
||||
public Result<?> orderDownloadRecord(){
|
||||
BaseContext.getCurrentUser();
|
||||
return null;
|
||||
@PostMapping("/order/downloadRecordQuery")
|
||||
public Result<?> orderDownloadRecordQuery(){
|
||||
return Result.Success(SUCCESS,manageService.orderDownloadRecordQuery());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.manage.entity;
|
||||
|
||||
import com.chint.manage.entity.query.OrderPageQuery;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -8,6 +9,8 @@ import org.springframework.data.annotation.Id;
|
|||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
|
@ -15,7 +18,7 @@ import java.util.Date;
|
|||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class OrderDownloadRecord {
|
||||
public class OrderDownloadRecord implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -24,11 +27,11 @@ public class OrderDownloadRecord {
|
|||
//文件名
|
||||
private String fileName;
|
||||
//查询条件
|
||||
private String queryCriteria;
|
||||
private OrderPageQuery queryCriteria;
|
||||
//执行时间
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
//过期时间
|
||||
private Date expireTime;
|
||||
private LocalDateTime expireTime;
|
||||
//员工ID
|
||||
private String employeeNo;
|
||||
//文件路径
|
||||
|
|
|
@ -4,6 +4,10 @@ import com.chint.manage.entity.OrderDownloadRecord;
|
|||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface JdbcOrderDownloadRecordRepository extends CrudRepository<OrderDownloadRecord, Long> {
|
||||
|
||||
List<OrderDownloadRecord> findAllByEmployeeNo(String employeeNo);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.chint.manage.service;
|
||||
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.manage.entity.OrderDownloadRecord;
|
||||
import com.chint.manage.entity.dto.ItineraryPageDto;
|
||||
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||
import com.chint.manage.entity.query.ItineraryPageQuery;
|
||||
|
@ -9,6 +10,7 @@ import com.chint.manage.entity.excel.BaseExcel;
|
|||
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -26,4 +28,8 @@ public interface ManageService {
|
|||
File standardExport(StandardQuery dto);
|
||||
|
||||
PageResult<ItineraryPageDto> orderPageQuery(ItineraryPageQuery dto);
|
||||
|
||||
void addOrderDownloadRecord(OrderDownloadRecord orderDownloadRecord);
|
||||
|
||||
List<OrderDownloadRecord> orderDownloadRecordQuery();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ import com.chint.domain.repository.UserRepository;
|
|||
import com.chint.domain.service.LegDomainService;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcUserRepository;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.manage.entity.OrderDownloadRecord;
|
||||
import com.chint.manage.entity.OrderExceedStandard;
|
||||
import com.chint.manage.entity.dto.ItineraryPageDto;
|
||||
import com.chint.manage.entity.excel.BaseExcel;
|
||||
|
@ -16,6 +18,7 @@ import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
|||
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||
import com.chint.manage.entity.query.ItineraryPageQuery;
|
||||
import com.chint.manage.entity.query.StandardQuery;
|
||||
import com.chint.manage.mapper.JdbcOrderDownloadRecordRepository;
|
||||
import com.chint.manage.mapper.JdbcOrderExceedStandardRepository;
|
||||
import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl;
|
||||
import com.chint.manage.service.ManageService;
|
||||
|
@ -52,6 +55,8 @@ public class ManageServiceImpl implements ManageService {
|
|||
private JdbcRouteRepository jdbcRouteRepository;
|
||||
@Autowired
|
||||
private JdbcUserRepository jdbcUserRepository;
|
||||
@Autowired
|
||||
private JdbcOrderDownloadRecordRepository jdbcOrderDownloadRecordRepository;
|
||||
|
||||
@Override
|
||||
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
|
||||
|
@ -110,6 +115,21 @@ public class ManageServiceImpl implements ManageService {
|
|||
return PageResult.totalPageNum(page.getTotalElements(), orders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrderDownloadRecord(OrderDownloadRecord orderDownloadRecord) {
|
||||
// User user= BaseContext.getCurrentUser();
|
||||
User user=new User();
|
||||
user.setEmployeeNo("123");
|
||||
orderDownloadRecord.setEmployeeNo(user.getEmployeeNo());
|
||||
jdbcOrderDownloadRecordRepository.save(orderDownloadRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderDownloadRecord> orderDownloadRecordQuery() {
|
||||
User user=BaseContext.getCurrentUser();
|
||||
return jdbcOrderDownloadRecordRepository.findAllByEmployeeNo(user.getEmployeeNo());
|
||||
}
|
||||
|
||||
private static List<OrderExceedStandardExcel> getOrderExceedStandardExcels(Page<OrderExceedStandard> page) {
|
||||
List<OrderExceedStandard> orderList = page.getContent();
|
||||
List<OrderExceedStandardExcel> excelList = new ArrayList<>();
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.chint.manage.util;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jdbc.core.convert.JdbcCustomConversions;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Configuration
|
||||
public class DataJdbcConfig {
|
||||
|
||||
@Bean
|
||||
public JdbcCustomConversions jdbcCustomConversions() {
|
||||
return new JdbcCustomConversions(Arrays.asList(
|
||||
new OrderPageQueryWriteConverter(),
|
||||
new OrderPageQueryReadConverter()
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.chint.manage.util;
|
||||
|
||||
import com.chint.manage.entity.query.OrderPageQuery;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.convert.ReadingConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@ReadingConverter
|
||||
public class OrderPageQueryReadConverter implements Converter<String, OrderPageQuery> {
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public OrderPageQuery convert(String source) {
|
||||
try {
|
||||
return objectMapper.readValue(source, OrderPageQuery.class);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to convert JSON to OrderPageQuery", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.chint.manage.util;
|
||||
|
||||
import com.chint.manage.entity.query.OrderPageQuery;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.convert.ReadingConverter;
|
||||
import org.springframework.data.convert.WritingConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@WritingConverter
|
||||
public class OrderPageQueryWriteConverter implements Converter<OrderPageQuery, String> {
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String convert(OrderPageQuery source) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(source);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException("Failed to convert OrderPageQuery to JSON", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,11 +3,13 @@ package com.chint;
|
|||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.manage.entity.OrderDownloadRecord;
|
||||
import com.chint.manage.entity.OrderExceedStandard;
|
||||
import com.chint.manage.entity.dto.ItineraryPageDto;
|
||||
import com.chint.manage.entity.excel.BaseExcel;
|
||||
import com.chint.manage.entity.query.ConsumptionDetailQuery;
|
||||
import com.chint.manage.entity.query.ItineraryPageQuery;
|
||||
import com.chint.manage.entity.query.OrderPageQuery;
|
||||
import com.chint.manage.mapper.JdbcOrderExceedStandardRepository;
|
||||
import com.chint.manage.mapper.impl.JdbcConsumptionDetailRepositoryImpl;
|
||||
import com.chint.manage.service.ManageService;
|
||||
|
@ -17,6 +19,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@SpringBootTest
|
||||
public class ManageTest {
|
||||
|
@ -30,6 +33,21 @@ public class ManageTest {
|
|||
private JdbcConsumptionDetailRepositoryImpl jdbcConsumptionDetailRepository;
|
||||
|
||||
|
||||
@Test
|
||||
void recordAdd(){
|
||||
OrderPageQuery dto=new OrderPageQuery();
|
||||
dto.setOderNo("123");
|
||||
OrderDownloadRecord downloadRecord=OrderDownloadRecord.builder()
|
||||
.createTime(new Date())
|
||||
.fileUrl("url")
|
||||
.status("已完成")
|
||||
.expireTime(new Date())
|
||||
.fileName("文件名")
|
||||
.queryCriteria(dto)
|
||||
.build();
|
||||
manageService.addOrderDownloadRecord(downloadRecord);
|
||||
}
|
||||
|
||||
@Test
|
||||
void pageQuery(){
|
||||
ItineraryPageQuery dto=new ItineraryPageQuery();
|
||||
|
|
Loading…
Reference in New Issue