package com.iailab.module.model.mcs.pre.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.stereotype.Service;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年05月06日 13:20
|
*/
|
@Service("sequenceNumService")
|
public class SequenceNumServiceImpl extends ServiceImpl<SequenceNumDao, SequenceNumEntity> implements SequenceNumService {
|
|
@Override
|
public synchronized SequenceNumEntity getAndIncreaseByCode (String code) {
|
QueryWrapper queryWrapper = new QueryWrapper<SequenceNumEntity>();
|
queryWrapper.eq("code", code);
|
SequenceNumEntity sequenceNumEntity = this.getOne(queryWrapper);
|
|
SequenceNumEntity sequenceNumUpdate = new SequenceNumEntity();
|
sequenceNumUpdate.setId(sequenceNumEntity.getId());
|
sequenceNumUpdate.setSequenceNum(sequenceNumEntity.getSequenceNum() + 1);
|
this.updateById(sequenceNumUpdate);
|
return sequenceNumEntity;
|
}
|
}
|