🐛 超管默认不限组织范围,并修复司机同步初始密码不合规
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+3
@@ -110,6 +110,9 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
validateUniqueCode(region);
|
||||
// 设置祖区划编号
|
||||
Region parent = getByCode(region.getParentCode());
|
||||
if (level != null && level > COUNTRY_LEVEL && (Func.isEmpty(parent) || Func.isEmpty(parent.getCode()))) {
|
||||
throw new ServiceException("父区划不存在,请重新选择父区划");
|
||||
}
|
||||
if (Func.isNotEmpty(parent) && Func.isNotEmpty(parent.getCode())) {
|
||||
String ancestors = parent.getRegionLevel() != null && parent.getRegionLevel() == COUNTRY_LEVEL
|
||||
? parent.getCode()
|
||||
|
||||
+4
-20
@@ -33,11 +33,9 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.excel.util.ExcelUtil;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.PreAuth;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.DateUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
@@ -46,6 +44,7 @@ import org.springblade.transport.pojo.entity.CommonAddress;
|
||||
import org.springblade.transport.pojo.vo.CommonAddressRemoveResultVO;
|
||||
import org.springblade.transport.pojo.vo.CommonAddressVO;
|
||||
import org.springblade.transport.service.ICommonAddressService;
|
||||
import org.springblade.transport.support.TransportBusinessSupport;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -54,7 +53,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 常用地址 控制器
|
||||
@@ -164,15 +162,9 @@ public class CommonAddressController extends BladeController {
|
||||
if (Func.isNotEmpty(ids)) {
|
||||
queryWrapper.in(CommonAddress::getId, Func.toLongList(ids));
|
||||
}
|
||||
if (Objects.equals(commonAddress.getAllDept(), 1)) {
|
||||
if (!AuthUtil.isAdministrator()) {
|
||||
throw new ServiceException("无权导出全部组织常用地址");
|
||||
}
|
||||
} else {
|
||||
queryWrapper.eq(CommonAddress::getDeptId, currentDeptId());
|
||||
}
|
||||
if (Objects.equals(commonAddress.getAllDept(), 1) && Func.isNotEmpty(commonAddress.getDeptId())) {
|
||||
queryWrapper.eq(CommonAddress::getDeptId, commonAddress.getDeptId());
|
||||
List<Long> deptIdList = TransportBusinessSupport.resolveDeptFilterIds(commonAddress.getAllDept(), commonAddress.getDeptId(), "常用地址");
|
||||
if (Func.isNotEmpty(deptIdList)) {
|
||||
queryWrapper.eq(CommonAddress::getDeptId, deptIdList.get(0));
|
||||
}
|
||||
if (Func.isNotEmpty(commonAddress.getAddressName())) {
|
||||
queryWrapper.like(CommonAddress::getAddressName, commonAddress.getAddressName().trim());
|
||||
@@ -198,12 +190,4 @@ public class CommonAddressController extends BladeController {
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private Long currentDeptId() {
|
||||
Long deptId = Func.firstLong(AuthUtil.getDeptId());
|
||||
if (Func.isEmpty(deptId) || deptId <= 0) {
|
||||
throw new ServiceException("当前用户所属组织为空,无法导出常用地址");
|
||||
}
|
||||
return deptId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-4
@@ -200,10 +200,12 @@ public class CustomerArchiveController extends BladeController {
|
||||
LambdaQueryWrapper<CustomerArchive> queryWrapper = Wrappers.<CustomerArchive>lambdaQuery()
|
||||
.eq(CustomerArchive::getIsDeleted, 0)
|
||||
.orderByDesc(CustomerArchive::getCreateTime);
|
||||
Long userId = AuthUtil.getUserId();
|
||||
queryWrapper.and(wrapper -> wrapper
|
||||
.exists("SELECT 1 FROM blade_user_customer_scope bucs WHERE bucs.user_id = " + userId
|
||||
+ " AND bucs.customer_id = blade_customer_archive.id"));
|
||||
if (!AuthUtil.isAdministrator()) {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
queryWrapper.and(wrapper -> wrapper
|
||||
.exists("SELECT 1 FROM blade_user_customer_scope bucs WHERE bucs.user_id = " + userId
|
||||
+ " AND bucs.customer_id = blade_customer_archive.id"));
|
||||
}
|
||||
if (Func.isNotEmpty(ids)) {
|
||||
queryWrapper.in(CustomerArchive::getId, Func.toLongList(ids));
|
||||
}
|
||||
|
||||
+5
-9
@@ -38,6 +38,7 @@ import org.springblade.transport.pojo.entity.CommonAddress;
|
||||
import org.springblade.transport.pojo.vo.CommonAddressRemoveResultVO;
|
||||
import org.springblade.transport.pojo.vo.CommonAddressVO;
|
||||
import org.springblade.transport.service.ICommonAddressService;
|
||||
import org.springblade.transport.support.TransportBusinessSupport;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -165,13 +166,8 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
}
|
||||
|
||||
private void prepareQuery(CommonAddressVO address) {
|
||||
if (Objects.equals(address.getAllDept(), 1)) {
|
||||
if (!AuthUtil.isAdministrator()) {
|
||||
throw new ServiceException("无权查看全部组织常用地址");
|
||||
}
|
||||
} else {
|
||||
address.setDeptId(currentDeptId());
|
||||
}
|
||||
List<Long> deptIdList = TransportBusinessSupport.resolveDeptFilterIds(address.getAllDept(), address.getDeptId(), "常用地址");
|
||||
address.setDeptId(Func.isEmpty(deptIdList) ? null : deptIdList.get(0));
|
||||
address.setAddressName(trimToNull(address.getAddressName()));
|
||||
address.setAddressType(trimToNull(address.getAddressType()));
|
||||
address.setDetailAddress(trimToNull(address.getDetailAddress()));
|
||||
@@ -300,14 +296,14 @@ public class CommonAddressServiceImpl extends BaseServiceImpl<CommonAddressMappe
|
||||
}
|
||||
|
||||
private void validateCurrentDept(CommonAddress address) {
|
||||
if (!Objects.equals(address.getDeptId(), currentDeptId())) {
|
||||
if (!AuthUtil.isAdministrator() && !Objects.equals(address.getDeptId(), currentDeptId())) {
|
||||
throw new ServiceException("无权操作其他组织常用地址");
|
||||
}
|
||||
}
|
||||
|
||||
private void fillDisplay(CommonAddressVO address) {
|
||||
address.setSiteCodeDisplay(TYPE_NORMAL.equals(address.getAddressType()) ? NORMAL_SITE_CODE : address.getSiteCode());
|
||||
address.setReadonly(!Objects.equals(address.getDeptId(), currentDeptId()));
|
||||
address.setReadonly(!AuthUtil.isAdministrator() && !Objects.equals(address.getDeptId(), currentDeptId()));
|
||||
address.setCreateUserName(UserCache.getUserRealName(address.getCreateUser()));
|
||||
address.setUpdateUserName(UserCache.getUserRealName(address.getUpdateUser()));
|
||||
}
|
||||
|
||||
+3
-5
@@ -156,12 +156,10 @@ public class CommonRouteServiceImpl extends BaseServiceImpl<CommonRouteMapper, C
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<CommonRoute> buildQuery(CommonRouteVO commonRoute) {
|
||||
TransportBusinessSupport.validateAllDept(commonRoute.getAllDept(), "常用线路");
|
||||
LambdaQueryWrapper<CommonRoute> queryWrapper = Wrappers.<CommonRoute>lambdaQuery().eq(CommonRoute::getIsDeleted, 0);
|
||||
if (!Objects.equals(commonRoute.getAllDept(), 1)) {
|
||||
queryWrapper.eq(CommonRoute::getDeptId, TransportBusinessSupport.currentDeptId("常用线路"));
|
||||
} else if (Func.isNotEmpty(commonRoute.getDeptId())) {
|
||||
queryWrapper.eq(CommonRoute::getDeptId, commonRoute.getDeptId());
|
||||
List<Long> deptIdList = TransportBusinessSupport.resolveDeptFilterIds(commonRoute.getAllDept(), commonRoute.getDeptId(), "常用线路");
|
||||
if (Func.isNotEmpty(deptIdList)) {
|
||||
queryWrapper.eq(CommonRoute::getDeptId, deptIdList.get(0));
|
||||
}
|
||||
if (Func.isNotEmpty(commonRoute.getRouteCode())) {
|
||||
queryWrapper.eq(CommonRoute::getRouteCode, commonRoute.getRouteCode());
|
||||
|
||||
+8
-1
@@ -416,7 +416,11 @@ public class ContractManageServiceImpl extends BaseServiceImpl<ContractManageMap
|
||||
private LambdaQueryWrapper<ContractManage> buildQuery(ContractManageVO contractManage) {
|
||||
TransportBusinessSupport.validateAllDept(contractManage.getAllDept(), "合同管理");
|
||||
LambdaQueryWrapper<ContractManage> queryWrapper = Wrappers.<ContractManage>lambdaQuery().eq(ContractManage::getIsDeleted, 0);
|
||||
if (!Objects.equals(contractManage.getAllDept(), 1)) {
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
if (Objects.equals(contractManage.getAllDept(), 1) && Func.isNotEmpty(contractManage.getOrganizationId())) {
|
||||
queryWrapper.eq(ContractManage::getOrganizationId, contractManage.getOrganizationId());
|
||||
}
|
||||
} else if (!Objects.equals(contractManage.getAllDept(), 1)) {
|
||||
Long currentDeptId = TransportBusinessSupport.currentDeptId("合同管理");
|
||||
Long currentUserId = AuthUtil.getUserId();
|
||||
queryWrapper.and(wrapper -> wrapper.eq(ContractManage::getOrganizationId, currentDeptId)
|
||||
@@ -1088,6 +1092,9 @@ public class ContractManageServiceImpl extends BaseServiceImpl<ContractManageMap
|
||||
}
|
||||
|
||||
private boolean canOperateInCurrentScope(ContractManage contractManage) {
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
Long currentDeptId = TransportBusinessSupport.currentDeptId("合同管理");
|
||||
Long currentUserId = AuthUtil.getUserId();
|
||||
return Objects.equals(contractManage.getOrganizationId(), currentDeptId)
|
||||
|
||||
+10
-2
@@ -144,7 +144,7 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
|
||||
@Override
|
||||
public IPage<CustomerArchiveVO> selectCustomerArchivePage(IPage<CustomerArchiveVO> page, CustomerArchiveVO customer) {
|
||||
List<CustomerArchiveVO> records = baseMapper.selectCustomerArchivePage(page, customer, AuthUtil.getUserId());
|
||||
List<CustomerArchiveVO> records = baseMapper.selectCustomerArchivePage(page, customer, currentScopeUserId());
|
||||
fillFundUseRisk(records);
|
||||
return page.setRecords(records);
|
||||
}
|
||||
@@ -1221,12 +1221,20 @@ public class CustomerArchiveServiceImpl extends BaseServiceImpl<CustomerArchiveM
|
||||
|
||||
private CustomerArchive ensureCustomerAccessible(Long id) {
|
||||
CustomerArchive customer = getExistingCustomer(id);
|
||||
if (baseMapper.selectCustomerPermissionCount(id, AuthUtil.getUserId()) == 0) {
|
||||
Long userId = currentScopeUserId();
|
||||
if (userId != null && baseMapper.selectCustomerPermissionCount(id, userId) == 0) {
|
||||
throw new ServiceException("无权访问该客商档案");
|
||||
}
|
||||
return customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 客商可见范围用户。超管返回空,表示不按用户客商授权表过滤。
|
||||
*/
|
||||
private Long currentScopeUserId() {
|
||||
return AuthUtil.isAdministrator() ? null : AuthUtil.getUserId();
|
||||
}
|
||||
|
||||
private CustomerArchive copyCustomer(CustomerArchive customer) {
|
||||
return Objects.requireNonNull(BeanUtil.copyProperties(customer, CustomerArchive.class));
|
||||
}
|
||||
|
||||
+2
-2
@@ -338,7 +338,7 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
||||
|
||||
User existing = findExistingUser(driver, tenantId, mobile);
|
||||
if (existing == null || Func.isEmpty(existing.getId())) {
|
||||
// 司机未关联有效用户时新建;密码为手机号后6位
|
||||
// 司机未关联有效用户时新建;初始密码由系统用户保存逻辑按默认参数/强度规则填充
|
||||
createAndLinkDriverUser(driver, tenantId, mobile, roleId, deptId);
|
||||
} else {
|
||||
updateAndLinkDriverUser(driver, existing, tenantId, mobile, roleId, deptId);
|
||||
@@ -373,7 +373,7 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
||||
|
||||
private void createAndLinkDriverUser(Driver driver, String tenantId, String mobile, String roleId, String deptId) {
|
||||
User user = buildSyncUser(null, tenantId, mobile, driver.getDriverName(), driver.getGender(), roleId, deptId);
|
||||
user.setPassword(mobile.substring(mobile.length() - 6));
|
||||
// 不传密码:交由 UserServiceImpl.saveUser 使用系统默认初始密码或自动生成合规密码
|
||||
user.setUserType(UserType.WEB.getCategory());
|
||||
|
||||
R<Boolean> saveResult = null;
|
||||
|
||||
+3
-5
@@ -252,12 +252,10 @@ public class ProcessConfigServiceImpl extends BaseServiceImpl<ProcessConfigMappe
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<ProcessConfig> buildQuery(ProcessConfigVO processConfig) {
|
||||
TransportBusinessSupport.validateAllDept(processConfig.getAllDept(), "过程配置");
|
||||
LambdaQueryWrapper<ProcessConfig> queryWrapper = Wrappers.<ProcessConfig>lambdaQuery().eq(ProcessConfig::getIsDeleted, 0);
|
||||
if (!Objects.equals(processConfig.getAllDept(), 1)) {
|
||||
queryWrapper.eq(ProcessConfig::getDeptId, TransportBusinessSupport.currentDeptId("过程配置"));
|
||||
} else if (Func.isNotEmpty(processConfig.getDeptId())) {
|
||||
queryWrapper.eq(ProcessConfig::getDeptId, processConfig.getDeptId());
|
||||
List<Long> deptIdList = TransportBusinessSupport.resolveDeptFilterIds(processConfig.getAllDept(), processConfig.getDeptId(), "过程配置");
|
||||
if (Func.isNotEmpty(deptIdList)) {
|
||||
queryWrapper.eq(ProcessConfig::getDeptId, deptIdList.get(0));
|
||||
}
|
||||
if (Func.isNotEmpty(processConfig.getConfigCode())) {
|
||||
queryWrapper.eq(ProcessConfig::getConfigCode, processConfig.getConfigCode());
|
||||
|
||||
+6
-1
@@ -337,7 +337,12 @@ public class ProjectApplyServiceImpl extends BaseServiceImpl<ProjectApplyMapper,
|
||||
private LambdaQueryWrapper<ProjectApply> buildQuery(ProjectApplyVO projectApply) {
|
||||
TransportBusinessSupport.validateAllDept(projectApply.getAllDept(), "项目立项");
|
||||
LambdaQueryWrapper<ProjectApply> queryWrapper = Wrappers.<ProjectApply>lambdaQuery().eq(ProjectApply::getIsDeleted, 0);
|
||||
if (!Objects.equals(projectApply.getAllDept(), 1)) {
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
// 超管默认可查看全部未删除数据;仅在明确指定承办组织时按组织精确筛选。
|
||||
if (Objects.equals(projectApply.getAllDept(), 1) && Func.isNotEmpty(projectApply.getUndertakeDeptId())) {
|
||||
queryWrapper.eq(ProjectApply::getUndertakeDeptId, projectApply.getUndertakeDeptId());
|
||||
}
|
||||
} else if (!Objects.equals(projectApply.getAllDept(), 1)) {
|
||||
Long currentDeptId = TransportBusinessSupport.currentDeptId("项目立项");
|
||||
Long currentUserId = AuthUtil.getUserId();
|
||||
queryWrapper.and(wrapper -> wrapper.eq(ProjectApply::getUndertakeDeptId, currentDeptId)
|
||||
|
||||
+5
-1
@@ -185,7 +185,11 @@ public class TemporaryCreditLimitServiceImpl extends BaseServiceImpl<TemporaryCr
|
||||
private LambdaQueryWrapper<TemporaryCreditLimit> buildQuery(TemporaryCreditLimitVO temporaryCreditLimit) {
|
||||
TransportBusinessSupport.validateAllDept(temporaryCreditLimit.getAllDept(), "临时额度管理");
|
||||
LambdaQueryWrapper<TemporaryCreditLimit> queryWrapper = Wrappers.<TemporaryCreditLimit>lambdaQuery().eq(TemporaryCreditLimit::getIsDeleted, 0);
|
||||
if (!Objects.equals(temporaryCreditLimit.getAllDept(), 1)) {
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
if (Objects.equals(temporaryCreditLimit.getAllDept(), 1) && Func.isNotEmpty(temporaryCreditLimit.getApplyDeptId())) {
|
||||
queryWrapper.eq(TemporaryCreditLimit::getApplyDeptId, temporaryCreditLimit.getApplyDeptId());
|
||||
}
|
||||
} else if (!Objects.equals(temporaryCreditLimit.getAllDept(), 1)) {
|
||||
queryWrapper.eq(TemporaryCreditLimit::getApplyDeptId, TransportBusinessSupport.currentDeptId("临时额度管理"));
|
||||
} else if (Func.isNotEmpty(temporaryCreditLimit.getApplyDeptId())) {
|
||||
queryWrapper.eq(TemporaryCreditLimit::getApplyDeptId, temporaryCreditLimit.getApplyDeptId());
|
||||
|
||||
+7
-2
@@ -88,8 +88,7 @@ public final class TransportBusinessSupport {
|
||||
/**
|
||||
* 解析列表组织筛选 ID。
|
||||
* <p>
|
||||
* allDept!=1 时强制当前组织;allDept=1 且传入 deptId 时仅精确匹配该组织;
|
||||
* allDept=1 且未传 deptId 时返回空集合,表示不按组织过滤。
|
||||
* 普通用户 allDept!=1 时强制当前组织;超管默认不按组织过滤,仅在 allDept=1 且传入 deptId 时精确匹配该组织。
|
||||
*
|
||||
* @param allDept 是否查看全部组织
|
||||
* @param deptId 筛选组织 ID
|
||||
@@ -98,6 +97,12 @@ public final class TransportBusinessSupport {
|
||||
*/
|
||||
public static List<Long> resolveDeptFilterIds(Integer allDept, Long deptId, String moduleName) {
|
||||
validateAllDept(allDept, moduleName);
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
if (Objects.equals(allDept, 1) && Func.isNotEmpty(deptId) && deptId > 0) {
|
||||
return Collections.singletonList(deptId);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (!Objects.equals(allDept, 1)) {
|
||||
return Collections.singletonList(currentDeptId(moduleName));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user