Browse Source

优化oidc创建租户相关流程(通过接口调用完成对接配置)

tags/v2.5.0
xiaoying 1 year ago
parent
commit
b707d77766
26 changed files with 583 additions and 528 deletions
  1. +0
    -39
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/AirportConstant.java
  2. +45
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/DictConstant.java
  3. +0
    -46
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/FreeWayConstant.java
  4. +0
    -47
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/HhzUrlConstant.java
  5. +0
    -43
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/MonitorConstant.java
  6. +0
    -38
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/PilotConstant.java
  7. +0
    -46
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/WaterWayConstant.java
  8. +0
    -38
      tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/WeptspConstant.java
  9. +35
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/DictController.java
  10. +20
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/DictDataMapper.java
  11. +20
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/DictMapper.java
  12. +72
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/entity/Dict.java
  13. +91
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/model/entity/DictData.java
  14. +13
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/DictDataService.java
  15. +20
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/DictService.java
  16. +22
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/DictDataServiceImpl.java
  17. +78
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/DictServiceImpl.java
  18. +79
    -166
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java
  19. +31
    -65
      tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/impl/ThirdServiceImpl.java
  20. +31
    -0
      tuoheng_oidc_admin/src/main/resources/mapper/DictDataMapper.xml
  21. +26
    -0
      tuoheng_oidc_admin/src/main/resources/mapper/DictMapper.xml
  22. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/TenantServiceImpl.class
  23. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl$1.class
  24. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl$2.class
  25. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl$3.class
  26. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl.class

+ 0
- 39
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/AirportConstant.java View File

@@ -1,39 +0,0 @@
package com.tuoheng.constant;

import lombok.Data;

/**
* 机场平台接口常量类
*
* @Author xiaoying
* @Date 2023/1/31 17:45
*/
public class AirportConstant {

public static final String AIRPORT_CLIENT = "tuoheng-airport";

public static final String AIRPORT_NAME = "机场业务平台";

/**
* 创建租户
*/
public static final String CREATE_TENANT = "/api/airportInterface/addTenant";
/**
* 修改租户
*/
public static final String EDIT_TENANT = "/api/airportInterface/editTenant";
/**
* 删除租户
*/
public static final String DELETE_TENANT = "/api/airportInterface/delTenant";
/**
* 查询可用角色
*/
public static final String FIND_ROLE = "/api/airportInterface/getRoleList";

/**
* 查询角色对应菜单
*/
public static final String FIND_MENU = "/api/airportInterface/getMenuList/{roleId}";

}

+ 45
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/DictConstant.java View File

@@ -0,0 +1,45 @@
package com.tuoheng.constant;

/**
* 字典表-平台相关常量
*/
public class DictConstant {
/**
* 添加-租户
*/
public static final String ADD_TENANT = "addTenant";
/**
* 编辑-租户
*/
public static final String EDIT_TENANT = "editTenant";
/**
* 删除-租户
*/
public static final String DELETE_TENANT = "deleteTenant";
/**
* 查询角色
*/
public static final String GET_ROLE = "getRole";
/**
* 查询菜单
*/
public static final String GET_MENU = "getMenu";
/**
* 系统名
*/
public static final String GET_NAME = "getName";
/**
* 平台标识
*/
public static final String CLIENT = "client";
/**
* pc标识
*/
public static final String ADMIN = "admin";
/**
* 小程序标识
*/
public static final String MP = "mp";


}

+ 0
- 46
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/FreeWayConstant.java View File

@@ -1,46 +0,0 @@
package com.tuoheng.constant;

/**
* 高速平台接口常量类
* @Author xiaoying
* @Date 2023/2/23 9:32
*/
public class FreeWayConstant {

/**
* pc端
*/
public static final String FREEWAY_CLIENT_ADMIN = "tuoheng-freeway-admin";
/**
* web端
*/
public static final String FREEWAY_CLIENT_MP = "tuoheng-freeway-mp";

public static final String FREEWAY_CLIENT="tuoheng-freeway";


public static final String FREEWAY_NAME="高速业务平台";

/**
* 创建租户
*/
public static final String CREATE_TENANT = "/oidc/callback/tenant/create";
/**
* 更新租户
*/
public static final String UPDATE_TENANT = "/oidc/callback/tenant/edit";
/**
* 逻辑删除租户
*/
public static final String DELETE_TENANT = "/oidc/callback/tenant/deleted";

/**
* 查询可用角色
*/
public static final String FIND_ROLE = "/oidc/callback/getRoleList";

/**
* 查询可用角色
*/
public static final String FIND_MENU = "/oidc/callback/getMenuList/{roleId}";
}

+ 0
- 47
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/HhzUrlConstant.java View File

@@ -1,47 +0,0 @@
package com.tuoheng.constant;

