| | |
| | | import com.iailab.module.model.mcs.pre.dao.SequenceNumDao; |
| | | import com.iailab.module.model.mcs.pre.entity.SequenceNumEntity; |
| | | import com.iailab.module.model.mcs.pre.service.SequenceNumService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * @author PanZhibao |
| | | * @date 2021年05月06日 13:20 |
| | | */ |
| | | @Service("sequenceNumService") |
| | | @Service |
| | | public class SequenceNumServiceImpl extends ServiceImpl<SequenceNumDao, SequenceNumEntity> implements SequenceNumService { |
| | | |
| | | @Autowired |
| | | private SequenceNumDao sequenceNumDao; |
| | | |
| | | @Override |
| | | public synchronized SequenceNumEntity getAndIncreaseByCode (String code) { |
| | | QueryWrapper queryWrapper = new QueryWrapper<SequenceNumEntity>(); |
| | | queryWrapper.eq("code", code); |
| | | SequenceNumEntity sequenceNumEntity = this.getOne(queryWrapper); |
| | | SequenceNumEntity sequenceNumEntity = sequenceNumDao.selectOne(queryWrapper); |
| | | |
| | | SequenceNumEntity sequenceNumUpdate = new SequenceNumEntity(); |
| | | sequenceNumUpdate.setId(sequenceNumEntity.getId()); |
| | | sequenceNumUpdate.setSequenceNum(sequenceNumEntity.getSequenceNum() + 1); |
| | | this.updateById(sequenceNumUpdate); |
| | | sequenceNumDao.updateById(sequenceNumUpdate); |
| | | return sequenceNumEntity; |
| | | } |
| | | } |