Forráskód Böngészése

修改子账号编辑出现脏数据问题

liudongzhi 1 hónapja
szülő
commit
05365b5b85

+ 10 - 0
alien-entity/src/main/java/shop/alien/mapper/StorePlatformUserRoleMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
 import shop.alien.entity.store.StorePlatformUserRole;
 import shop.alien.entity.store.vo.SubAccountListVo;
 import shop.alien.entity.store.vo.SubAccountVo;
@@ -47,5 +48,14 @@ public interface StorePlatformUserRoleMapper extends BaseMapper<StorePlatformUse
                                                 @Param("accountId") String accountId,
                                                 @Param("phone") String phone,
                                                 @Param("status") Integer status);
+
+    /**
+     * 回滚删除操作:恢复角色关联记录
+     *
+     * @param id 记录ID
+     * @return 更新影响的行数
+     */
+    @Update("UPDATE store_platform_user_role SET delete_flag = 0 WHERE id = #{id} AND delete_flag = 1")
+    int rollbackDeleteById(@Param("id") Long id);
 }
 

+ 2 - 8
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StorePlatformUserRoleServiceImpl.java

@@ -811,10 +811,7 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
                     log.warn("创建新账号失败,执行回滚操作: phone={}, storeId={}, roleId={}, error={}", 
                             phone, storeId, roleId, createResult.getMsg());
                     
-                    LambdaUpdateWrapper<StorePlatformUserRole> rollbackWrapper = new LambdaUpdateWrapper<>();
-                    rollbackWrapper.eq(StorePlatformUserRole::getId, id)
-                            .set(StorePlatformUserRole::getDeleteFlag, 0);
-                    int rollbackResult = storePlatformUserRoleMapper.update(null, rollbackWrapper);
+                    int rollbackResult = storePlatformUserRoleMapper.rollbackDeleteById(Long.valueOf(id));
                     
                     if (rollbackResult > 0) {
                         log.info("成功回滚,恢复角色关联记录: id={}, userId={}, storeId={}, roleId={}", 
@@ -835,10 +832,7 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
             
             // 异常情况下也尝试回滚
             try {
-                LambdaUpdateWrapper<StorePlatformUserRole> rollbackWrapper = new LambdaUpdateWrapper<>();
-                rollbackWrapper.eq(StorePlatformUserRole::getId, id)
-                        .set(StorePlatformUserRole::getDeleteFlag, 0);
-                int rollbackResult = storePlatformUserRoleMapper.update(null, rollbackWrapper);
+                int rollbackResult = storePlatformUserRoleMapper.rollbackDeleteById(Long.valueOf(id));
                 if (rollbackResult > 0) {
                     log.info("异常情况下成功回滚,恢复角色关联记录: id={}", id);
                 }