/**
* hhz平台接口常量类
* @Author xiaoying
* @Date 2022/10/18 10:52
*/
public class HhzUrlConstant {

public static final String HHZ_CLIENT="tuoheng-hhz";
/**
* 河湖长-pc端
*/
public static final String HHZ_CLIENT_ADMIN = "tuoheng-hhz-admin";

public static final String HHZ_CLIENT_MP = "tuoheng-hhz-mp";



public static final String HHZ_NAME="河湖长业务平台";

/**
* 创建租户
*/
public static final String CREATE_TENANT = "/oidcTenant/add";
/**
* 编辑租户
*/
public static final String UPDATE_TENANT = "/oidcTenant/edit";

public static final String DELETE_TENANT = "/oidcTenant/delete";

/**
* 查询可用角色
*/
public static final String FIND_ROLE = "/oidcTenant/getRoleList";

/**
* 查询可用角色
*/
public static final String FIND_MENU = "/oidcTenant/getMenuList/{roleId}";





}

+ 0
- 43
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/MonitorConstant.java View File

@@ -1,43 +0,0 @@
package com.tuoheng.constant;

/**
* 大气监测相关常量类
* @Author xiaoying
* @Date 2023/5/18 8:56
*/
public class MonitorConstant {

public static final String AIRMONITOR_CLIENT="tuoheng-airmonitor";
/**
* 空气监测-pc端
*/
public static final String AIRMONITOR_CLIENT_ADMIN = "tuoheng-airmonitor-admin";

public static final String AIRMONITOR_CLIENT_MP = "tuoheng-airmonitor-mp";



public static final String AIRMONITOR_NAME="大气监测业务平台";

/**
* 创建租户
*/
public static final String CREATE_TENANT = "/oidc/callback/tenant/create";
/**
* 更新租户
*/
public static final String UPDATE_TENANT = "/oidc/callback/tenant/edit";
/**
* 逻辑删除租户
*/
public static final String DELETE_TENANT = "/oidc/callback/tenant/deleted";
/**
* 查询可用角色
*/
public static final String FIND_ROLE = "/oidc/callback/getRoleList";

/**
* 查询可用角色
*/
public static final String FIND_MENU = "/oidc/callback/getMenuList/{roleId}";
}

+ 0
- 38
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/PilotConstant.java View File

@@ -1,38 +0,0 @@
package com.tuoheng.constant;

/**
* @Author xiaoying
* @Date 2023/3/1 11:10
*/
public class PilotConstant {
public static final String PILOT_CLIENT="tuoheng-pilot";
/**
* 河湖长-pc端
*/
public static final String PILOT_CLIENT_ADMIN = "tuoheng-pilot-admin";

public static final String PILOT_CLIENT_MP = "tuoheng-pilot-mp";



public static final String PILOT_NAME="飞手业务平台";

/**
* 创建租户
*/
public static final String CREATE_TENANT = "/oidcTenant/add";
/**
* 编辑租户
*/
public static final String UPDATE_TENANT = "/oidcTenant/edit";

public static final String DELETE_TENANT = "/oidcTenant/delete";
/**
* 查询可用角色
*/
public static final String FIND_ROLE = "/oidcTenant/getRoleList";
/**
* 查询可用角色
*/
public static final String FIND_MENU = "/oidcTenant/getMenuList/{roleId}";
}

+ 0
- 46
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/WaterWayConstant.java View File

@@ -1,46 +0,0 @@
package com.tuoheng.constant;

/**
* 航道平台接口常量类
*
* @Author xiaoying
* @Date 2023/2/23 9:34
*/
public class WaterWayConstant {


public static final String WATERWAY_CLIENT = "tuoheng-waterway";
/**
* 航道pc端
*/
public static final String WATERWAY_CLIENT_ADMIN = "tuoheng-waterway-admin";
/**
* 航道小程序端
*/
public static final String WATERWAY_CLIENT_MP = "tuoheng-waterway-mp";



public static final String WATERWAY_NAME = "航道业务平台";
/**
* 创建租户
*/
public static final String CREATE_TENANT = "/oidc/callback/tenant/create";
/**
* 更新租户
*/
public static final String UPDATE_TENANT = "/oidc/callback/tenant/edit";
/**
* 逻辑删除租户
*/
public static final String DELETE_TENANT = "/oidc/callback/tenant/deleted";
/**
* 查询可用角色
*/
public static final String FIND_ROLE = "/oidc/callback/getRoleList";

/**
* 查询可用角色
*/
public static final String FIND_MENU = "/oidc/callback/getMenuList/{roleId}";
}

+ 0
- 38
tuoheng_oidc_admin/src/main/java/com/tuoheng/constant/WeptspConstant.java View File

@@ -1,38 +0,0 @@
package com.tuoheng.constant;

/**
* @Author xiaoying
* @Date 2023/5/15 16:08
*/
public class WeptspConstant {
public static final String WEPTSP_CLIENT="tuoheng-weptsp";
/**
* 河湖长-pc端
*/
public static final String WEPTSP_CLIENT_ADMIN = "tuoheng-weptsp-admin";

public static final String WEPTSP_CLIENT_MP = "tuoheng-weptsp-mp";



public static final String WEPTSP_NAME="水环境监测业务平台";

/**
* 创建租户
*/
public static final String CREATE_TENANT = "/oidcTenant/add";
/**
* 编辑租户
*/
public static final String UPDATE_TENANT = "/oidcTenant/edit";

public static final String DELETE_TENANT = "/oidcTenant/delete";
/**
* 查询可用角色
*/
public static final String FIND_ROLE = "/oidcTenant/getRoleList";
/**
* 查询可用角色
*/
public static final String FIND_MENU = "/oidcTenant/getMenuList/{roleId}";
}

