|
@@ -1,97 +1,137 @@
|
|
|
package com.boman.web.core.service.vaccineInfo.impl;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import com.boman.common.core.utils.DateUtils;
|
|
|
+import com.boman.common.core.utils.SecurityUtils;
|
|
|
import com.boman.web.core.domain.VaccineInfoOperation;
|
|
|
+import com.boman.web.core.mapper.VaccineInfoOperationMapper;
|
|
|
import com.boman.web.core.service.vaccineInfo.IVaccineInfoService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.boman.web.core.mapper.VaccineInfoMapper;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
/**
|
|
|
* 疫苗信息Service业务层处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
* @date 2021-09-05
|
|
|
*/
|
|
|
@Service
|
|
|
-public class VaccineInfoServiceImpl implements IVaccineInfoService
|
|
|
-{
|
|
|
+public class VaccineInfoServiceImpl implements IVaccineInfoService {
|
|
|
+
|
|
|
+ private static final String INSERT = "insert";
|
|
|
+ private static final String EDIT = "edit";
|
|
|
+ private static final String DELETE = "delete";
|
|
|
+
|
|
|
@Autowired
|
|
|
private VaccineInfoMapper vaccineInfoMapper;
|
|
|
+ @Autowired
|
|
|
+ private VaccineInfoOperationMapper vaccineInfoOperationMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询疫苗信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param id 疫苗信息ID
|
|
|
* @return 疫苗信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public VaccineInfoOperation selectVaccineInfoById(Long id)
|
|
|
- {
|
|
|
+ public VaccineInfoOperation selectVaccineInfoById(Long id) {
|
|
|
return vaccineInfoMapper.selectVaccineInfoById(id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询疫苗信息列表
|
|
|
- *
|
|
|
- * @param vaccineInfo 疫苗信息
|
|
|
+ *
|
|
|
+ * @param vaccineInfoOperation 疫苗信息
|
|
|
* @return 疫苗信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<VaccineInfoOperation> selectVaccineInfoList(VaccineInfoOperation vaccineInfo)
|
|
|
- {
|
|
|
- return vaccineInfoMapper.selectVaccineInfoList(vaccineInfo);
|
|
|
+ public List<VaccineInfoOperation> selectVaccineInfoList(VaccineInfoOperation vaccineInfoOperation) {
|
|
|
+ return vaccineInfoMapper.selectVaccineInfoList(vaccineInfoOperation);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增疫苗信息
|
|
|
- *
|
|
|
- * @param vaccineInfo 疫苗信息
|
|
|
+ *
|
|
|
+ * @param vaccineInfoOperation 疫苗信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertVaccineInfo(VaccineInfoOperation vaccineInfo)
|
|
|
- {
|
|
|
- vaccineInfo.setCreateTime(DateUtils.getNowDate());
|
|
|
- return vaccineInfoMapper.insertVaccineInfo(vaccineInfo);
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
|
|
|
+ public int insertVaccineInfo(VaccineInfoOperation vaccineInfoOperation) {
|
|
|
+ // 疫苗信息
|
|
|
+ vaccineInfoOperation.setCreateTime(DateUtils.getNowDate());
|
|
|
+ int info = vaccineInfoMapper.insertVaccineInfo(vaccineInfoOperation);
|
|
|
+
|
|
|
+ // 疫苗信息新增操作记录
|
|
|
+ vaccineInfoOperation.setOperationType(INSERT);
|
|
|
+ vaccineInfoOperation.setVaccineInfoId(vaccineInfoOperation.getId());
|
|
|
+ vaccineInfoOperation.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ vaccineInfoOperationMapper.insertVaccineInfoOperation(vaccineInfoOperation);
|
|
|
+
|
|
|
+ return info;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改疫苗信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param vaccineInfo 疫苗信息
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateVaccineInfo(VaccineInfoOperation vaccineInfo)
|
|
|
- {
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class)
|
|
|
+ public int updateVaccineInfo(VaccineInfoOperation vaccineInfo) {
|
|
|
vaccineInfo.setUpdateTime(DateUtils.getNowDate());
|
|
|
- return vaccineInfoMapper.updateVaccineInfo(vaccineInfo);
|
|
|
+ int info = vaccineInfoMapper.updateVaccineInfo(vaccineInfo);
|
|
|
+
|
|
|
+ // 疫苗信息新增操作记录
|
|
|
+ vaccineInfo.setOperationType(EDIT);
|
|
|
+ vaccineInfo.setCreateTime(new Date());
|
|
|
+ vaccineInfo.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ vaccineInfo.setVaccineInfoId(vaccineInfo.getId());
|
|
|
+ vaccineInfoOperationMapper.insertVaccineInfoOperation(vaccineInfo);
|
|
|
+ return info;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量删除疫苗信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param ids 需要删除的疫苗信息ID
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteVaccineInfoByIds(Long[] ids)
|
|
|
- {
|
|
|
+ public int deleteVaccineInfoByIds(Long[] ids) {
|
|
|
+ List<VaccineInfoOperation> vaccineInfos = vaccineInfoMapper.selectVaccineInfoByIds(ids);
|
|
|
+ String userName = SecurityUtils.getUsername();
|
|
|
+ for(VaccineInfoOperation vaccineInfoOperation : vaccineInfos) {
|
|
|
+ // 疫苗信息新增操作记录
|
|
|
+ vaccineInfoOperation.setOperationType(DELETE);
|
|
|
+ vaccineInfoOperation.setCreateTime(new Date());
|
|
|
+ vaccineInfoOperation.setCreateBy(userName);
|
|
|
+ vaccineInfoOperation.setVaccineInfoId(vaccineInfoOperation.getId());
|
|
|
+ vaccineInfoOperationMapper.insertVaccineInfoOperation(vaccineInfoOperation);
|
|
|
+ }
|
|
|
+
|
|
|
return vaccineInfoMapper.deleteVaccineInfoByIds(ids);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除疫苗信息信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param id 疫苗信息ID
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteVaccineInfoById(Long id)
|
|
|
- {
|
|
|
+ public int deleteVaccineInfoById(Long id) {
|
|
|
+ VaccineInfoOperation vaccineInfo = vaccineInfoMapper.selectVaccineInfoById(id);
|
|
|
+ vaccineInfo.setVaccineInfoId(id);
|
|
|
+ vaccineInfo.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ vaccineInfo.setCreateTime(new Date());
|
|
|
+ vaccineInfo.setOperationType(DELETE);
|
|
|
return vaccineInfoMapper.deleteVaccineInfoById(id);
|
|
|
}
|
|
|
}
|