Commit 09803e79 by 杨卫

feat:调整登录用户信息

1 parent 33fac8ce
......@@ -156,19 +156,15 @@ public class DataPermissionAspect {
private List<Long> resolveAllowedUserIds(LoginUserDTO currentUser) {
Long roleId = currentUser.getRoleId();
Long orgId = currentUser.getOrgId();
Long groupId = currentUser.getGroupId();
// 兼容历史代码
String roleCode = currentUser.getRoleCode();
orgId = VrRoleCodeEnum.GROUP_ACCOUNT.getCode().equals(roleCode) ? groupId : orgId;
if (roleId == null || orgId == null) {
return Collections.emptyList();
}
VrRole role = vrRoleRepository.findByIdAndDeleteFlag(roleId, DeleteFlag.NOT_DELETED.getCode())
.orElse(null);
if (role == null) {
return Collections.emptyList();
}
String roleCode = role.getRoleCode();
// 集团账号:查询集团及旗下所有门店的用户
if (VrRoleCodeEnum.GROUP_ACCOUNT.getCode().equals(roleCode)) {
return vrUserOrgRepository.findUserIdsByGroupId(orgId);
......@@ -193,19 +189,15 @@ public class DataPermissionAspect {
private List<Long> resolveAllowedOrgIds(LoginUserDTO currentUser) {
Long roleId = currentUser.getRoleId();
Long orgId = currentUser.getOrgId();
Long groupId = currentUser.getGroupId();
// 兼容历史代码
String roleCode = currentUser.getRoleCode();
orgId = VrRoleCodeEnum.GROUP_ACCOUNT.getCode().equals(roleCode) ? groupId : orgId;
if (roleId == null || orgId == null) {
return Collections.emptyList();
}
VrRole role = vrRoleRepository.findByIdAndDeleteFlag(roleId, DeleteFlag.NOT_DELETED.getCode())
.orElse(null);
if (role == null) {
return Collections.emptyList();
}
String roleCode = role.getRoleCode();
// 集团账号:集团本身 + 旗下所有门店
if (VrRoleCodeEnum.GROUP_ACCOUNT.getCode().equals(roleCode)) {
List<Long> orgIds = new ArrayList<>();
......
......@@ -17,7 +17,17 @@ public class LoginUserDTO implements Serializable {
private Long userId;
private String phone;
private String userName;
// 角色
private String roleCode;
private Long roleId;
private String roleName;
// 门店
private Long orgId;
private String orgName;
// 集团
private Long groupId;
private String groupName;
}
......@@ -1293,6 +1293,17 @@ public class VrAuditService {
vo.setSnapshotVehicleAmount(snapshot.getVehicleAmount());
vo.setSnapshotDealPrice(snapshot.getDealPrice());
vo.setSnapshotTotalAmount(snapshot.getTotalAmount());
vo.setSnapshotCarBrandId(snapshot.getCarBrandId());
vo.setSnapshotCarBrand(snapshot.getCarBrand());
vo.setSnapshotCarChildsBrandId(snapshot.getCarChildsBrandId());
vo.setSnapshotCarChildsBrandName(snapshot.getCarChildsBrandName());
vo.setSnapshotCarSeriesId(snapshot.getCarSeriesId());
vo.setSnapshotCarSeriesName(snapshot.getCarSeriesName());
vo.setSnapshotCarTypeId(snapshot.getCarTypeId());
vo.setSnapshotCarTypeName(snapshot.getCarTypeName());
vo.setSnapshotLicensePlate(snapshot.getLicensePlate());
vo.setSnapshotVin(snapshot.getVin());
}
log.info("获取发拍单订单详情成功,id={},publishNo={}", id, vrAudit.getPublishNo());
......
package com.glsx.usedcar.module.vrsystem.service;
import cn.hutool.core.util.StrUtil;
import com.glsx.usedcar.enums.common.DeleteFlag;
import com.glsx.usedcar.module.vrsystem.config.VrLoginProperties;
import com.glsx.usedcar.module.vrsystem.dto.LoginUserDTO;
import com.glsx.usedcar.module.vrsystem.dao.VrOrgRepository;
import com.glsx.usedcar.module.vrsystem.entity.VrOrg;
import com.glsx.usedcar.module.vrsystem.entity.VrRole;
import com.glsx.usedcar.module.vrsystem.entity.VrUser;
......@@ -33,6 +35,7 @@ public class VrLoginService {
private final VrUserService vrUserService;
private final VrRoleService vrRoleService;
private final VrOrgService vrOrgService;
private final VrOrgRepository vrOrgRepository;
private final PasswordEncoder passwordEncoder;
private final RedisTokenUtil redisTokenUtil;
private final StringRedisTemplate redisTemplate;
......@@ -123,13 +126,39 @@ public class VrLoginService {
VrRole role = vrUserService.getUserRole(user.getId());
if (role != null) {
userDTO.setRoleCode(role.getRoleCode());
userDTO.setRoleName(role.getRoleName());
userDTO.setRoleId(role.getId());
}
// 获取组织信息
VrOrg org = vrUserService.getUserOrg(user.getId());
Long groupId = null;
String groupName = null;
Long storeId = null;
String storeName = null;
if (org != null) {
userDTO.setOrgId(org.getId());
if (org.getOrgType() != null && org.getOrgType() == 1) {
// 集团账号
groupId = org.getId();
groupName = org.getOrgName();
} else if (org.getOrgType() != null && org.getOrgType() == 2) {
// 门店账号
storeId = org.getId();
storeName = org.getOrgName();
// 查询所属集团
if (org.getParentId() != null && org.getParentId() > 0) {
VrOrg groupOrg = vrOrgRepository.findByIdAndDeleteFlag(org.getParentId(), DeleteFlag.NOT_DELETED.getCode()).orElse(null);
if (groupOrg != null) {
groupId = groupOrg.getId();
groupName = groupOrg.getOrgName();
}
}
}
userDTO.setGroupId(groupId);
userDTO.setGroupName(groupName);
userDTO.setOrgId(storeId);
userDTO.setOrgName(storeName);
}
// 生成并存储Token
......@@ -148,8 +177,10 @@ public class VrLoginService {
.roleId(role != null ? role.getId() : null)
.roleCode(role != null ? role.getRoleCode() : null)
.roleName(role != null ? role.getRoleName() : null)
.orgId(org != null ? org.getId() : null)
.orgName(org != null ? org.getOrgName() : null)
.orgId(storeId)
.orgName(storeName)
.groupId(groupId)
.groupName(groupName)
.build();
}
......@@ -209,10 +240,10 @@ public class VrLoginService {
}
// 查询组织名称
String orgName = null;
if (userDTO.getOrgId() != null) {
orgName = vrOrgService.getOrgNameById(userDTO.getOrgId());
}
Long groupId = userDTO.getGroupId();
String groupName = userDTO.getGroupName();
Long storeId = userDTO.getOrgId();
String storeName = userDTO.getOrgName();
VrLoginUserVO rtn = VrLoginUserVO.builder()
.userId(userDTO.getUserId())
......@@ -221,7 +252,10 @@ public class VrLoginService {
.roleId(userDTO.getRoleId())
.orgId(userDTO.getOrgId())
.roleCode(userDTO.getRoleCode())
.orgName(orgName)
.orgId(storeId)
.orgName(storeName)
.groupId(groupId)
.groupName(groupName)
.build();
Optional.ofNullable(userDTO.getRoleId())
......
......@@ -2,7 +2,13 @@ package com.glsx.usedcar.module.vrsystem.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.*;
import org.summerframework.orm.validator.CreateValidGroup;
import org.summerframework.orm.validator.UpdateValidGroup;
import java.math.BigDecimal;
import java.time.LocalDateTime;
......@@ -173,4 +179,64 @@ public class VrAuditOrderDetailRespVO {
@Schema(description = "快照总金额(元)")
private BigDecimal snapshotTotalAmount;
/**
* 车辆品牌ID
*/
@Schema(description = "快照车辆品牌ID")
private Integer snapshotCarBrandId;
/**
* 车辆品牌名称
*/
@Schema(description = "快照车辆品牌名称")
private String snapshotCarBrand;
/**
* 车辆子品牌ID
*/
@Schema(description = "快照车辆子品牌ID")
private Integer snapshotCarChildsBrandId;
/**
* 车辆子品牌名称
*/
@Schema(description = "快照车辆子品牌名称")
private String snapshotCarChildsBrandName;
/**
* 车辆车系ID
*/
@Schema(description = "快照车辆车系ID")
private Integer snapshotCarSeriesId;
/**
* 车辆车系名称
*/
@Schema(description = "快照车辆车系名称")
private String snapshotCarSeriesName;
/**
* 车辆车型ID
*/
@Schema(description = "快照车辆车型ID")
private Integer snapshotCarTypeId;
/**
* 车型名称
*/
@Schema(description = "快照车型名称")
private String snapshotCarTypeName;
/**
* 车牌号
*/
@Schema(description = "快照车牌号")
private String snapshotLicensePlate;
/**
* 车辆VIN码
*/
@Schema(description = "快照车辆VIN码")
private String snapshotVin;
}
......@@ -39,9 +39,16 @@ public class VrLoginRespVO implements Serializable {
@Schema(description = "角色名称", example = "管理员")
private String roleName;
@Schema(description = "组织ID", example = "1")
@Schema(description = "门店ID", example = "1")
private Long orgId;
@Schema(description = "组织名称", example = "XX集团")
@Schema(description = "门店名称", example = "XX集团")
private String orgName;
@Schema(description = "集团ID")
private Long groupId;
@Schema(description = "集团名称")
private String groupName;
}
......@@ -36,9 +36,16 @@ public class VrLoginUserVO implements Serializable {
@Schema(description = "角色名称", example = "管理员")
private String roleName;
@Schema(description = "组织ID", example = "1")
@Schema(description = "门店ID", example = "1")
private Long orgId;
@Schema(description = "组织名称", example = "XX集团")
@Schema(description = "门店名称", example = "门店")
private String orgName;
@Schema(description = "集团ID")
private Long groupId;
@Schema(description = "集团名称")
private String groupName;
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!