提交 | 用户 | 时间
|
48c57b
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
L |
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.MmSequenceNumDao; |
|
6 |
import com.iailab.module.model.mcs.pre.entity.MmSequenceNumEntity; |
|
7 |
import com.iailab.module.model.mcs.pre.service.MmSequenceNumService; |
|
8 |
import org.springframework.beans.factory.annotation.Autowired; |
|
9 |
import org.springframework.stereotype.Service; |
|
10 |
|
|
11 |
/** |
|
12 |
* @author PanZhibao |
|
13 |
* @date 2021年05月06日 13:20 |
|
14 |
*/ |
|
15 |
@Service |
|
16 |
public class MmSequenceNumServiceImpl extends ServiceImpl<MmSequenceNumDao, MmSequenceNumEntity> implements MmSequenceNumService { |
|
17 |
|
|
18 |
@Autowired |
|
19 |
private MmSequenceNumDao mmSequenceNumDao; |
|
20 |
|
|
21 |
@Override |
|
22 |
public synchronized MmSequenceNumEntity getAndIncreaseByCode (String code) { |
|
23 |
QueryWrapper queryWrapper = new QueryWrapper<MmSequenceNumEntity>(); |
|
24 |
queryWrapper.eq("code", code); |
|
25 |
MmSequenceNumEntity mmSequenceNumEntity = mmSequenceNumDao.selectOne(queryWrapper); |
|
26 |
|
|
27 |
MmSequenceNumEntity mmSequenceNumUpdate = new MmSequenceNumEntity(); |
|
28 |
mmSequenceNumUpdate.setId(mmSequenceNumEntity.getId()); |
|
29 |
mmSequenceNumUpdate.setSequenceNum(mmSequenceNumEntity.getSequenceNum() + 1); |
|
30 |
mmSequenceNumDao.updateById(mmSequenceNumUpdate); |
|
31 |
return mmSequenceNumEntity; |
|
32 |
} |
|
33 |
} |