fix:删除代理商时同时删除用户角色关系。
This commit is contained in:
parent
29da542823
commit
fadc42f2c2
@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -124,10 +125,17 @@ public class AdminAgentService {
|
|||||||
log.warn("删除代理商时,ID列表为空");
|
log.warn("删除代理商时,ID列表为空");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
List<MpAgentEntity> agentList = mpAgentService.lambdaQuery().in(MpAgentEntity::getId, ids)
|
||||||
|
.select(MpAgentEntity::getContactUserId).list();
|
||||||
|
List<Integer> contactUserIdList = agentList.stream().map(MpAgentEntity::getContactUserId)
|
||||||
|
.filter(Objects::nonNull).toList();
|
||||||
|
log.info("待删除代理商关联的用户ID列表: {}", contactUserIdList);
|
||||||
boolean result = mpAgentService.removeByIds(ids);
|
boolean result = mpAgentService.removeByIds(ids);
|
||||||
log.info("删除代理商结果: {}", result);
|
log.info("删除代理商结果: {}", result);
|
||||||
if (result) {
|
if (result) {
|
||||||
log.info("删除代理商成功,ID列表: {}", ids);
|
log.info("删除代理商成功,ID列表: {}", ids);
|
||||||
|
// 删除关联的用户数据
|
||||||
|
userInfoServiceApi.deleteUserRoleByUserId(contactUserIdList);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -195,4 +195,7 @@ public interface UserInfoServiceApi {
|
|||||||
@GetMapping("/getUserIdByMobile")
|
@GetMapping("/getUserIdByMobile")
|
||||||
boolean getUserIdByMobile(@RequestParam("mobile") String mobile);
|
boolean getUserIdByMobile(@RequestParam("mobile") String mobile);
|
||||||
|
|
||||||
|
@DeleteMapping("/deleteUserRoleByUserIds")
|
||||||
|
boolean deleteUserRoleByUserId(@RequestParam("userIds") List<Integer> userIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -4,9 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.seer.teach.common.entity.BaseEntity;
|
import com.seer.teach.common.entity.BaseEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Builder;
|
import lombok.*;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -21,6 +19,8 @@ import lombok.Setter;
|
|||||||
@TableName("za_user_role")
|
@TableName("za_user_role")
|
||||||
@Schema(name = "UserRoleEntity对象", description = "")
|
@Schema(name = "UserRoleEntity对象", description = "")
|
||||||
@Builder
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class UserRoleEntity extends BaseEntity {
|
public class UserRoleEntity extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -327,6 +327,17 @@ public class UserInfoServiceApiImpl implements UserInfoServiceApi {
|
|||||||
return one == null;
|
return one == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteUserRoleByUserId(List<Integer> userIds) {
|
||||||
|
log.info("删除用户角色,用户id{}", userIds);
|
||||||
|
List<UserRoleEntity> userRolesList = userRoleService.lambdaQuery().in(UserRoleEntity::getUserId, userIds).list();
|
||||||
|
List<Integer> ids = userRolesList.stream().map(UserRoleEntity::getId).filter(Objects::nonNull).toList();
|
||||||
|
log.info("准备删除角色记录,ID列表: {}", ids);
|
||||||
|
boolean result = userRoleService.removeByIds(ids);
|
||||||
|
log.info("删除角色结果: {}", result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送更新孩子信息的MQ消息
|
* 推送更新孩子信息的MQ消息
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user