+ 35
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/controller/DictController.java View File

@@ -0,0 +1,35 @@
package com.tuoheng.controller;

import com.tuoheng.service.DictService;
import com.tuoheng.until.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* @Author xiaoying
* @Date 2023/6/2 16:29
*/
@RestController
@RequestMapping("/dict")
public class DictController {

@Autowired
private DictService dictService;

/**
* 初始化平台对应字典数据
*
* @param code 平台code
* @return
*/
@PostMapping("/init")
public JsonResult init(String code) {
return dictService.init(code);

}

}

+ 20
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/DictDataMapper.java View File

@@ -0,0 +1,20 @@
package com.tuoheng.mapper;

import com.tuoheng.model.entity.DictData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
* @author 小影
* @description 针对表【t_dict_data(字典数据表)】的数据库操作Mapper
* @createDate 2023-06-02 16:27:47
* @Entity com.tuoheng.model.entity.DictData
*/
@Mapper
public interface DictDataMapper extends BaseMapper<DictData> {

}





+ 20
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/DictMapper.java View File

@@ -0,0 +1,20 @@
package com.tuoheng.mapper;

import com.tuoheng.model.entity.Dict;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
* @author 小影
* @description 针对表【t_dict(字典类型表)】的数据库操作Mapper
* @createDate 2023-06-02 16:27:18
* @Entity com.tuoheng.model.entity.Dict
*/
@Mapper
public interface DictMapper extends BaseMapper<Dict> {

}





+ 72
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/entity/Dict.java View File

@@ -0,0 +1,72 @@
package com.tuoheng.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
* 字典类型表
*
* @TableName t_dict
*/
@TableName(value = "t_dict")
@Data
public class Dict implements Serializable {
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;

/**
* 字典名称
*/
private String dictName;

/**
* 字典类型
*/
private String type;

/**
* 状态(1正常 0停用)
*/
private Integer status;

/**
* 创建者
*/
private String createUser;

/**
* 创建时间
*/
private Date createTime;

/**
* 更新者
*/
private String updateUser;

/**
* 更新时间
*/
private Date updateTime;

/**
* 备注
*/
private String remark;
/**
* 0 删除 1正常
*/
private Integer mark;

@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

+ 91
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/model/entity/DictData.java View File

@@ -0,0 +1,91 @@
package com.tuoheng.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;

/**
* 字典数据表
* @TableName t_dict_data
*/
@TableName(value ="t_dict_data")
@Data
public class DictData implements Serializable {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;

/**
* 字典名称
*/
private String dictName;

/**
* 字典对应type
*/
private String dictType;

/**
* 对应值
*/
private String value;

/**
* 字典类型
*/
private String code;

/**
* 状态(1正常 0停用)
*/
private Integer status;

/**
* 创建者
*/
private String createUser;

/**
* 创建时间
*/
private Date createTime;

/**
* 更新者
*/
private String updateUser;

/**
* 更新时间
*/
private Date updateTime;

/**
* 备注
*/
private String remark;

/**
* 租户id
*/
private String tenantId;

/**
* 0 删除 1正常
*/
private Integer mark;

/**
* 排序
*/
private Integer sort;

@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

+ 13
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/DictDataService.java View File

@@ -0,0 +1,13 @@
package com.tuoheng.service;

import com.tuoheng.model.entity.DictData;
import com.baomidou.mybatisplus.extension.service.IService;

/**
* @author 小影
* @description 针对表【t_dict_data(字典数据表)】的数据库操作Service
* @createDate 2023-06-02 16:27:47
*/
public interface DictDataService extends IService<DictData> {

}

+ 20
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/DictService.java View File

@@ -0,0 +1,20 @@
package com.tuoheng.service;

import com.tuoheng.model.entity.Dict;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tuoheng.until.JsonResult;

/**
* @author 小影
* @description 针对表【t_dict(字典类型表)】的数据库操作Service
* @createDate 2023-06-02 16:27:18
*/
public interface DictService extends IService<Dict> {
/**
* 初始化平台对应字典数据
*
* @param code 平台code
* @return
*/
JsonResult init(String code);
}

+ 22
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/DictDataServiceImpl.java View File

@@ -0,0 +1,22 @@
package com.tuoheng.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.model.entity.DictData;
import com.tuoheng.service.DictDataService;
import com.tuoheng.mapper.DictDataMapper;
import org.springframework.stereotype.Service;

/**
* @author 小影
* @description 针对表【t_dict_data(字典数据表)】的数据库操作Service实现
* @createDate 2023-06-02 16:27:47
*/
@Service
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData>
implements DictDataService{

}





+ 78
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/DictServiceImpl.java View File

@@ -0,0 +1,78 @@
package com.tuoheng.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tuoheng.enums.MarkTypeEnum;
import com.tuoheng.mapper.DictDataMapper;
import com.tuoheng.mapper.PlatformMapper;
import com.tuoheng.model.dto.Platform;
import com.tuoheng.model.entity.Dict;
import com.tuoheng.model.entity.DictData;
import com.tuoheng.service.DictDataService;
import com.tuoheng.service.DictService;
import com.tuoheng.mapper.DictMapper;
import com.tuoheng.until.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author 小影
* @description 针对表【t_dict(字典类型表)】的数据库操作Service实现
* @createDate 2023-06-02 16:27:18
*/
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict>
implements DictService {

@Autowired
private DictMapper dictMapper;
@Autowired
private DictDataMapper dictDataMapper;
@Autowired
private DictDataService dictDataService;
@Autowired
private PlatformMapper platformMapper;


/**
* 初始化平台对应字典数据
*
* @param code 平台code
* @return
*/
@Override
@Transactional
public JsonResult init(String code) {

Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getMark, MarkTypeEnum.VALID.getCode())
.eq(Platform::getPlatformCode, code));
if (ObjectUtil.isNull(platform)) {
return JsonResult.error("对应业务平台不存在,请检查后初始化");
}

List<DictData> list = dictDataMapper.selectList(Wrappers.<DictData>lambdaQuery()
.eq(DictData::getMark, MarkTypeEnum.VALID.getCode())
.eq(DictData::getDictType, "tuoheng-hhz"));
//添加字典表
Dict dict = new Dict();
dict.setDictName(platform.getPlatformName());
dict.setType(code);
dictMapper.insert(dict);
//添加对应数据
for (DictData dictData : list) {
dictData.setDictType(code);
dictData.setId(null);
}
dictDataService.saveBatch(list);
return JsonResult.success("初始化成功请修改对应数据值");
}
}





