合并更新 #1
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.ticket.controller.admin.checkticket.vo.vo.CheckTi
|
||||
import cn.iocoder.yudao.module.ticket.controller.admin.checkticket.vo.vo.CheckTicketSaveReqVO;
|
||||
import cn.iocoder.yudao.module.ticket.dal.dataobject.checkticket.CheckTicket;
|
||||
import cn.iocoder.yudao.module.ticket.dal.mongodb.checkticket.CheckTicketRepository;
|
||||
import com.mongodb.MongoException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -118,11 +119,13 @@ public class CheckTicketServiceImpl implements CheckTicketService {
|
||||
@Override
|
||||
public String createCheckTicketByMongoDB(CheckTicketSaveReqDTO checkTicketSaveReqDTO) {
|
||||
CheckTicket checkTicket = BeanUtils.toBean(checkTicketSaveReqDTO, CheckTicket.class);
|
||||
// TODO 插入失败会自动抛出异常,需要对异常进行处理
|
||||
// DuplicateKeyException:当插入的文档违反唯一索引约束时,会抛出此异常。
|
||||
// MongoWriteException:在写入操作中发生的其他错误,例如文档格式不正确或数据库连接问题。
|
||||
try {
|
||||
// 执行插入操作
|
||||
checkTicketRepository.insert(checkTicket);
|
||||
return "添加成功";
|
||||
} catch (MongoException e){
|
||||
return "Mongo数据库写入异常";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.ticket.api.saledata.dto.SaleDataSaveReqDTO;
|
||||
import cn.iocoder.yudao.module.ticket.dal.dataobject.saledata.SaleData;
|
||||
import cn.iocoder.yudao.module.ticket.dal.mongodb.saledata.SaleDataRepository;
|
||||
import com.mongodb.MongoException;
|
||||
import kotlin.jvm.internal.Lambda;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -189,6 +190,7 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
wrapperX.between(SaleDataDO::getSddate, start, end).select(SaleDataDO::getCertificateno, SaleDataDO::getAmount);
|
||||
return saleDataMapper.selectList(wrapperX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaleDataDO> findEventsThisYear() {
|
||||
DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
@ -242,7 +244,6 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> findBySaleMethod() {
|
||||
List<SaleDataDO> saleDataList = saleDataMapper.selectList(new LambdaQueryWrapperX<SaleDataDO>().select(SaleDataDO::getTransactiontypeno));
|
||||
@ -435,8 +436,13 @@ public class SaleDataServiceImpl implements SaleDataService {
|
||||
@Override
|
||||
public String createSaleDataByMongoDB(SaleDataSaveReqDTO saleDataSaveReqDTO) {
|
||||
SaleData saleData = BeanUtils.toBean(saleDataSaveReqDTO, SaleData.class);
|
||||
try {
|
||||
saleDataRepository.insert(saleData);
|
||||
return "添加成功";
|
||||
} catch (MongoException e) {
|
||||
return "Mongo数据库写入异常";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user