PublicPoolServiceImpl.java
3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package cn.fw.valhalla.service.data.impl;
import cn.fw.valhalla.dao.mapper.PublicPoolMapper;
import cn.fw.valhalla.domain.db.pool.PublicPool;
import cn.fw.valhalla.domain.dto.PublicPoolDTO;
import cn.fw.valhalla.domain.dto.PublicPoolReportDTO;
import cn.fw.valhalla.domain.dto.PublicPoolReportQueryDTO;
import cn.fw.valhalla.domain.query.PublicPoolQueryVO;
import cn.fw.valhalla.service.data.PublicPoolService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* @author : kurisu
* @className : PublicPoolServiceImpl
* @description : 公共池
* @date: 2020-08-12 11:22
*/
@Slf4j
@Service
public class PublicPoolServiceImpl extends ServiceImpl<PublicPoolMapper, PublicPool> implements PublicPoolService {
@Override
public PublicPool queryByVin(final String vin, final Long groupId) {
return getOne(Wrappers.<PublicPool>lambdaQuery()
.eq(PublicPool::getGroupId, groupId)
.eq(PublicPool::getFrameNo, vin)
.last("limit 1")
);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void removeByCustomerId(Long customerId, Long groupId) {
remove(Wrappers.<PublicPool>lambdaQuery()
.eq(PublicPool::getCustomerId, customerId)
.eq(PublicPool::getGroupId, groupId)
);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void removeByVin(final String vin, final Long groupId) {
remove(Wrappers.<PublicPool>lambdaQuery()
.eq(PublicPool::getFrameNo, vin)
.eq(PublicPool::getGroupId, groupId)
);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void removeBatchByVin(final List<String> vinList, final Long groupId) {
if (CollectionUtils.isEmpty(vinList)) {
return;
}
remove(Wrappers.<PublicPool>lambdaQuery()
.in(PublicPool::getFrameNo, vinList)
.eq(PublicPool::getGroupId, groupId)
);
}
@Override
public List<PublicPoolDTO> publicList(PublicPoolQueryVO queryVO) {
Integer current = queryVO.getCurrent();
Integer pageSize = queryVO.getPageSize();
Integer startIndex = (current - 1) * pageSize;
return Optional.ofNullable(getBaseMapper().publicList(startIndex, pageSize, queryVO)).orElse(new ArrayList<>());
}
@Override
public Long publicListCount(PublicPoolQueryVO queryVO) {
return Optional.ofNullable(getBaseMapper().publicListCount(queryVO)).orElse(0L);
}
@Override
public List<String> queryIdListByShops(final List<Long> shopIds) {
if (CollectionUtils.isEmpty(shopIds)) {
return Collections.emptyList();
}
// mybatis plus 性能有问题 不使用
return Optional.ofNullable(this.getBaseMapper().queryIdListByShops(shopIds)).orElse(Collections.emptyList());
}
@Override
public List<PublicPoolReportDTO> countPublicPoolList(PublicPoolReportQueryDTO dto) {
return Optional.ofNullable(this.getBaseMapper().countPublicPoolList(dto)).orElse(Collections.emptyList());
}
}