@@ -0,0 +1,41 @@ | |||
package com.tuoheng.controller; | |||
import com.tuoheng.model.dto.LoginUser; | |||
import com.tuoheng.model.param.CreateClientTenantDto; | |||
import com.tuoheng.model.param.GetClientTenantRoleDto; | |||
import com.tuoheng.service.ClientSevice; | |||
import com.tuoheng.service.ClientUserSevice; | |||
import com.tuoheng.service.CurrentUser; | |||
import com.tuoheng.until.JsonResult; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* @author chenjiandong | |||
* @description: TODO | |||
* @date 2022/12/7 16:17 | |||
*/ | |||
@RestController | |||
@RequestMapping("/client") | |||
@Slf4j | |||
public class ClientController { | |||
@Autowired | |||
private ClientSevice clientSevice; | |||
@PostMapping("/getAllClient") | |||
public JsonResult getAllClient(@CurrentUser LoginUser loginUser){ | |||
return clientSevice.getAllClient(); | |||
} | |||
@PostMapping("/getClientTenantRole") | |||
public JsonResult getClientTenantRole(@RequestBody GetClientTenantRoleDto getClientTenantRoleDto, | |||
@CurrentUser LoginUser loginUser){ | |||
return clientSevice.getClientTenantRole(getClientTenantRoleDto); | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package com.tuoheng.mapper; | |||
import com.tuoheng.model.dto.ClientDto; | |||
import com.tuoheng.model.po.UserPo; | |||
import org.apache.ibatis.annotations.Mapper; | |||
import java.util.List; | |||
/** | |||
* @author chenjiandong | |||
* @description: TODO | |||
* @date 2022/10/8 11:59 | |||
*/ | |||
@Mapper | |||
public interface ClientMapper { | |||
List<ClientDto> getAllClient(); | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.model.dto; | |||
import lombok.Data; | |||
/** | |||
* @author chenjiandong | |||
* @description: TODO | |||
* @date 2022/12/12 9:16 | |||
*/ | |||
@Data | |||
public class ClientDto { | |||
private String clientId; | |||
private String clientName; | |||
} |
@@ -0,0 +1,19 @@ | |||
package com.tuoheng.model.dto; | |||
import lombok.Data; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* @author chenjiandong | |||
* @description: TODO | |||
* @date 2022/12/12 10:01 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
public class ClientRoleInfoDto { | |||
private Integer roleId; | |||
private String roleName; | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.model.param; | |||
import lombok.Data; | |||
/** | |||
* @author chenjiandong | |||
* @description: TODO | |||
* @date 2022/12/12 9:53 | |||
*/ | |||
@Data | |||
public class GetClientTenantRoleDto { | |||
private String clientId; | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.service; | |||
import com.tuoheng.model.param.GetClientTenantRoleDto; | |||
import com.tuoheng.until.JsonResult; | |||
/** | |||
* @author chenjiandong | |||
* @description: TODO | |||
* @date 2022/10/8 11:35 | |||
*/ | |||
public interface ClientSevice { | |||
JsonResult getAllClient(); | |||
JsonResult getClientTenantRole(GetClientTenantRoleDto getClientTenantRoleDto); | |||
} |
@@ -0,0 +1,45 @@ | |||
package com.tuoheng.service.impl; | |||
import com.tuoheng.mapper.ClientMapper; | |||
import com.tuoheng.model.dto.ClientRoleInfoDto; | |||
import com.tuoheng.model.param.ClientRoleDto; | |||
import com.tuoheng.model.param.GetClientTenantRoleDto; | |||
import com.tuoheng.service.ClientSevice; | |||
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.ArrayList; | |||
import java.util.List; | |||
/** | |||
* @author chenjiandong | |||
* @description: TODO | |||
* @date 2022/10/8 11:35 | |||
*/ | |||
@Service | |||
public class ClientServiceImpl implements ClientSevice { | |||
@Autowired | |||
private ClientMapper clientMapper; | |||
@Override | |||
@Transactional(readOnly = true) | |||
public JsonResult getAllClient(){ | |||
return JsonResult.success(clientMapper.getAllClient()); | |||
} | |||
@Override | |||
@Transactional(readOnly = true) | |||
public JsonResult getClientTenantRole(GetClientTenantRoleDto getClientTenantRoleDto){ | |||
List<ClientRoleInfoDto> clientRoleInfoDtos = new ArrayList<>(); | |||
ClientRoleInfoDto clientRoleInfoDto = new ClientRoleInfoDto() | |||
.setRoleId(1).setRoleName("租户管理员角色"); | |||
clientRoleInfoDtos.add(clientRoleInfoDto); | |||
//todo:根据不同的 client 调用不同系统的接口,获取租户所对应的角色 | |||
return JsonResult.success(clientRoleInfoDtos); | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
<?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.ClientMapper"> | |||
<select id="getAllClient" resultType="com.tuoheng.model.dto.ClientDto"> | |||
select client_id as clientId, client_name as clientName from oauth2_registered_client | |||
</select> | |||
</mapper> |