|
@@ -21,9 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -45,17 +43,13 @@ public class QrCodeServiceImpl extends ServiceImpl<QrCodeMapper, QrCode> impleme
|
|
|
|
|
|
@Override
|
|
|
public boolean add(QrCode qrCode) {
|
|
|
- try {
|
|
|
- Optional.ofNullable(qrCode.getTopChannelId())
|
|
|
- .filter(cId -> 0L != cId)
|
|
|
- .orElseThrow(() ->new CustomException("渠道编号不能为空"));
|
|
|
- TopChannel topChannel = topChannelService.getById(qrCode.getTopChannelId());
|
|
|
- Optional.ofNullable(topChannel)
|
|
|
- .orElseThrow(() ->new CustomException("渠道不能为空"));
|
|
|
- qrCode.setCreateBy(SecurityUtils.getUsername());
|
|
|
- }catch (Exception e){
|
|
|
- throw new CustomException("生成二维码图片失败");
|
|
|
- }
|
|
|
+ Optional.ofNullable(qrCode.getTopChannelId())
|
|
|
+ .filter(cId -> 0L != cId)
|
|
|
+ .orElseThrow(() ->new CustomException("渠道编号不能为空"));
|
|
|
+ TopChannel topChannel = topChannelService.getById(qrCode.getTopChannelId());
|
|
|
+ Optional.ofNullable(topChannel)
|
|
|
+ .orElseThrow(() ->new CustomException("渠道不能为空"));
|
|
|
+ qrCode.setCreateBy(SecurityUtils.getUsername());
|
|
|
return this.save(qrCode);
|
|
|
}
|
|
|
|
|
@@ -78,11 +72,8 @@ public class QrCodeServiceImpl extends ServiceImpl<QrCodeMapper, QrCode> impleme
|
|
|
String payPath = sysConfigService.selectConfigByKey("app.pay.path");
|
|
|
IPage<QrCode> page = new Page<>(current, size);
|
|
|
page = baseMapper.list(page,name);
|
|
|
- List<QrCode> collect = page.getRecords()
|
|
|
- .stream()
|
|
|
- .peek(qrCode -> qrCode.setQrPath(String.format("%s%s", payPath, qrCode.getTopChannelId())))
|
|
|
- .collect(Collectors.toList());
|
|
|
- return new CommonPage<>(collect,page.getTotal(),page.getCurrent(),page.getSize());
|
|
|
+ page.getRecords().forEach(qrCode -> qrCode.setQrPath(String.format("%s%s", payPath, qrCode.getTopChannelId())));
|
|
|
+ return new CommonPage<>(page.getRecords(),page.getTotal(),page.getCurrent(),page.getSize());
|
|
|
}
|
|
|
|
|
|
@Override
|