feat: 接入gbs用户信息
parent
63389a7d42
commit
4fa421b623
|
|
@ -46,6 +46,7 @@ create table org_info (
|
||||||
economy_industry_name varchar(100) default null comment '国民经济行业分类名称',
|
economy_industry_name varchar(100) default null comment '国民经济行业分类名称',
|
||||||
auth_status_code int default null comment '认证状态编码(1填写信息2审核中3通过)',
|
auth_status_code int default null comment '认证状态编码(1填写信息2审核中3通过)',
|
||||||
auth_status_name varchar(50) default null comment '认证状态名称',
|
auth_status_name varchar(50) default null comment '认证状态名称',
|
||||||
|
state int default 0 comment '状态(0启用1禁用)',
|
||||||
delete_enum varchar(32) default null comment '删除标识true false',
|
delete_enum varchar(32) default null comment '删除标识true false',
|
||||||
remarks varchar(255) default null comment '备注',
|
remarks varchar(255) default null comment '备注',
|
||||||
create_name varchar(50) default null comment '创建人姓名',
|
create_name varchar(50) default null comment '创建人姓名',
|
||||||
|
|
@ -61,7 +62,8 @@ create table org_info (
|
||||||
primary key (id),
|
primary key (id),
|
||||||
key idx_org_info_tenant_id (tenant_id),
|
key idx_org_info_tenant_id (tenant_id),
|
||||||
key idx_org_info_credit_code (credit_code),
|
key idx_org_info_credit_code (credit_code),
|
||||||
key idx_org_info_auth_status (auth_status_code)
|
key idx_org_info_auth_status (auth_status_code),
|
||||||
|
key idx_org_info_state (state)
|
||||||
) engine=innodb default charset=utf8mb4 collate=utf8mb4_0900_ai_ci comment='机构信息表';
|
) engine=innodb default charset=utf8mb4 collate=utf8mb4_0900_ai_ci comment='机构信息表';
|
||||||
|
|
||||||
-- ------------------------------------------------------------
|
-- ------------------------------------------------------------
|
||||||
|
|
@ -651,6 +653,10 @@ create table qual_filing_change_detail (
|
||||||
-- 执行前会清理本机构 org_id=1 下的旧联调数据,避免脏数据干扰
|
-- 执行前会清理本机构 org_id=1 下的旧联调数据,避免脏数据干扰
|
||||||
-- ============================================================
|
-- ============================================================
|
||||||
|
|
||||||
|
-- 已有库增量:机构信息 state 字段(0启用1禁用)
|
||||||
|
-- ALTER TABLE org_info ADD COLUMN state int DEFAULT 0 COMMENT '状态(0启用1禁用)' AFTER auth_status_name;
|
||||||
|
-- CREATE INDEX idx_org_info_state ON org_info (state);
|
||||||
|
|
||||||
SET @tenant_id = 1001;
|
SET @tenant_id = 1001;
|
||||||
SET @org_id = 1;
|
SET @org_id = 1;
|
||||||
SET @now = NOW();
|
SET @now = NOW();
|
||||||
|
|
@ -673,7 +679,7 @@ INSERT INTO org_info (
|
||||||
principal_name, principal_phone, safety_dept_manager, safety_dept_manager_phone,
|
principal_name, principal_phone, safety_dept_manager, safety_dept_manager_phone,
|
||||||
safety_deputy_phone, production_date, business_status_name, info_disclosure_url,
|
safety_deputy_phone, production_date, business_status_name, info_disclosure_url,
|
||||||
workplace_area, archive_room_area, fulltime_evaluator_count, registered_engineer_count,
|
workplace_area, archive_room_area, fulltime_evaluator_count, registered_engineer_count,
|
||||||
economy_industry_code, auth_status_code, auth_status_name,
|
economy_industry_code, auth_status_code, auth_status_name, state,
|
||||||
delete_enum, tenant_id, org_id, create_time, update_time
|
delete_enum, tenant_id, org_id, create_time, update_time
|
||||||
) VALUES (
|
) VALUES (
|
||||||
@org_id, '秦皇岛示例安全评价有限公司', '91130300MA0XXXXXX1', '安全评价', '海港区', '白塔岭街道',
|
@org_id, '秦皇岛示例安全评价有限公司', '91130300MA0XXXXXX1', '安全评价', '海港区', '白塔岭街道',
|
||||||
|
|
@ -681,7 +687,7 @@ INSERT INTO org_info (
|
||||||
'河北省秦皇岛市海港区示例路88号', '河北省秦皇岛市海港区示例路88号',
|
'河北省秦皇岛市海港区示例路88号', '河北省秦皇岛市海港区示例路88号',
|
||||||
'民营企业', '张三', '0335-88880001', '李四', '13800138001', '王五', '13800138002',
|
'民营企业', '张三', '0335-88880001', '李四', '13800138001', '王五', '13800138002',
|
||||||
'13800138003', '2018-06-01', '正常经营', 'https://example.com/disclosure',
|
'13800138003', '2018-06-01', '正常经营', 'https://example.com/disclosure',
|
||||||
1200.00, 80.00, 12, 5, 'M7491', 3, '通过',
|
1200.00, 80.00, 12, 5, 'M7491', 3, '通过', 0,
|
||||||
'false', @tenant_id, @org_id, @now, @now
|
'false', @tenant_id, @org_id, @now, @now
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import org.qinan.safetyeval.client.co.OrgInfoCO;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
||||||
|
import org.qinan.safetyeval.client.dto.OrgInfoUpdateStateCmd;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
|
@ -57,6 +58,18 @@ public class OrgInfoController {
|
||||||
return orgInfoApi.delete(id);
|
return orgInfoApi.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("启用/禁用机构信息")
|
||||||
|
@PostMapping("/update-state")
|
||||||
|
public SingleResponse<Void> updateState(@Validated @RequestBody OrgInfoUpdateStateCmd cmd) {
|
||||||
|
return orgInfoApi.updateState(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("重置机构密码")
|
||||||
|
@PostMapping("/reset-password")
|
||||||
|
public SingleResponse<Void> resetPassword(@RequestParam Long id) {
|
||||||
|
return orgInfoApi.resetPassword(id);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("分页查询机构信息")
|
@ApiOperation("分页查询机构信息")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public PageResponse<OrgInfoCO> page(@Validated OrgInfoPageQuery query) {
|
public PageResponse<OrgInfoCO> page(@Validated OrgInfoPageQuery query) {
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,17 @@ import org.qinan.safetyeval.client.co.OrgInfoCO;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
||||||
|
import org.qinan.safetyeval.client.dto.OrgInfoUpdateStateCmd;
|
||||||
import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
||||||
|
import org.qinan.safetyeval.domain.exception.BizException;
|
||||||
|
import org.qinan.safetyeval.domain.exception.ErrorCode;
|
||||||
import org.qinan.safetyeval.domain.query.OrgInfoQuery;
|
import org.qinan.safetyeval.domain.query.OrgInfoQuery;
|
||||||
import org.qinan.safetyeval.domain.query.PageResult;
|
import org.qinan.safetyeval.domain.query.PageResult;
|
||||||
import org.qinan.safetyeval.domain.service.OrgInfoDomainService;
|
import org.qinan.safetyeval.domain.service.OrgInfoDomainService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机构信息执行器(App层)
|
* 机构信息执行器(App层)
|
||||||
|
|
@ -117,11 +121,29 @@ public class OrgInfoExecutor implements OrgInfoApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public SingleResponse<Void> delete(Long id) {
|
public SingleResponse<Void> delete(Long id) {
|
||||||
orgInfoDomainService.delete(id);
|
orgInfoDomainService.delete(id);
|
||||||
return SingleResponse.success();
|
return SingleResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SingleResponse<Void> updateState(OrgInfoUpdateStateCmd cmd) {
|
||||||
|
orgInfoDomainService.updateState(cmd.getId(), cmd.getState());
|
||||||
|
return SingleResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SingleResponse<Void> resetPassword(Long id) {
|
||||||
|
OrgInfoEntity entity = orgInfoDomainService.get(id);
|
||||||
|
if (entity == null) {
|
||||||
|
throw new BizException(ErrorCode.ORG_INFO_NOT_FOUND);
|
||||||
|
}
|
||||||
|
// 联调阶段:密码重置占位,后续对接统一用户中心
|
||||||
|
orgInfoDomainService.resetPassword(entity.getCreateId());
|
||||||
|
return SingleResponse.success();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResponse<OrgInfoCO> page(OrgInfoPageQuery query) {
|
public PageResponse<OrgInfoCO> page(OrgInfoPageQuery query) {
|
||||||
OrgInfoQuery domainQuery = new OrgInfoQuery();
|
OrgInfoQuery domainQuery = new OrgInfoQuery();
|
||||||
|
|
@ -187,6 +209,7 @@ public class OrgInfoExecutor implements OrgInfoApi {
|
||||||
co.setEconomyIndustryName(entity.getEconomyIndustryName());
|
co.setEconomyIndustryName(entity.getEconomyIndustryName());
|
||||||
co.setAuthStatusCode(entity.getAuthStatusCode());
|
co.setAuthStatusCode(entity.getAuthStatusCode());
|
||||||
co.setAuthStatusName(entity.getAuthStatusName());
|
co.setAuthStatusName(entity.getAuthStatusName());
|
||||||
|
co.setState(entity.getState());
|
||||||
co.setTenantId(entity.getTenantId());
|
co.setTenantId(entity.getTenantId());
|
||||||
return co;
|
return co;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package org.qinan.safetyeval.app.executor;
|
||||||
|
|
||||||
import com.jjb.saas.system.client.user.facade.UserFacade;
|
import com.jjb.saas.system.client.user.facade.UserFacade;
|
||||||
import com.jjb.saas.system.client.user.request.FacadeUserAddCmd;
|
import com.jjb.saas.system.client.user.request.FacadeUserAddCmd;
|
||||||
|
import com.jjb.saas.system.client.user.request.UserAddCmd;
|
||||||
|
import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.qinan.safetyeval.app.support.OrgPersonnelChangeRecorder;
|
import org.qinan.safetyeval.app.support.OrgPersonnelChangeRecorder;
|
||||||
import org.qinan.safetyeval.app.support.OrgPersonnelViewEnricher;
|
import org.qinan.safetyeval.app.support.OrgPersonnelViewEnricher;
|
||||||
|
|
@ -21,6 +23,7 @@ import org.qinan.safetyeval.domain.query.PageResult;
|
||||||
import org.qinan.safetyeval.domain.service.OrgPersonnelDomainService;
|
import org.qinan.safetyeval.domain.service.OrgPersonnelDomainService;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
@ -46,16 +49,26 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
||||||
@Autowired(required = false)
|
@Autowired(required = false)
|
||||||
private OrgResignApplyGateway orgResignApplyGateway;
|
private OrgResignApplyGateway orgResignApplyGateway;
|
||||||
|
|
||||||
// @DubboReference
|
@DubboReference
|
||||||
// private UserFacade userFacade;
|
private UserFacade userFacade;
|
||||||
|
|
||||||
|
@Value("${def.password:a123456}")
|
||||||
|
private String defPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public SingleResponse<OrgPersonnelCO> add(OrgPersonnelAddCmd cmd) {
|
public SingleResponse<OrgPersonnelCO> add(OrgPersonnelAddCmd cmd) {
|
||||||
OrgPersonnelEntity entity = toEntity(cmd);
|
OrgPersonnelEntity entity = toEntity(cmd);
|
||||||
OrgPersonnelEntity result = orgPersonnelDomainService.add(entity);
|
OrgPersonnelEntity result = orgPersonnelDomainService.add(entity);
|
||||||
OrgPersonnelCO co = toCO(result);
|
OrgPersonnelCO co = toCO(result);
|
||||||
enrich(co);
|
enrich(co);
|
||||||
// 同步用户信息GBS
|
//todo 同步用户信息GBS
|
||||||
|
UserAddCmd userAddCmd = new UserAddCmd();
|
||||||
|
userAddCmd.setId(result.getId());
|
||||||
|
userAddCmd.setAccount(result.getAccount());
|
||||||
|
userAddCmd.setIdCard(result.getIdCardNo());
|
||||||
|
userAddCmd.setTenantId(result.getTenantId());
|
||||||
|
userFacade.add(userAddCmd);
|
||||||
return SingleResponse.success(co);
|
return SingleResponse.success(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,6 +106,10 @@ public class OrgPersonnelExecutor implements OrgPersonnelApi {
|
||||||
throw new BizException(ErrorCode.ORG_PERSONNEL_NOT_FOUND);
|
throw new BizException(ErrorCode.ORG_PERSONNEL_NOT_FOUND);
|
||||||
}
|
}
|
||||||
// 联调阶段:密码重置占位,后续对接统一用户中心
|
// 联调阶段:密码重置占位,后续对接统一用户中心
|
||||||
|
UserUpdatePasswordCmd userUpdatePasswordCmd = new UserUpdatePasswordCmd();
|
||||||
|
userUpdatePasswordCmd.setId(entity.getId());
|
||||||
|
userUpdatePasswordCmd.setPassword(defPassword);
|
||||||
|
userFacade.updatePassword(userUpdatePasswordCmd);
|
||||||
return SingleResponse.success();
|
return SingleResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import org.qinan.safetyeval.client.dto.SingleResponse;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
import org.qinan.safetyeval.client.dto.OrgInfoAddCmd;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
import org.qinan.safetyeval.client.dto.OrgInfoModifyCmd;
|
||||||
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
import org.qinan.safetyeval.client.dto.OrgInfoPageQuery;
|
||||||
|
import org.qinan.safetyeval.client.dto.OrgInfoUpdateStateCmd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机构信息接口定义(Client层)
|
* 机构信息接口定义(Client层)
|
||||||
|
|
@ -22,6 +23,10 @@ public interface OrgInfoApi {
|
||||||
|
|
||||||
SingleResponse<Void> delete(Long id);
|
SingleResponse<Void> delete(Long id);
|
||||||
|
|
||||||
|
SingleResponse<Void> updateState(OrgInfoUpdateStateCmd cmd);
|
||||||
|
|
||||||
|
SingleResponse<Void> resetPassword(Long id);
|
||||||
|
|
||||||
PageResponse<OrgInfoCO> page(OrgInfoPageQuery query);
|
PageResponse<OrgInfoCO> page(OrgInfoPageQuery query);
|
||||||
|
|
||||||
SingleResponse<OrgInfoCO> getInfo();
|
SingleResponse<OrgInfoCO> getInfo();
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,9 @@ public class OrgInfoCO {
|
||||||
/** authStatusName */
|
/** authStatusName */
|
||||||
private String authStatusName;
|
private String authStatusName;
|
||||||
|
|
||||||
|
/** 状态(0启用1禁用) */
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
/** 租户ID */
|
/** 租户ID */
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package org.qinan.safetyeval.client.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构信息启用/禁用命令
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OrgInfoUpdateStateCmd {
|
||||||
|
|
||||||
|
/** 主键ID */
|
||||||
|
@NotNull(message = "机构ID不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 状态(0启用1禁用) */
|
||||||
|
@NotNull(message = "状态不能为空")
|
||||||
|
@Min(value = 0, message = "状态值无效")
|
||||||
|
@Max(value = 1, message = "状态值无效")
|
||||||
|
private Integer state;
|
||||||
|
}
|
||||||
|
|
@ -115,9 +115,14 @@ public class OrgInfoEntity {
|
||||||
/** 认证状态名称 */
|
/** 认证状态名称 */
|
||||||
private String authStatusName;
|
private String authStatusName;
|
||||||
|
|
||||||
|
/** 状态(0启用1禁用) */
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
/** 租户ID */
|
/** 租户ID */
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
/** 单位ID */
|
/** 单位ID */
|
||||||
private Long orgId;
|
private Long orgId;
|
||||||
|
/** 创建人 */
|
||||||
|
private Long createId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,11 @@ public interface OrgInfoGateway {
|
||||||
|
|
||||||
void delete(Long id);
|
void delete(Long id);
|
||||||
|
|
||||||
|
void updateState(Long id, Integer state);
|
||||||
|
|
||||||
PageResult<OrgInfoEntity> page(OrgInfoQuery query);
|
PageResult<OrgInfoEntity> page(OrgInfoQuery query);
|
||||||
|
|
||||||
OrgInfoEntity getInfo();
|
OrgInfoEntity getInfo();
|
||||||
|
|
||||||
|
void resetPassword(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,14 @@ public class OrgInfoDomainService {
|
||||||
orgInfoGateway.delete(id);
|
orgInfoGateway.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateState(Long id, Integer state) {
|
||||||
|
OrgInfoEntity existing = orgInfoGateway.get(id);
|
||||||
|
if (existing == null) {
|
||||||
|
throw new BizException(ErrorCode.ORG_INFO_NOT_FOUND);
|
||||||
|
}
|
||||||
|
orgInfoGateway.updateState(id, state);
|
||||||
|
}
|
||||||
|
|
||||||
public PageResult<OrgInfoEntity> page(OrgInfoQuery query) {
|
public PageResult<OrgInfoEntity> page(OrgInfoQuery query) {
|
||||||
return orgInfoGateway.page(query);
|
return orgInfoGateway.page(query);
|
||||||
}
|
}
|
||||||
|
|
@ -52,4 +60,8 @@ public class OrgInfoDomainService {
|
||||||
public OrgInfoEntity getInfo() {
|
public OrgInfoEntity getInfo() {
|
||||||
return orgInfoGateway.getInfo();
|
return orgInfoGateway.getInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetPassword(Long id) {
|
||||||
|
orgInfoGateway.resetPassword(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ public class OrgInfoDO {
|
||||||
private String economyIndustryName;
|
private String economyIndustryName;
|
||||||
private Integer authStatusCode;
|
private Integer authStatusCode;
|
||||||
private String authStatusName;
|
private String authStatusName;
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
// ---- GBS默认字段 ----
|
// ---- GBS默认字段 ----
|
||||||
private String deleteEnum;
|
private String deleteEnum;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ package org.qinan.safetyeval.infrastructure.gatewayimpl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.jjb.saas.system.client.user.facade.UserFacade;
|
||||||
|
import com.jjb.saas.system.client.user.request.UserUpdatePasswordCmd;
|
||||||
|
import com.jjb.saas.system.client.user.request.UserUpdateQuitCmd;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
import org.qinan.safetyeval.domain.entity.OrgInfoEntity;
|
||||||
import org.qinan.safetyeval.domain.gateway.OrgInfoGateway;
|
import org.qinan.safetyeval.domain.gateway.OrgInfoGateway;
|
||||||
import org.qinan.safetyeval.domain.query.OrgInfoQuery;
|
import org.qinan.safetyeval.domain.query.OrgInfoQuery;
|
||||||
|
|
@ -13,13 +17,16 @@ import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelDO;
|
||||||
import org.qinan.safetyeval.infrastructure.mapper.OrgInfoMapper;
|
import org.qinan.safetyeval.infrastructure.mapper.OrgInfoMapper;
|
||||||
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper;
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper;
|
||||||
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
import org.qinan.safetyeval.infrastructure.support.InsertFieldDefaults;
|
||||||
|
import org.qinan.safetyeval.infrastructure.support.OrgInfoCascadeDeleter;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -34,10 +41,19 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
||||||
private OrgInfoMapper orgInfoMapper;
|
private OrgInfoMapper orgInfoMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private OrgPersonnelMapper orgPersonnelMapper;
|
private OrgPersonnelMapper orgPersonnelMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgInfoCascadeDeleter orgInfoCascadeDeleter;
|
||||||
|
@DubboReference
|
||||||
|
private UserFacade userFacade;
|
||||||
|
@Value("${def.password:a123456}")
|
||||||
|
private String defPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrgInfoEntity save(OrgInfoEntity entity) {
|
public OrgInfoEntity save(OrgInfoEntity entity) {
|
||||||
OrgInfoDO dataObject = toDO(entity);
|
OrgInfoDO dataObject = toDO(entity);
|
||||||
|
if (dataObject.getState() == null) {
|
||||||
|
dataObject.setState(0);
|
||||||
|
}
|
||||||
InsertFieldDefaults.apply(dataObject);
|
InsertFieldDefaults.apply(dataObject);
|
||||||
orgInfoMapper.insert(dataObject);
|
orgInfoMapper.insert(dataObject);
|
||||||
entity.setId(dataObject.getId());
|
entity.setId(dataObject.getId());
|
||||||
|
|
@ -68,10 +84,47 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void delete(Long id) {
|
public void delete(Long id) {
|
||||||
|
// 同步删除gbs用户(gbs物理)
|
||||||
|
List<Long> orgPersonnelDOIdS = orgPersonnelMapper.selectList(new LambdaQueryWrapper<OrgPersonnelDO>()
|
||||||
|
.eq(OrgPersonnelDO::getOrgId, id)).stream().map(OrgPersonnelDO::getId).collect(Collectors.toList());
|
||||||
|
if (!CollectionUtils.isEmpty(orgPersonnelDOIdS)) {
|
||||||
|
for (Long orgPersonnelDOId : orgPersonnelDOIdS) {
|
||||||
|
userFacade.delete(orgPersonnelDOId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
orgInfoCascadeDeleter.deleteRelatedData(id);
|
||||||
orgInfoMapper.deleteById(id);
|
orgInfoMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateState(Long id, Integer state) {
|
||||||
|
OrgInfoDO update = new OrgInfoDO();
|
||||||
|
update.setId(id);
|
||||||
|
update.setState(state);
|
||||||
|
InsertFieldDefaults.applyForUpdate(update);
|
||||||
|
orgInfoMapper.updateById(update);
|
||||||
|
// 同步启用禁用gbs用户
|
||||||
|
List<Long> orgPersonnelDOIdS = orgPersonnelMapper.selectList(new LambdaQueryWrapper<OrgPersonnelDO>()
|
||||||
|
.eq(OrgPersonnelDO::getOrgId, id)).stream().map(OrgPersonnelDO::getId).collect(Collectors.toList());
|
||||||
|
if (!CollectionUtils.isEmpty(orgPersonnelDOIdS)) {
|
||||||
|
for (Long orgPersonnelDOId : orgPersonnelDOIdS) {
|
||||||
|
UserUpdateQuitCmd userUpdateQuitCmd = new UserUpdateQuitCmd();
|
||||||
|
userUpdateQuitCmd.setId(orgPersonnelDOId);
|
||||||
|
if (state == 1) {
|
||||||
|
// 禁用
|
||||||
|
userFacade.quit(userUpdateQuitCmd);
|
||||||
|
} else {
|
||||||
|
// 启用
|
||||||
|
userFacade.restoreJob(userUpdateQuitCmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OrgInfoEntity> page(OrgInfoQuery query) {
|
public PageResult<OrgInfoEntity> page(OrgInfoQuery query) {
|
||||||
LambdaQueryWrapper<OrgInfoDO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<OrgInfoDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
@ -117,6 +170,15 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
||||||
return toEntity(dataObject.get(0));
|
return toEntity(dataObject.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetPassword(Long id) {
|
||||||
|
// 同步重置gbs用户密码
|
||||||
|
UserUpdatePasswordCmd userUpdatePasswordCmd = new UserUpdatePasswordCmd();
|
||||||
|
userUpdatePasswordCmd.setId(id);
|
||||||
|
userUpdatePasswordCmd.setPassword(defPassword);
|
||||||
|
userFacade.updatePassword(userUpdatePasswordCmd);
|
||||||
|
}
|
||||||
|
|
||||||
private OrgInfoDO toDO(OrgInfoEntity entity) {
|
private OrgInfoDO toDO(OrgInfoEntity entity) {
|
||||||
OrgInfoDO dataObject = new OrgInfoDO();
|
OrgInfoDO dataObject = new OrgInfoDO();
|
||||||
dataObject.setUnitName(entity.getUnitName());
|
dataObject.setUnitName(entity.getUnitName());
|
||||||
|
|
@ -152,6 +214,7 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
||||||
dataObject.setEconomyIndustryName(entity.getEconomyIndustryName());
|
dataObject.setEconomyIndustryName(entity.getEconomyIndustryName());
|
||||||
dataObject.setAuthStatusCode(entity.getAuthStatusCode());
|
dataObject.setAuthStatusCode(entity.getAuthStatusCode());
|
||||||
dataObject.setAuthStatusName(entity.getAuthStatusName());
|
dataObject.setAuthStatusName(entity.getAuthStatusName());
|
||||||
|
dataObject.setState(entity.getState());
|
||||||
dataObject.setTenantId(entity.getTenantId());
|
dataObject.setTenantId(entity.getTenantId());
|
||||||
return dataObject;
|
return dataObject;
|
||||||
}
|
}
|
||||||
|
|
@ -195,6 +258,7 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
||||||
entity.setEconomyIndustryName(dataObject.getEconomyIndustryName());
|
entity.setEconomyIndustryName(dataObject.getEconomyIndustryName());
|
||||||
entity.setAuthStatusCode(dataObject.getAuthStatusCode());
|
entity.setAuthStatusCode(dataObject.getAuthStatusCode());
|
||||||
entity.setAuthStatusName(dataObject.getAuthStatusName());
|
entity.setAuthStatusName(dataObject.getAuthStatusName());
|
||||||
|
entity.setState(dataObject.getState());
|
||||||
entity.setTenantId(dataObject.getTenantId());
|
entity.setTenantId(dataObject.getTenantId());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
package org.qinan.safetyeval.infrastructure.support;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgDepartmentDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgEquipmentDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelCertDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelChangeDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgPersonnelDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgPositionDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgQualificationDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.OrgResignApplyDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingChangeDetailDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingChangeDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingCommitmentDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingEquipmentDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingMaterialDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingPersonnelCertDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.QualFilingPersonnelDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgDepartmentMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgEquipmentMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelCertMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelChangeMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPositionMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgQualificationMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.OrgResignApplyMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingChangeDetailMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingChangeMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingCommitmentMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingEquipmentMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingMaterialMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingPersonnelCertMapper;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.QualFilingPersonnelMapper;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按 org_info.id 级联删除关联数据(应用层维护,无数据库外键)。
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class OrgInfoCascadeDeleter {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QualFilingChangeDetailMapper qualFilingChangeDetailMapper;
|
||||||
|
@Resource
|
||||||
|
private QualFilingChangeMapper qualFilingChangeMapper;
|
||||||
|
@Resource
|
||||||
|
private QualFilingPersonnelCertMapper qualFilingPersonnelCertMapper;
|
||||||
|
@Resource
|
||||||
|
private QualFilingEquipmentMapper qualFilingEquipmentMapper;
|
||||||
|
@Resource
|
||||||
|
private QualFilingPersonnelMapper qualFilingPersonnelMapper;
|
||||||
|
@Resource
|
||||||
|
private QualFilingMaterialMapper qualFilingMaterialMapper;
|
||||||
|
@Resource
|
||||||
|
private QualFilingCommitmentMapper qualFilingCommitmentMapper;
|
||||||
|
@Resource
|
||||||
|
private QualFilingMapper qualFilingMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgPersonnelChangeMapper orgPersonnelChangeMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgPersonnelCertMapper orgPersonnelCertMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgResignApplyMapper orgResignApplyMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgPersonnelMapper orgPersonnelMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgEquipmentMapper orgEquipmentMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgQualificationMapper orgQualificationMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgPositionMapper orgPositionMapper;
|
||||||
|
@Resource
|
||||||
|
private OrgDepartmentMapper orgDepartmentMapper;
|
||||||
|
|
||||||
|
public void deleteRelatedData(Long orgInfoId) {
|
||||||
|
deleteByOrgId(qualFilingChangeDetailMapper, QualFilingChangeDetailDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(qualFilingChangeMapper, QualFilingChangeDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(qualFilingPersonnelCertMapper, QualFilingPersonnelCertDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(qualFilingEquipmentMapper, QualFilingEquipmentDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(qualFilingPersonnelMapper, QualFilingPersonnelDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(qualFilingMaterialMapper, QualFilingMaterialDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(qualFilingCommitmentMapper, QualFilingCommitmentDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(qualFilingMapper, QualFilingDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgPersonnelChangeMapper, OrgPersonnelChangeDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgPersonnelCertMapper, OrgPersonnelCertDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgResignApplyMapper, OrgResignApplyDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgPersonnelMapper, OrgPersonnelDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgEquipmentMapper, OrgEquipmentDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgQualificationMapper, OrgQualificationDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgPositionMapper, OrgPositionDO::getOrgId, orgInfoId);
|
||||||
|
deleteByOrgId(orgDepartmentMapper, OrgDepartmentDO::getOrgId, orgInfoId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> void deleteByOrgId(BaseMapper<T> mapper, SFunction<T, Long> orgIdColumn, Long orgInfoId) {
|
||||||
|
mapper.delete(new LambdaQueryWrapper<T>().eq(orgIdColumn, orgInfoId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -116,3 +116,5 @@ safety-eval:
|
||||||
system-user-name: local-dev
|
system-user-name: local-dev
|
||||||
tenant-id: 1001
|
tenant-id: 1001
|
||||||
org-id: 1
|
org-id: 1
|
||||||
|
def:
|
||||||
|
passwrod: a123456
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue