crud注入当前操作用户信息

dev
huwei 2026-06-25 09:18:05 +08:00
parent 2766c34889
commit 3c87bf32f1
54 changed files with 283 additions and 35 deletions

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.OrgDepartmentEntity;
import org.qinan.safetyeval.domain.query.OrgDepartmentQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgDepartmentDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -73,7 +74,8 @@ public class OrgDepartmentExecutor implements OrgDepartmentApi {
OrgDepartmentQuery domainQuery = new OrgDepartmentQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setParentId(query.getParentId());
domainQuery.setDeptName(query.getDeptName());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.OrgEquipmentEntity;
import org.qinan.safetyeval.domain.query.OrgEquipmentQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgEquipmentDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -93,7 +94,8 @@ public class OrgEquipmentExecutor implements OrgEquipmentApi {
OrgEquipmentQuery domainQuery = new OrgEquipmentQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setDeviceName(query.getDeviceName());
domainQuery.setInstrumentType(query.getInstrumentType());
domainQuery.setDeviceType(query.getDeviceType());

View File

@ -130,6 +130,7 @@ public class OrgInfoExecutor implements OrgInfoApi {
domainQuery.setUnitName(query.getUnitName());
domainQuery.setCreditCode(query.getCreditCode());
domainQuery.setAuthStatusCode(query.getAuthStatusCode());
// 管理员可跨租户查询机构信息此处保留前端传入的tenantId
domainQuery.setTenantId(query.getTenantId());
PageResult<OrgInfoEntity> pageResult = orgInfoDomainService.page(domainQuery);

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.OrgPersonnelCertEntity;
import org.qinan.safetyeval.domain.query.OrgPersonnelCertQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgPersonnelCertDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -89,7 +90,8 @@ public class OrgPersonnelCertExecutor implements OrgPersonnelCertApi {
OrgPersonnelCertQuery domainQuery = new OrgPersonnelCertQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setPersonnelId(query.getPersonnelId());
domainQuery.setCertName(query.getCertName());
domainQuery.setCertTypeCode(query.getCertTypeCode());

View File

@ -11,9 +11,11 @@ import org.qinan.safetyeval.domain.entity.OrgPersonnelChangeEntity;
import org.qinan.safetyeval.domain.query.OrgPersonnelChangeQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgPersonnelChangeDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
/**
* App
@ -32,7 +34,9 @@ public class OrgPersonnelChangeExecutor implements OrgPersonnelChangeApi {
OrgPersonnelChangeEntity entity = new OrgPersonnelChangeEntity();
entity.setChangeItem(cmd.getChangeItem());
entity.setChangeTime(cmd.getChangeTime());
entity.setOperatorName(cmd.getOperatorName());
// 操作人从AuthUserContextAdapter获取不从前端Cmd传入
String operator = AuthUserContextAdapter.getCurrentUserName();
entity.setOperatorName(StringUtils.hasText(operator) ? operator : "系统");
OrgPersonnelChangeEntity result = orgPersonnelChangeDomainService.add(entity);
return SingleResponse.success(toCO(result));
@ -50,7 +54,9 @@ public class OrgPersonnelChangeExecutor implements OrgPersonnelChangeApi {
entity.setId(cmd.getId());
entity.setChangeItem(cmd.getChangeItem());
entity.setChangeTime(cmd.getChangeTime());
entity.setOperatorName(cmd.getOperatorName());
// 操作人从AuthUserContextAdapter获取不从前端Cmd传入
String operator = AuthUserContextAdapter.getCurrentUserName();
entity.setOperatorName(StringUtils.hasText(operator) ? operator : "系统");
OrgPersonnelChangeEntity result = orgPersonnelChangeDomainService.modify(entity);
return SingleResponse.success(toCO(result));
@ -67,7 +73,8 @@ public class OrgPersonnelChangeExecutor implements OrgPersonnelChangeApi {
OrgPersonnelChangeQuery domainQuery = new OrgPersonnelChangeQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setPersonnelId(query.getPersonnelId());
domainQuery.setChangeItem(query.getChangeItem());

View File

@ -16,6 +16,7 @@ import org.qinan.safetyeval.domain.gateway.OrgResignApplyGateway;
import org.qinan.safetyeval.domain.query.OrgPersonnelQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgPersonnelDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -93,7 +94,8 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
OrgPersonnelQuery domainQuery = new OrgPersonnelQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setDeptId(query.getDeptId());
domainQuery.setPostId(query.getPostId());
domainQuery.setUserName(query.getUserName());
@ -101,7 +103,7 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
domainQuery.setEmploymentStatusCode(query.getEmploymentStatusCode());
if (query.getResignAuditStatus() != null && orgResignApplyGateway != null) {
domainQuery.setPersonnelIds(orgResignApplyGateway.listPersonnelIdsByAuditStatus(
query.getResignAuditStatus(), query.getOrgId()));
query.getResignAuditStatus(), AuthUserContextAdapter.getCurrentOrgId()));
}
PageResult<OrgPersonnelEntity> pageResult = orgPersonnelDomainService.page(domainQuery);

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.OrgPositionEntity;
import org.qinan.safetyeval.domain.query.OrgPositionQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgPositionDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -69,7 +70,8 @@ public class OrgPositionExecutor implements OrgPositionApi {
OrgPositionQuery domainQuery = new OrgPositionQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setDeptId(query.getDeptId());
domainQuery.setPositionName(query.getPositionName());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.OrgQualificationEntity;
import org.qinan.safetyeval.domain.query.OrgQualificationQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgQualificationDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -83,7 +84,8 @@ public class OrgQualificationExecutor implements OrgQualificationApi {
OrgQualificationQuery domainQuery = new OrgQualificationQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setCertName(query.getCertName());
domainQuery.setCertNo(query.getCertNo());
domainQuery.setEnableFlag(query.getEnableFlag());

View File

@ -14,6 +14,7 @@ import org.qinan.safetyeval.domain.query.OrgResignApplyQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.OrgResignApplyDomainService;
import org.qinan.safetyeval.app.support.OrgPersonnelViewEnricher;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -40,7 +41,9 @@ public class OrgResignApplyExecutor implements OrgResignApplyApi {
@Override
public SingleResponse<OrgResignApplyCO> add(OrgResignApplyAddCmd cmd) {
OrgResignApplyEntity entity = new OrgResignApplyEntity();
entity.setApplicantName(cmd.getApplicantName());
// 申请人从当前登录用户自动获取,不从前端参数传入
String currentUserName = AuthUserContextAdapter.getCurrentUserName();
entity.setApplicantName(StringUtils.hasText(currentUserName) ? currentUserName : cmd.getApplicantName());
entity.setApplyTime(cmd.getApplyTime());
entity.setResignReason(cmd.getResignReason());
entity.setExpectedResignDate(cmd.getExpectedResignDate());
@ -102,7 +105,8 @@ public class OrgResignApplyExecutor implements OrgResignApplyApi {
OrgResignApplyQuery domainQuery = new OrgResignApplyQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setPersonnelId(query.getPersonnelId());
domainQuery.setAuditStatusCode(query.getAuditStatusCode());
domainQuery.setApplicantName(query.getApplicantName());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingChangeDetailEntity;
import org.qinan.safetyeval.domain.query.QualFilingChangeDetailQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingChangeDetailDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -65,6 +66,7 @@ public class QualFilingChangeDetailExecutor implements QualFilingChangeDetailApi
QualFilingChangeDetailQuery domainQuery = new QualFilingChangeDetailQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setChangeId(query.getChangeId());
domainQuery.setChangeField(query.getChangeField());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingChangeEntity;
import org.qinan.safetyeval.domain.query.QualFilingChangeQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingChangeDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -109,7 +110,8 @@ public class QualFilingChangeExecutor implements QualFilingChangeApi {
QualFilingChangeQuery domainQuery = new QualFilingChangeQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setOriginFilingId(query.getOriginFilingId());
domainQuery.setFilingNo(query.getFilingNo());
domainQuery.setFilingStatusCode(query.getFilingStatusCode());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingCommitmentEntity;
import org.qinan.safetyeval.domain.query.QualFilingCommitmentQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingCommitmentDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -67,6 +68,7 @@ public class QualFilingCommitmentExecutor implements QualFilingCommitmentApi {
QualFilingCommitmentQuery domainQuery = new QualFilingCommitmentQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setFilingId(query.getFilingId());
PageResult<QualFilingCommitmentEntity> pageResult = qualFilingCommitmentDomainService.page(domainQuery);

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingEquipmentEntity;
import org.qinan.safetyeval.domain.query.QualFilingEquipmentQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingEquipmentDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -91,6 +92,7 @@ public class QualFilingEquipmentExecutor implements QualFilingEquipmentApi {
QualFilingEquipmentQuery domainQuery = new QualFilingEquipmentQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setFilingId(query.getFilingId());
domainQuery.setDeviceName(query.getDeviceName());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingEntity;
import org.qinan.safetyeval.domain.query.QualFilingQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -111,7 +112,8 @@ public class QualFilingExecutor implements QualFilingApi {
QualFilingQuery domainQuery = new QualFilingQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setOrgId(query.getOrgId());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setOrgId(AuthUserContextAdapter.getCurrentOrgId());
domainQuery.setFilingNo(query.getFilingNo());
domainQuery.setFilingUnitName(query.getFilingUnitName());
domainQuery.setFilingStatusCode(query.getFilingStatusCode());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingMaterialEntity;
import org.qinan.safetyeval.domain.query.QualFilingMaterialQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingMaterialDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -69,6 +70,7 @@ public class QualFilingMaterialExecutor implements QualFilingMaterialApi {
QualFilingMaterialQuery domainQuery = new QualFilingMaterialQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setFilingId(query.getFilingId());
domainQuery.setMaterialContent(query.getMaterialContent());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingPersonnelCertEntity;
import org.qinan.safetyeval.domain.query.QualFilingPersonnelCertQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingPersonnelCertDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -87,6 +88,7 @@ public class QualFilingPersonnelCertExecutor implements QualFilingPersonnelCertA
QualFilingPersonnelCertQuery domainQuery = new QualFilingPersonnelCertQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setFilingId(query.getFilingId());
domainQuery.setFilingPersonnelId(query.getFilingPersonnelId());
domainQuery.setCertName(query.getCertName());

View File

@ -11,6 +11,7 @@ import org.qinan.safetyeval.domain.entity.QualFilingPersonnelEntity;
import org.qinan.safetyeval.domain.query.QualFilingPersonnelQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.domain.service.QualFilingPersonnelDomainService;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -105,6 +106,7 @@ public class QualFilingPersonnelExecutor implements QualFilingPersonnelApi {
QualFilingPersonnelQuery domainQuery = new QualFilingPersonnelQuery();
domainQuery.setPageNum(query.getCurrent());
domainQuery.setPageSize(query.getSize());
domainQuery.setTenantId(AuthUserContextAdapter.getCurrentTenantId());
domainQuery.setFilingId(query.getFilingId());
domainQuery.setPersonName(query.getPersonName());

View File

@ -16,6 +16,9 @@ public class OrgDepartmentQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class OrgEquipmentQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class OrgPersonnelCertQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class OrgPersonnelChangeQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class OrgPersonnelQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class OrgPositionQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class OrgQualificationQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class OrgResignApplyQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class QualFilingChangeDetailQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 变更ID */
private Long changeId;

View File

@ -16,6 +16,9 @@ public class QualFilingChangeQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -16,6 +16,9 @@ public class QualFilingCommitmentQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 备案ID */
private Long filingId;
}

View File

@ -16,6 +16,9 @@ public class QualFilingEquipmentQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 备案ID */
private Long filingId;

View File

@ -16,6 +16,9 @@ public class QualFilingMaterialQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 备案ID */
private Long filingId;

View File

@ -16,6 +16,9 @@ public class QualFilingPersonnelCertQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 备案ID */
private Long filingId;

View File

@ -16,6 +16,9 @@ public class QualFilingPersonnelQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 备案ID */
private Long filingId;

View File

@ -16,6 +16,9 @@ public class QualFilingQuery {
/** 每页条数 */
private Long pageSize;
/** 租户ID */
private Long tenantId;
/** 机构ID */
private Long orgId;

View File

@ -21,6 +21,14 @@ public final class AuthUserContextAdapter {
return AuthUserInfo.from(AuthContext.getCurrentUser());
}
/**
*
* @return
*/
public static SSOUser getCurrentUserOri(){
return AuthContext.getCurrentUser();
}
public static Long getCurrentUserId() {
AuthUserInfo user = getCurrentUser();
return user == null ? null : user.getUserId();

View File

@ -51,6 +51,7 @@ public class OrgDepartmentGatewayImpl implements OrgDepartmentGateway {
public OrgDepartmentEntity modify(OrgDepartmentEntity entity) {
OrgDepartmentDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgDepartmentMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -51,6 +51,7 @@ public class OrgEquipmentGatewayImpl implements OrgEquipmentGateway {
public OrgEquipmentEntity modify(OrgEquipmentEntity entity) {
OrgEquipmentDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgEquipmentMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -56,6 +56,7 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
public OrgInfoEntity modify(OrgInfoEntity entity) {
OrgInfoDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgInfoMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -68,6 +68,7 @@ public class OrgPersonnelCertGatewayImpl implements OrgPersonnelCertGateway {
public OrgPersonnelCertEntity modify(OrgPersonnelCertEntity entity) {
OrgPersonnelCertDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgPersonnelCertMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -59,6 +59,7 @@ public class OrgPersonnelChangeGatewayImpl implements OrgPersonnelChangeGateway
public OrgPersonnelChangeEntity modify(OrgPersonnelChangeEntity entity) {
OrgPersonnelChangeDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgPersonnelChangeMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -76,6 +76,7 @@ public class OrgPersonnelGatewayImpl implements OrgPersonnelGateway {
public OrgPersonnelEntity modify(OrgPersonnelEntity entity) {
OrgPersonnelDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgPersonnelMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -51,6 +51,7 @@ public class OrgPositionGatewayImpl implements OrgPositionGateway {
public OrgPositionEntity modify(OrgPositionEntity entity) {
OrgPositionDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgPositionMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -59,6 +59,7 @@ public class OrgQualificationGatewayImpl implements OrgQualificationGateway {
public OrgQualificationEntity modify(OrgQualificationEntity entity) {
OrgQualificationDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgQualificationMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -53,6 +53,7 @@ public class OrgResignApplyGatewayImpl implements OrgResignApplyGateway {
public OrgResignApplyEntity modify(OrgResignApplyEntity entity) {
OrgResignApplyDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
orgResignApplyMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingChangeDetailQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingChangeDetailDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingChangeDetailMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingChangeDetailGatewayImpl implements QualFilingChangeDetail
@Override
public QualFilingChangeDetailEntity save(QualFilingChangeDetailEntity entity) {
QualFilingChangeDetailDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingChangeDetailMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -53,6 +55,7 @@ public class QualFilingChangeDetailGatewayImpl implements QualFilingChangeDetail
public QualFilingChangeDetailEntity modify(QualFilingChangeDetailEntity entity) {
QualFilingChangeDetailDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingChangeDetailMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingChangeQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingChangeDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingChangeMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingChangeGatewayImpl implements QualFilingChangeGateway {
@Override
public QualFilingChangeEntity save(QualFilingChangeEntity entity) {
QualFilingChangeDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingChangeMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -53,6 +55,7 @@ public class QualFilingChangeGatewayImpl implements QualFilingChangeGateway {
public QualFilingChangeEntity modify(QualFilingChangeEntity entity) {
QualFilingChangeDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingChangeMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingCommitmentQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingCommitmentDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingCommitmentMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingCommitmentGatewayImpl implements QualFilingCommitmentGate
@Override
public QualFilingCommitmentEntity save(QualFilingCommitmentEntity entity) {
QualFilingCommitmentDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingCommitmentMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -53,6 +55,7 @@ public class QualFilingCommitmentGatewayImpl implements QualFilingCommitmentGate
public QualFilingCommitmentEntity modify(QualFilingCommitmentEntity entity) {
QualFilingCommitmentDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingCommitmentMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingEquipmentQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingEquipmentDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingEquipmentMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingEquipmentGatewayImpl implements QualFilingEquipmentGatewa
@Override
public QualFilingEquipmentEntity save(QualFilingEquipmentEntity entity) {
QualFilingEquipmentDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingEquipmentMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -53,6 +55,7 @@ public class QualFilingEquipmentGatewayImpl implements QualFilingEquipmentGatewa
public QualFilingEquipmentEntity modify(QualFilingEquipmentEntity entity) {
QualFilingEquipmentDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingEquipmentMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingGatewayImpl implements QualFilingGateway {
@Override
public QualFilingEntity save(QualFilingEntity entity) {
QualFilingDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -53,6 +55,7 @@ public class QualFilingGatewayImpl implements QualFilingGateway {
public QualFilingEntity modify(QualFilingEntity entity) {
QualFilingDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingMaterialQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingMaterialDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingMaterialMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingMaterialGatewayImpl implements QualFilingMaterialGateway
@Override
public QualFilingMaterialEntity save(QualFilingMaterialEntity entity) {
QualFilingMaterialDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingMaterialMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -53,6 +55,7 @@ public class QualFilingMaterialGatewayImpl implements QualFilingMaterialGateway
public QualFilingMaterialEntity modify(QualFilingMaterialEntity entity) {
QualFilingMaterialDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingMaterialMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingPersonnelCertQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingPersonnelCertDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingPersonnelCertMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingPersonnelCertGatewayImpl implements QualFilingPersonnelCe
@Override
public QualFilingPersonnelCertEntity save(QualFilingPersonnelCertEntity entity) {
QualFilingPersonnelCertDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingPersonnelCertMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -62,6 +64,7 @@ public class QualFilingPersonnelCertGatewayImpl implements QualFilingPersonnelCe
public QualFilingPersonnelCertEntity modify(QualFilingPersonnelCertEntity entity) {
QualFilingPersonnelCertDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingPersonnelCertMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -9,6 +9,7 @@ import org.qinan.safetyeval.domain.query.QualFilingPersonnelQuery;
import org.qinan.safetyeval.domain.query.PageResult;
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingPersonnelDO;
import org.qinan.safetyeval.infrastructure.mapper.QualFilingPersonnelMapper;
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@ -30,6 +31,7 @@ public class QualFilingPersonnelGatewayImpl implements QualFilingPersonnelGatewa
@Override
public QualFilingPersonnelEntity save(QualFilingPersonnelEntity entity) {
QualFilingPersonnelDO dataObject = toDO(entity);
InsertFieldDefaults.apply(dataObject);
qualFilingPersonnelMapper.insert(dataObject);
entity.setId(dataObject.getId());
return entity;
@ -53,6 +55,7 @@ public class QualFilingPersonnelGatewayImpl implements QualFilingPersonnelGatewa
public QualFilingPersonnelEntity modify(QualFilingPersonnelEntity entity) {
QualFilingPersonnelDO dataObject = toDO(entity);
dataObject.setId(entity.getId());
InsertFieldDefaults.applyForUpdate(dataObject);
qualFilingPersonnelMapper.updateById(dataObject);
return get(entity.getId());
}

View File

@ -3,6 +3,7 @@ package org.qinan.safetyeval.infrastructure.handler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.qinan.safetyeval.domain.adapter.UserInfoAdapter;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -13,7 +14,8 @@ import java.time.LocalDateTime;
* MyBatis Plus
* <p>
* insert update GBS
* UserInfoAdapter
* AuthUserContextAdapter SSO
* UserInfoAdapterThreadLocal 退
* 使 strictFill null
* </p>
*
@ -41,26 +43,73 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
@Value("${safety-eval.public-api.system-user-name:system}")
private String fallbackUserName;
@Override
public void insertFill(MetaObject metaObject) {
LocalDateTime now = LocalDateTime.now();
Long userId = userInfoAdapter.getCurrentUserId();
String userName = userInfoAdapter.getCurrentUserName();
Long tenantId = userInfoAdapter.getCurrentTenantId();
Long orgId = userInfoAdapter.getCurrentOrgId();
/**
* ID AuthUserContextAdapterSSO UserInfoAdapterThreadLocal 退
*/
private Long resolveUserId() {
Long userId = AuthUserContextAdapter.getCurrentUserId();
if (userId != null) {
return userId;
}
userId = userInfoAdapter.getCurrentUserId();
if (userId == null && fallbackUserId != null && fallbackUserId > 0) {
userId = fallbackUserId;
}
return userId;
}
/**
* AuthUserContextAdapterSSO UserInfoAdapterThreadLocal 退
*/
private String resolveUserName() {
String userName = AuthUserContextAdapter.getCurrentUserName();
if (userName != null) {
return userName;
}
userName = userInfoAdapter.getCurrentUserName();
if (userName == null && fallbackUserName != null) {
userName = fallbackUserName;
}
return userName;
}
/**
* ID AuthUserContextAdapterSSO UserInfoAdapterThreadLocal 退
*/
private Long resolveTenantId() {
Long tenantId = AuthUserContextAdapter.getCurrentTenantId();
if (tenantId != null) {
return tenantId;
}
tenantId = userInfoAdapter.getCurrentTenantId();
if (tenantId == null && fallbackTenantId != null && fallbackTenantId > 0) {
tenantId = fallbackTenantId;
}
return tenantId;
}
/**
* ID AuthUserContextAdapterSSO UserInfoAdapterThreadLocal 退
*/
private Long resolveOrgId() {
Long orgId = AuthUserContextAdapter.getCurrentOrgId();
if (orgId != null) {
return orgId;
}
orgId = userInfoAdapter.getCurrentOrgId();
if (orgId == null && fallbackOrgId != null && fallbackOrgId > 0) {
orgId = fallbackOrgId;
}
return orgId;
}
@Override
public void insertFill(MetaObject metaObject) {
LocalDateTime now = LocalDateTime.now();
Long userId = resolveUserId();
String userName = resolveUserName();
Long tenantId = resolveTenantId();
Long orgId = resolveOrgId();
// 严格填充:仅当字段值为 null 时填充,优先级最低
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, now);
@ -69,7 +118,7 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
this.strictInsertFill(metaObject, "env", String.class, DEFAULT_ENV);
this.strictInsertFill(metaObject, "version", Integer.class, 0);
// 用户相关字段:仅当 adapter 返回值不为 null 时才填充
// 用户相关字段:仅当解析值不为 null 时才填充
if (userId != null) {
this.strictInsertFill(metaObject, "createId", Long.class, userId);
this.strictInsertFill(metaObject, "updateId", Long.class, userId);
@ -89,14 +138,8 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
@Override
public void updateFill(MetaObject metaObject) {
LocalDateTime now = LocalDateTime.now();
Long userId = userInfoAdapter.getCurrentUserId();
String userName = userInfoAdapter.getCurrentUserName();
if (userId == null && fallbackUserId != null && fallbackUserId > 0) {
userId = fallbackUserId;
}
if (userName == null && fallbackUserName != null) {
userName = fallbackUserName;
}
Long userId = resolveUserId();
String userName = resolveUserName();
this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, now);
if (userId != null) {

View File

@ -1,9 +1,17 @@
package org.qinan.safetyeval.infrastructure.support;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
/**
* insert GBS null selectById
* insert GBS
* <p>
* MyMetaObjectHandler MyBatis-Plus MetaObjectHandler
* GBS insert
* AuthUserContextAdapterSSO
* </p>
*/
public final class InsertFieldDefaults {
@ -17,9 +25,69 @@ public final class InsertFieldDefaults {
if (dataObject == null) {
return;
}
LocalDateTime now = LocalDateTime.now();
// 常量默认值
setIfNull(dataObject, "deleteEnum", DELETE_NOT_DELETED);
setIfNull(dataObject, "env", DEFAULT_ENV);
setIfNull(dataObject, "version", 0);
// 时间字段
setIfNull(dataObject, "createTime", now);
setIfNull(dataObject, "updateTime", now);
// 用户上下文字段:从 AuthUserContextAdapter 获取
Long userId = AuthUserContextAdapter.getCurrentUserId();
String userName = AuthUserContextAdapter.getCurrentUserName();
Long tenantId = AuthUserContextAdapter.getCurrentTenantId();
Long orgId = AuthUserContextAdapter.getCurrentOrgId();
if (userId != null) {
setIfNull(dataObject, "createId", userId);
setIfNull(dataObject, "updateId", userId);
}
if (userName != null) {
setIfNull(dataObject, "createName", userName);
setIfNull(dataObject, "updateName", userName);
}
if (tenantId != null) {
setIfNull(dataObject, "tenantId", tenantId);
}
if (orgId != null) {
setIfNull(dataObject, "orgId", orgId);
}
}
/**
* insert GBS entity.operatorName
*/
public static void applyWithUserName(Object dataObject, String overrideUserName) {
apply(dataObject);
if (overrideUserName != null) {
setIfNull(dataObject, "createName", overrideUserName);
setIfNull(dataObject, "updateName", overrideUserName);
}
}
/**
* update GBS updateTimeupdateIdupdateName
* MyMetaObjectHandler
*/
public static void applyForUpdate(Object dataObject) {
if (dataObject == null) {
return;
}
LocalDateTime now = LocalDateTime.now();
Long userId = AuthUserContextAdapter.getCurrentUserId();
String userName = AuthUserContextAdapter.getCurrentUserName();
setIfNull(dataObject, "updateTime", now);
if (userId != null) {
setIfNull(dataObject, "updateId", userId);
}
if (userName != null) {
setIfNull(dataObject, "updateName", userName);
}
}
private static void setIfNull(Object target, String property, Object value) {

View File

@ -1,13 +1,14 @@
package org.qinan.safetyeval.infrastructure.support;
import org.qinan.safetyeval.domain.adapter.UserInfoAdapter;
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* orgId 退local org-id=1
* orgId SSO AuthUserContextAdapter ThreadLocalUserInfoAdapter 退local org-id=1
*/
@Component
public class OrgContextResolver {
@ -22,10 +23,17 @@ public class OrgContextResolver {
if (entityOrgId != null) {
return entityOrgId;
}
Long orgId = userInfoAdapter.getCurrentOrgId();
// 优先 SSO 真实登录用户的 orgId
Long orgId = AuthUserContextAdapter.getCurrentOrgId();
if (orgId != null) {
return orgId;
}
// 其次 ThreadLocal 方式
orgId = userInfoAdapter.getCurrentOrgId();
if (orgId != null) {
return orgId;
}
// 最后配置回退
if (fallbackOrgId != null && fallbackOrgId > 0) {
return fallbackOrgId;
}