优化快照功能 更新sql文件

This commit is contained in:
徐唯轩
2023-11-23 11:00:50 +08:00
parent 690f9cfe4c
commit 0e255d6c3a
4 changed files with 8673 additions and 7607 deletions

File diff suppressed because one or more lines are too long

8644
sql/yshop_pro.sql Normal file

File diff suppressed because one or more lines are too long

View File

@ -163,6 +163,7 @@ public interface ErrorCodeConstants {
// ========== 站内信发送 1002028000 ========== // ========== 站内信发送 1002028000 ==========
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1002025000, "模板参数({})缺失"); ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1002025000, "模板参数({})缺失");
ErrorCode BACKUP_NO_BACKUP = new ErrorCode(100202711, "请先备份数据再还原备份!");
ErrorCode BACKUP_MANY = new ErrorCode(100202701, "备份太频繁距离上一次备份未超过5分钟"); ErrorCode BACKUP_MANY = new ErrorCode(100202701, "备份太频繁距离上一次备份未超过5分钟");
} }

View File

@ -26,6 +26,7 @@ import java.util.stream.Collectors;
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception; import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
import static co.yixiang.yshop.module.system.enums.ErrorCodeConstants.BACKUP_MANY; import static co.yixiang.yshop.module.system.enums.ErrorCodeConstants.BACKUP_MANY;
import static co.yixiang.yshop.module.system.enums.ErrorCodeConstants.BACKUP_NO_BACKUP;
/** /**
* 品牌 Service 实现类 * 品牌 Service 实现类
@ -46,10 +47,10 @@ public class BackupRecordServiceImpl extends ServiceImpl<BackupRecordMapper, Ba
private AdminUserService adminUserService; private AdminUserService adminUserService;
private static final String orderCountKey = "yshop_order_count_cache:*"; private static final String orderCountKey = "yshop_order_count_cache:*";
private static final String orderAdminCountKey = "yshop_admin_order_count_cache:*"; private static final String orderAdminCountKey = "yshop_admin_order_count_cache:*";
@Override @Override
public PageResult<BackupRecordRespVO> backupPageList(BackupPageReqVO pageVO) { public PageResult<BackupRecordRespVO> backupPageList(BackupPageReqVO pageVO) {
PageResult<BackupRecordDO> pageResult = this.baseMapper.selectPage(pageVO); PageResult<BackupRecordDO> pageResult = this.baseMapper.selectPage(pageVO);
@ -101,13 +102,14 @@ public class BackupRecordServiceImpl extends ServiceImpl<BackupRecordMapper, Ba
BackupRecordDO backupRecordDO = backupRecordMapper.selectOne(new LambdaQueryWrapper<BackupRecordDO>().orderByDesc( BackupRecordDO backupRecordDO = backupRecordMapper.selectOne(new LambdaQueryWrapper<BackupRecordDO>().orderByDesc(
BackupRecordDO::getId BackupRecordDO::getId
).last("limit 1")); ).last("limit 1"));
if(backupRecordDO!=null) {
if (backupRecordDO.getUpdateTime().plusMinutes(5).isAfter(LocalDateTime.now()) && Long count = backupRecordMapper.selectCount();
!backupRecordDO.getCreateTime().isEqual(backupRecordDO.getUpdateTime())) { if (backupRecordDO == null) throw exception(BACKUP_NO_BACKUP);
if (backupRecordDO.getUpdateTime().plusMinutes(5).isAfter(LocalDateTime.now()) && count > 1) {
throw exception(BACKUP_MANY); throw exception(BACKUP_MANY);
} }
}
this.baseMapper.revertBackup(); this.baseMapper.revertBackup();
backupRecordDO.setUpdateTime(LocalDateTime.now());
this.baseMapper.updateById(backupRecordDO); this.baseMapper.updateById(backupRecordDO);
//清除redis信息 //清除redis信息
Set<String> orderCountKeys = stringRedisTemplate.keys(orderCountKey); Set<String> orderCountKeys = stringRedisTemplate.keys(orderCountKey);