主从库双数据源
This commit is contained in:
@@ -8,6 +8,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.wms.admin.auth.model.req.LoginReq;
|
||||
import top.wms.admin.common.constant.DataSourceContextHolder;
|
||||
import top.wms.admin.common.context.RoleContext;
|
||||
import top.wms.admin.common.context.UserContext;
|
||||
import top.wms.admin.common.context.UserContextHolder;
|
||||
@@ -91,6 +92,14 @@ public abstract class AbstractLoginHandler<T extends LoginReq> implements LoginH
|
||||
userContext.setClientType(client.getClientType());
|
||||
model.setExtra(CLIENT_ID, client.getClientId());
|
||||
userContext.setClientId(client.getClientId());
|
||||
// 设置数据源(如果用户未配置,则使用默认主库)
|
||||
String dataSource = user.getDataSource();
|
||||
if (dataSource == null || dataSource.isEmpty()) {
|
||||
dataSource = "wms"; // 默认主库
|
||||
}
|
||||
userContext.setDataSource(dataSource);
|
||||
DataSourceContextHolder.setDataSource(dataSource);
|
||||
|
||||
// 登录并缓存用户信息
|
||||
StpUtil.login(userContext.getId(), model.setExtraData(BeanUtil.beanToMap(new UserExtraContext(SpringWebUtils
|
||||
.getRequest()))));
|
||||
@@ -108,4 +117,4 @@ public abstract class AbstractLoginHandler<T extends LoginReq> implements LoginH
|
||||
// DeptDO dept = deptService.getById(user.getDeptId());
|
||||
// CheckUtils.throwIfEqual(DisEnableStatusEnum.DISABLE, dept.getStatus(), "此账号所属部门已被禁用,如有疑问,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import top.continew.starter.data.mp.base.BaseMapper;
|
||||
import top.wms.admin.fullWorkOrder.model.entity.FullWorkOrderDO;
|
||||
import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 整箱领取记录 Mapper
|
||||
*
|
||||
@@ -21,4 +23,6 @@ public interface FullWorkOrderMapper extends BaseMapper<FullWorkOrderDO> {
|
||||
|
||||
IPage<FullWorkOrderResp> selectFullWorkOrderPage(@Param("page") Page<Object> objectPage,
|
||||
@Param(Constants.WRAPPER) QueryWrapper<FullWorkOrderDO> queryWrapper);
|
||||
|
||||
List<FullWorkOrderResp> selectFullWorkOrderExport(@Param(Constants.WRAPPER) QueryWrapper<FullWorkOrderDO> queryWrapper);
|
||||
}
|
||||
@@ -92,4 +92,9 @@ public class UserDO extends BaseDO {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Long equipmentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据源标识(wms/wms2)
|
||||
*/
|
||||
private String dataSource;
|
||||
}
|
||||
@@ -93,6 +93,12 @@ public class UserReq implements Serializable {
|
||||
@Schema(description = "状态", example = "1")
|
||||
private DisEnableStatusEnum status;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "数据源")
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
|
||||
@@ -116,6 +116,12 @@ public class UserDetailResp extends BaseDetailResp {
|
||||
@Schema(description = "设备ID")
|
||||
private Long equipmentId;
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
*/
|
||||
@Schema(description = "数据源")
|
||||
private String dataSource;
|
||||
|
||||
@Override
|
||||
public Boolean getDisabled() {
|
||||
return this.getIsSystem() || Objects.equals(this.getId(), UserContextHolder.getUserId());
|
||||
|
||||
@@ -81,6 +81,12 @@ public class UserResp extends BaseDetailResp {
|
||||
@Schema(description = "描述", example = "张三描述信息")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@Schema(description = "数据源")
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 角色名称列表
|
||||
*/
|
||||
|
||||
@@ -12,4 +12,15 @@
|
||||
left join sys_user u on f.create_user = u.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="selectFullWorkOrderExport" resultType="top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp">
|
||||
select
|
||||
f.*,
|
||||
m.material_name materialName,
|
||||
u.username createUserString
|
||||
from
|
||||
sys_full_work_order f
|
||||
left join sys_material_info m on f.material_code = m.encoding
|
||||
left join sys_user u on f.create_user = u.id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -22,7 +22,8 @@
|
||||
t1.is_system,
|
||||
t1.pwd_reset_time,
|
||||
t1.dept_id,
|
||||
t2.name AS deptName
|
||||
t2.name AS deptName,
|
||||
t1.data_source
|
||||
FROM sys_user AS t1
|
||||
LEFT JOIN sys_dept AS t2 ON t2.id = t1.dept_id
|
||||
</sql>
|
||||
|
||||
Reference in New Issue
Block a user