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.MmSequenceNumDao;
|
import com.iailab.module.model.mcs.pre.entity.MmSequenceNumEntity;
|
import com.iailab.module.model.mcs.pre.service.MmSequenceNumService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* @author PanZhibao
|
* @date 2021年05月06日 13:20
|
*/
|
@Service
|
public class MmSequenceNumServiceImpl extends ServiceImpl<MmSequenceNumDao, MmSequenceNumEntity> implements MmSequenceNumService {
|
|
@Autowired
|
private MmSequenceNumDao mmSequenceNumDao;
|
|
@Override
|
public synchronized MmSequenceNumEntity getAndIncreaseByCode (String code) {
|
QueryWrapper queryWrapper = new QueryWrapper<MmSequenceNumEntity>();
|
queryWrapper.eq("code", code);
|
MmSequenceNumEntity mmSequenceNumEntity = mmSequenceNumDao.selectOne(queryWrapper);
|
|
MmSequenceNumEntity mmSequenceNumUpdate = new MmSequenceNumEntity();
|
mmSequenceNumUpdate.setId(mmSequenceNumEntity.getId());
|
mmSequenceNumUpdate.setSequenceNum(mmSequenceNumEntity.getSequenceNum() + 1);
|
mmSequenceNumDao.updateById(mmSequenceNumUpdate);
|
return mmSequenceNumEntity;
|
}
|
}
|