+ 79
- 166
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java View File

@@ -13,9 +13,11 @@ import com.tuoheng.common.CommonConfig;
import com.tuoheng.common.ServiceException;
import com.tuoheng.common.ServiceExceptionEnum;
import com.tuoheng.constant.*;
import com.tuoheng.enums.MarkTypeEnum;
import com.tuoheng.mapper.*;
import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.model.dto.Platform;
import com.tuoheng.model.entity.DictData;
import com.tuoheng.model.entity.TenantEmploy;
import com.tuoheng.model.entity.TenantItem;
import com.tuoheng.model.param.ClientRoleDto;
@@ -84,6 +86,8 @@ public class TenantServiceImpl implements TenantService {

@Autowired
private TenantItemMapper tenantItemMapper;
@Autowired
private DictDataMapper dictDataMapper;


@Override
@@ -191,7 +195,7 @@ public class TenantServiceImpl implements TenantService {
for (ClientRoleDto clientRoleDto : list) {
try {
log.info("参数:{}", clientRoleDto.toString());
JsonResult result = getResult(createClientTenantDto, clientRoleDto.getClientId(), loginUser);
JsonResult result = getResult(createClientTenantDto, clientRoleDto.getClientId(), DictConstant.ADD_TENANT, loginUser);
if (JsonResult.SUCCESS != result.getCode()) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), result.getMsg());
}
@@ -217,38 +221,14 @@ public class TenantServiceImpl implements TenantService {
//遍历获取参数进项封装
for (ClientRoleDto dto : clientRoleDtoList) {

switch (dto.getClientId()) {
//暂时河湖长,动态匹配其他平台
case HhzUrlConstant.HHZ_CLIENT:
addClientRoleDtoList(HhzUrlConstant.HHZ_CLIENT_MP, dto, list);
addClientRoleDtoList(HhzUrlConstant.HHZ_CLIENT_ADMIN, dto, list);
break;
case PilotConstant.PILOT_CLIENT:
addClientRoleDtoList(PilotConstant.PILOT_CLIENT_ADMIN, dto, list);
addClientRoleDtoList(PilotConstant.PILOT_CLIENT_MP, dto, list);
break;
case FreeWayConstant.FREEWAY_CLIENT:
addClientRoleDtoList(FreeWayConstant.FREEWAY_CLIENT_ADMIN, dto, list);
addClientRoleDtoList(FreeWayConstant.FREEWAY_CLIENT_MP, dto, list);
break;
case WaterWayConstant.WATERWAY_CLIENT:
addClientRoleDtoList(WaterWayConstant.WATERWAY_CLIENT_ADMIN, dto, list);
addClientRoleDtoList(WaterWayConstant.WATERWAY_CLIENT_MP, dto, list);
break;
//水环境
case WeptspConstant.WEPTSP_CLIENT:
addClientRoleDtoList(WeptspConstant.WEPTSP_CLIENT_ADMIN, dto, list);
//addClientRoleDtoList(WeptspConstant.WATERWAY_CLIENT_MP, dto, list);
break;
//大气
case MonitorConstant.AIRMONITOR_CLIENT:
addClientRoleDtoList(MonitorConstant.AIRMONITOR_CLIENT_ADMIN, dto, list);
//addClientRoleDtoList(WeptspConstant.WATERWAY_CLIENT_MP, dto, list);
break;
default:
break;
List<DictData> dictDataList = dictDataMapper.selectList(Wrappers.<DictData>lambdaQuery()
.eq(DictData::getMark, MarkTypeEnum.VALID.getCode()).eq(DictData::getCode, DictConstant.CLIENT));
for (DictData dictData : dictDataList) {
if (dto.getClientId().equals(dictData.getValue())) {
addClientRoleDtoList(getDictData(dictData.getDictType(), DictConstant.MP).getValue(), dto, list);
addClientRoleDtoList(getDictData(dictData.getDictType(), DictConstant.ADMIN).getValue(), dto, list);
}
}

}
return list;
}
@@ -284,20 +264,14 @@ public class TenantServiceImpl implements TenantService {
IPage<UserVo> pageData = clientUserMapper.selectByTenantIdAndPage(query, page);
pageData.convert(x -> {
String platformCode = x.getPlatformCode();
if (platformCode.contains(HhzUrlConstant.HHZ_CLIENT)) {
x.setPlatformName(HhzUrlConstant.HHZ_NAME);
} else if (platformCode.contains(WaterWayConstant.WATERWAY_CLIENT)) {
x.setPlatformName(WaterWayConstant.WATERWAY_NAME);
} else if (platformCode.contains(FreeWayConstant.FREEWAY_CLIENT)) {
x.setPlatformName(FreeWayConstant.FREEWAY_NAME);
} else if (platformCode.contains(PilotConstant.PILOT_CLIENT)) {
x.setPlatformName(PilotConstant.PILOT_NAME);
} else if (platformCode.contains(AirportConstant.AIRPORT_CLIENT)) {
x.setPlatformName(AirportConstant.AIRPORT_NAME);
} else if (platformCode.contains(WeptspConstant.WEPTSP_CLIENT)) {
x.setPlatformName(WeptspConstant.WEPTSP_NAME);
} else if (platformCode.contains(MonitorConstant.AIRMONITOR_CLIENT)) {
x.setPlatformName(MonitorConstant.AIRMONITOR_NAME);
//TODO 后期维护各个业务平台
List<DictData> dictDataList = dictDataMapper.selectList(Wrappers.<DictData>lambdaQuery()
.eq(DictData::getMark, MarkTypeEnum.VALID.getCode()).eq(DictData::getCode, DictConstant.CLIENT));
for (DictData dictData : dictDataList) {
if (platformCode.contains(dictData.getValue())) {
//获取对应平台
x.setPlatformName(getDictData(dictData.getDictType(), DictConstant.GET_NAME).getValue());
}
}
return x;
});
@@ -391,22 +365,15 @@ public class TenantServiceImpl implements TenantService {
List<BusinessSystemVo> businessSystemVoList = new ArrayList<>();
for (AuthoritiesPo authoritiesPo : list) {
//TODO 后期维护各个业务平台
if (authoritiesPo.getAuthority().contains(HhzUrlConstant.HHZ_CLIENT)) {
businessSystemVoList.add(getbusinessSystemVo(HhzUrlConstant.HHZ_CLIENT, HhzUrlConstant.HHZ_NAME));
} else if (authoritiesPo.getAuthority().contains(AirportConstant.AIRPORT_CLIENT)) {
businessSystemVoList.add(getbusinessSystemVo(AirportConstant.AIRPORT_CLIENT, AirportConstant.AIRPORT_NAME));
} else if (authoritiesPo.getAuthority().contains(WaterWayConstant.WATERWAY_CLIENT)) {
businessSystemVoList.add(getbusinessSystemVo(WaterWayConstant.WATERWAY_CLIENT, WaterWayConstant.WATERWAY_NAME));
} else if (authoritiesPo.getAuthority().contains(FreeWayConstant.FREEWAY_CLIENT)) {
businessSystemVoList.add(getbusinessSystemVo(FreeWayConstant.FREEWAY_CLIENT, FreeWayConstant.FREEWAY_NAME));
} else if (authoritiesPo.getAuthority().contains(PilotConstant.PILOT_CLIENT)) {
businessSystemVoList.add(getbusinessSystemVo(PilotConstant.PILOT_CLIENT, PilotConstant.PILOT_NAME));
} else if (authoritiesPo.getAuthority().contains(WeptspConstant.WEPTSP_CLIENT)) {
businessSystemVoList.add(getbusinessSystemVo(WeptspConstant.WEPTSP_CLIENT, WeptspConstant.WEPTSP_NAME));
} else if (authoritiesPo.getAuthority().contains(MonitorConstant.AIRMONITOR_CLIENT)) {
businessSystemVoList.add(getbusinessSystemVo(MonitorConstant.AIRMONITOR_CLIENT, MonitorConstant.AIRMONITOR_NAME));
List<DictData> dictDataList = dictDataMapper.selectList(Wrappers.<DictData>lambdaQuery()
.eq(DictData::getMark, MarkTypeEnum.VALID.getCode()).eq(DictData::getCode, DictConstant.CLIENT));
for (DictData dictData : dictDataList) {
if (authoritiesPo.getAuthority().contains(dictData.getValue())) {
//获取对应平台
Platform platform = getPlatform(dictData.getDictType());
businessSystemVoList.add(getbusinessSystemVo(dictData.getValue(), platform.getPlatformName()));
}
}

}
businessSystemVoList = businessSystemVoList.stream().distinct().collect(Collectors.toList());
vo.setList(businessSystemVoList);
@@ -560,7 +527,7 @@ public class TenantServiceImpl implements TenantService {
public JsonResult deleteTenant(CreateClientTenantDto dto, LoginUser loginUser) {
//通知业务系统进行删除
for (ClientRoleDto clientRoleDto : dto.getClientRoleDtoList()) {
deleteResult(dto, clientRoleDto.getClientId(), loginUser);
deleteResult(dto, clientRoleDto.getClientId(), DictConstant.DELETE_TENANT, loginUser);
}
return JsonResult.success();
}
@@ -631,10 +598,10 @@ public class TenantServiceImpl implements TenantService {
coincideClientRoleDtoList = clientRoleDtoList.stream().filter(t -> list.contains(t)).collect(Collectors.toList());
log.info("删除集合:{}", deleteClientRoleDtoList.toString());
log.info("交集集合:{}", coincideClientRoleDtoList.toString());
//交集集合做更新操作
//交集集合做更新操作 editTenant
for (ClientRoleDto clientRoleDto : coincideClientRoleDtoList) {
try {
editResult(clientTenantDto, clientRoleDto.getClientId(), loginUser);
editResult(clientTenantDto, clientRoleDto.getClientId(), DictConstant.EDIT_TENANT, loginUser);
} catch (Exception e) {
log.info("异常信息捕获,平台标识:{}", clientRoleDto.getClientId());
log.info("异常信息:{}", e.getMessage());
@@ -714,7 +681,7 @@ public class TenantServiceImpl implements TenantService {
for (ClientRoleDto clientRoleDto : insertClientRoleDtoList) {
try {
log.info("参数:{}", clientRoleDto.toString());
JsonResult result = getResult(dto, clientRoleDto.getClientId(), loginUser);
JsonResult result = getResult(dto, clientRoleDto.getClientId(), DictConstant.ADD_TENANT, loginUser);
if (JsonResult.SUCCESS != result.getCode()) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), result.getMsg());
}
@@ -763,10 +730,9 @@ public class TenantServiceImpl implements TenantService {
* @param loginUser
* @return
*/
private JsonResult getResult(CreateClientTenantDto dto, String code, LoginUser loginUser) {
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, code)
.eq(Platform::getMark, 1));
private JsonResult getResult(CreateClientTenantDto dto, String code, String dictCode, LoginUser loginUser) {
//获取对应平台
Platform platform = getPlatform(code);
if (ObjectUtil.isNull(platform)) {
return JsonResult.error("该业务平台不存在");
}
@@ -776,37 +742,11 @@ public class TenantServiceImpl implements TenantService {
//设置地址
String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配 ->并修改对应标识权限
switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = url + HhzUrlConstant.CREATE_TENANT;
break;
//机场
case AirportConstant.AIRPORT_CLIENT:
url = url + AirportConstant.CREATE_TENANT;
break;
//高速
case FreeWayConstant.FREEWAY_CLIENT:
url = url + FreeWayConstant.CREATE_TENANT;
break;
//航道
case WaterWayConstant.WATERWAY_CLIENT:
url = url + WaterWayConstant.CREATE_TENANT;
break;
//飞手
case PilotConstant.PILOT_CLIENT:
url = url + PilotConstant.CREATE_TENANT;
break;
//水环境
case WeptspConstant.WEPTSP_CLIENT:
url = url + WeptspConstant.CREATE_TENANT;
break;
//大气
case MonitorConstant.AIRMONITOR_CLIENT:
url = url + MonitorConstant.CREATE_TENANT;
default:
break;
DictData dictData = getDictData(code, dictCode);
if (ObjectUtil.isNull(dictData)) {
return JsonResult.error("该业务平台对应字典表数据不存在");
}
url = url + dictData.getValue();
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader);
log.info("请求url:{}", url);
ResponseEntity<JsonResult> response;
@@ -834,10 +774,9 @@ public class TenantServiceImpl implements TenantService {
* @param loginUser
* @return
*/
private JsonResult deleteResult(CreateClientTenantDto dto, String code, LoginUser loginUser) {
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, code)
.eq(Platform::getMark, 1));
private JsonResult deleteResult(CreateClientTenantDto dto, String code, String dictCode, LoginUser loginUser) {
//获取对应平台
Platform platform = getPlatform(code);
if (ObjectUtil.isNull(platform)) {
return JsonResult.error("该业务平台不存在");
}
@@ -848,36 +787,11 @@ public class TenantServiceImpl implements TenantService {
//设置地址(hhz平台)
String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配
switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = url + HhzUrlConstant.DELETE_TENANT;
break;
//机场
case AirportConstant.AIRPORT_CLIENT:
url = url + AirportConstant.DELETE_TENANT + CommonConstant.SLASH + dto.getTenantCode();
break;
case FreeWayConstant.FREEWAY_CLIENT:
url = url + FreeWayConstant.DELETE_TENANT;
break;
case WaterWayConstant.WATERWAY_CLIENT:
url = url + WaterWayConstant.DELETE_TENANT;
break;
//飞手
case PilotConstant.PILOT_CLIENT:
url = url + PilotConstant.DELETE_TENANT;
break;
//水环境
case WeptspConstant.WEPTSP_CLIENT:
url = url + WeptspConstant.DELETE_TENANT;
break;
//大气
case MonitorConstant.AIRMONITOR_CLIENT:
url = url + MonitorConstant.DELETE_TENANT;
break;
default:
break;
DictData dictData = getDictData(code, dictCode);
if (ObjectUtil.isNull(dictData)) {
return JsonResult.error("该业务平台对应字典表数据不存在");
}
url = url + dictData.getValue();
log.info("请求url:{}", url);
ResponseEntity<JsonResult> response;
try {
@@ -905,10 +819,8 @@ public class TenantServiceImpl implements TenantService {
* @param loginUser
* @return
*/
private JsonResult editResult(CreateClientTenantDto dto, String code, LoginUser loginUser) {
Platform platform = platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, code)
.eq(Platform::getMark, 1));
private JsonResult editResult(CreateClientTenantDto dto, String code, String dictCode, LoginUser loginUser) {
Platform platform = getPlatform(code);
if (ObjectUtil.isNull(platform)) {
return JsonResult.error("该业务平台不存在");
}
@@ -918,37 +830,11 @@ public class TenantServiceImpl implements TenantService {
HttpEntity httpEntity = new HttpEntity(dto, resultRequestHeader);
//设置地址(hhz平台)
String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配
switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = url + HhzUrlConstant.UPDATE_TENANT;
break;
//机场
case AirportConstant.AIRPORT_CLIENT:
url = url + AirportConstant.EDIT_TENANT;
break;
case FreeWayConstant.FREEWAY_CLIENT:
url = url + FreeWayConstant.UPDATE_TENANT;
break;
case WaterWayConstant.WATERWAY_CLIENT:
url = url + WaterWayConstant.UPDATE_TENANT;
break;
//飞手
case PilotConstant.PILOT_CLIENT:
url = url + PilotConstant.UPDATE_TENANT;
break;
//水环境
case WeptspConstant.WEPTSP_CLIENT:
url = url + WeptspConstant.UPDATE_TENANT;
break;
//大气
case MonitorConstant.AIRMONITOR_CLIENT:
url = url + MonitorConstant.UPDATE_TENANT;
break;
default:
break;
DictData dictData = getDictData(code, dictCode);
if (ObjectUtil.isNull(dictData)) {
return JsonResult.error("该业务平台对应字典表数据不存在");
}
url = url + dictData.getValue();
log.info("请求url:{}", url);
ResponseEntity<JsonResult> response;
try {
@@ -966,4 +852,31 @@ public class TenantServiceImpl implements TenantService {
}
return JsonResult.success();
}

/**
* 获取平台数据
*
* @param code
* @return
*/
private Platform getPlatform(String code) {
return platformMapper.selectOne(Wrappers.<Platform>lambdaQuery()
.eq(Platform::getPlatformCode, code)
.eq(Platform::getMark, 1));
}

/**
* 获取字典表数据
*
* @param code
* @param dictCode
* @return
*/
private DictData getDictData(String code, String dictCode) {
DictData dictData = dictDataMapper.selectOne(Wrappers.<DictData>lambdaQuery()
.eq(DictData::getDictType, code)
.eq(DictData::getCode, dictCode)
.eq(DictData::getMark, MarkTypeEnum.VALID.getCode()));
return dictData;
}
}

+ 31
- 65
tuoheng_oidc_admin/src/main/java/com/tuoheng/third/service/impl/ThirdServiceImpl.java View File

@@ -4,12 +4,17 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.common.CommonConfig;
import com.tuoheng.common.ServiceException;
import com.tuoheng.constant.*;
import com.tuoheng.constant.CommonConstant;
import com.tuoheng.constant.DictConstant;
import com.tuoheng.constant.DspConstant;
import com.tuoheng.enums.MarkTypeEnum;
import com.tuoheng.mapper.DictDataMapper;
import com.tuoheng.mapper.PlatformMapper;
import com.tuoheng.model.dto.ClientRoleListDto;
import com.tuoheng.model.dto.LoginUser;
import com.tuoheng.model.dto.Platform;
import com.tuoheng.model.dto.RoleDto;
import com.tuoheng.model.entity.DictData;
import com.tuoheng.third.request.ThirdRequest;
import com.tuoheng.third.service.ThirdService;
import com.tuoheng.third.vo.*;
@@ -36,6 +41,8 @@ public class ThirdServiceImpl implements ThirdService {
private PlatformMapper platformMapper;
@Autowired
private RestTemplate restTemplate;
@Autowired
private DictDataMapper dictDataMapper;

/**
* dsp -获取算法实例
@@ -138,41 +145,12 @@ public class ThirdServiceImpl implements ThirdService {
RoleMenuVo vo = new RoleMenuVo();
RoleMenuListVo roleMenuListVo = new RoleMenuListVo();
vo.setRoleId(request.getRoleId());

String url = "";

switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), HhzUrlConstant.FIND_MENU);
break;
//机场
case AirportConstant.AIRPORT_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), AirportConstant.FIND_MENU);
break;
//高速
case FreeWayConstant.FREEWAY_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), FreeWayConstant.FIND_MENU);
break;
//航道
case WaterWayConstant.WATERWAY_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), WaterWayConstant.FIND_MENU);
break;
//飞手
case PilotConstant.PILOT_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), PilotConstant.FIND_MENU);
break;
//水环境
case WeptspConstant.WEPTSP_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), WeptspConstant.FIND_MENU);
break;
//大气
case MonitorConstant.AIRMONITOR_CLIENT:
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), MonitorConstant.FIND_MENU);
break;
default:
break;
DictData dictData = getDictData(request.getClientId(), DictConstant.GET_MENU);
if (ObjectUtil.isNull(dictData)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "该业务平台对应字典表数据不存在");
}
url = String.format(Locale.ENGLISH, "%s%s", platform.getPlatformUrl(), dictData.getValue());
ParameterizedTypeReference<JsonResult<RoleMenuVo>> parameterizedTypeReference =
new ParameterizedTypeReference<JsonResult<RoleMenuVo>>() {
};
@@ -225,38 +203,11 @@ public class ThirdServiceImpl implements ThirdService {
clientRoleListDto.setClientId(platform.getPlatformCode());
String url = platform.getPlatformUrl();
//根据不同业务平台进行动态匹配 ->并修改对应标识权限
switch (platform.getPlatformCode()) {
//河湖长
case HhzUrlConstant.HHZ_CLIENT:
url = url + HhzUrlConstant.FIND_ROLE;
break;
//机场
case AirportConstant.AIRPORT_CLIENT:
url = url + AirportConstant.FIND_ROLE;
break;
//高速
case FreeWayConstant.FREEWAY_CLIENT:
url = url + FreeWayConstant.FIND_ROLE;
break;
//航道
case WaterWayConstant.WATERWAY_CLIENT:
url = url + WaterWayConstant.FIND_ROLE;
break;
//飞手
case PilotConstant.PILOT_CLIENT:
url = url + PilotConstant.FIND_ROLE;
break;
//水环境
case WeptspConstant.WEPTSP_CLIENT:
url = url + WeptspConstant.FIND_ROLE;
break;
//水环境
case MonitorConstant.AIRMONITOR_CLIENT:
url = url + MonitorConstant.FIND_ROLE;
break;
default:
break;
DictData dictData = getDictData(clientId, DictConstant.GET_ROLE);
if (ObjectUtil.isNull(dictData)) {
throw new ServiceException(HttpStatus.BAD_REQUEST.value(), "该业务平台对应字典表数据不存在");
}
url = url + dictData.getValue();
ParameterizedTypeReference<JsonResult<List<RoleDto>>> parameterizedTypeReference =
new ParameterizedTypeReference<JsonResult<List<RoleDto>>>() {
};
@@ -279,4 +230,19 @@ public class ThirdServiceImpl implements ThirdService {
return clientRoleListDto;

}

/**
* 获取字典表数据
*
* @param type
* @param dictCode
* @return
*/
private DictData getDictData(String type, String dictCode) {
DictData dictData = dictDataMapper.selectOne(Wrappers.<DictData>lambdaQuery()
.eq(DictData::getDictType, type)
.eq(DictData::getCode, dictCode)
.eq(DictData::getMark, MarkTypeEnum.VALID.getCode()));
return dictData;
}
}

+ 31
- 0
tuoheng_oidc_admin/src/main/resources/mapper/DictDataMapper.xml View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.DictDataMapper">

<resultMap id="BaseResultMap" type="com.tuoheng.model.entity.DictData">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="dictName" column="dict_name" jdbcType="VARCHAR"/>
<result property="dictType" column="dict_type" jdbcType="VARCHAR"/>
<result property="value" column="value" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/>
<result property="mark" column="mark" jdbcType="TINYINT"/>
<result property="sort" column="sort" jdbcType="INTEGER"/>
</resultMap>

<sql id="Base_Column_List">
id,dict_name,dict_type,
value,code,status,
create_user,create_time,update_user,
update_time,remark,tenant_id,
mark,sort
</sql>
</mapper>

+ 26
- 0
tuoheng_oidc_admin/src/main/resources/mapper/DictMapper.xml View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tuoheng.mapper.DictMapper">

<resultMap id="BaseResultMap" type="com.tuoheng.model.entity.Dict">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="dictName" column="dict_name" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="createUser" column="create_user" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="mark" column="mark" jdbcType="TINYINT"/>
</resultMap>

<sql id="Base_Column_List">
id,dict_name,type,
status,create_user,create_time,
update_user,update_time,remark,
mark
</sql>
</mapper>

BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/TenantServiceImpl.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl$1.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl$2.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl$3.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/third/service/impl/ThirdServiceImpl.class View File


Loading…
Cancel
Save