提交 | 用户 | 时间
|
7fd198
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
潘 |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
5 |
import com.iailab.module.model.mcs.pre.dao.SequenceNumDao; |
|
6 |
import com.iailab.module.model.mcs.pre.entity.SequenceNumEntity; |
|
7 |
import com.iailab.module.model.mcs.pre.service.SequenceNumService; |
|
8 |
import org.springframework.stereotype.Service; |
|
9 |
|
|
10 |
/** |
|
11 |
* @author PanZhibao |
|
12 |
* @date 2021年05月06日 13:20 |
|
13 |
*/ |
|
14 |
@Service("sequenceNumService") |
|
15 |
public class SequenceNumServiceImpl extends ServiceImpl<SequenceNumDao, SequenceNumEntity> implements SequenceNumService { |
|
16 |
|
|
17 |
@Override |
|
18 |
public synchronized SequenceNumEntity getAndIncreaseByCode (String code) { |
|
19 |
QueryWrapper queryWrapper = new QueryWrapper<SequenceNumEntity>(); |
|
20 |
queryWrapper.eq("code", code); |
|
21 |
SequenceNumEntity sequenceNumEntity = this.getOne(queryWrapper); |
|
22 |
|
|
23 |
SequenceNumEntity sequenceNumUpdate = new SequenceNumEntity(); |
|
24 |
sequenceNumUpdate.setId(sequenceNumEntity.getId()); |
|
25 |
sequenceNumUpdate.setSequenceNum(sequenceNumEntity.getSequenceNum() + 1); |
|
26 |
this.updateById(sequenceNumUpdate); |
|
27 |
return sequenceNumEntity; |
|
28 |
} |
|
29 |
} |