|
@@ -1,15 +1,23 @@
|
|
|
package com.ims.eval.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.ims.common.utils.StringUtils;
|
|
|
+import com.ims.eval.config.ImaConfig;
|
|
|
import com.ims.eval.entity.Myuser;
|
|
|
import com.ims.eval.dao.UserMapper;
|
|
|
import com.ims.eval.feign.RemoteServiceBuilder;
|
|
|
import com.ims.eval.service.IUserService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -22,13 +30,21 @@ import java.util.List;
|
|
|
* @since 2023-03-03
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class UserServiceImpl extends ServiceImpl<UserMapper, Myuser> implements IUserService {
|
|
|
|
|
|
+
|
|
|
@Autowired
|
|
|
private RemoteServiceBuilder remoteServiceBuilder;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ImaConfig imaConfig;
|
|
|
+
|
|
|
@Override
|
|
|
- public List<Myuser> listAll(String id, String orgId,String unitId) {
|
|
|
+ public List<Myuser> listAll(String id, String orgId, String unitId) {
|
|
|
|
|
|
QueryWrapper<Myuser> qw = new QueryWrapper<>();
|
|
|
|
|
@@ -52,9 +68,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, Myuser> implements
|
|
|
@Override
|
|
|
public Myuser getUser(String username) {
|
|
|
QueryWrapper<Myuser> qw = new QueryWrapper<>();
|
|
|
- qw.lambda().eq(Myuser::getLoginName,username);
|
|
|
+ qw.lambda().eq(Myuser::getLoginName, username);
|
|
|
List<Myuser> list = baseMapper.selectList(qw);
|
|
|
- if(list.size()<=0){
|
|
|
+ if (list.size() <= 0) {
|
|
|
return null;
|
|
|
}
|
|
|
return list.get(0);
|
|
@@ -76,4 +92,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, Myuser> implements
|
|
|
JSONObject json = remoteServiceBuilder.getGatewayUrl().getCodeByToken(token);
|
|
|
return json;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject getbladeAuth(String tenantId, String username, String password, String grantType, String scope, String type) {
|
|
|
+ MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
|
|
+ headers.add("Authorization", "Basic c2FiZXI6NWMwMmMzZDViNzYxNTNkZGM5ZTczYzc5YzMzNzYzODAxNmE5ZDM2Ng==");
|
|
|
+ headers.add("Tenant-Id", "000000");
|
|
|
+ HttpEntity<LinkedMultiValueMap<String, Object>> param = new HttpEntity<>(null, headers);
|
|
|
+
|
|
|
+ ResponseEntity<String> responseEntity2 = restTemplate.postForEntity(imaConfig.getGatewayUrl() + "blade-auth/oauth/token?tenantId={1}&username={2}&password={3}&grant_type={4}&scope={5}&type={6}",
|
|
|
+ param, String.class, tenantId, username, password, grantType, scope, type);
|
|
|
+ log.info("\n code:{}\n header:{}\n body:{}\n", responseEntity2.getStatusCodeValue(), responseEntity2.getHeaders(), responseEntity2.getBody());
|
|
|
+ if(200== responseEntity2.getStatusCodeValue()){
|
|
|
+ return JSON.parseObject(responseEntity2.getBody());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|