|
|
|
@ -5,15 +5,25 @@ import cn.chjyj.szwh.mapper.UserMapper; |
|
|
|
import cn.chjyj.szwh.service.UserService; |
|
|
|
import cn.chjyj.szwh.utils.ProperUtils; |
|
|
|
import cn.chjyj.szwh.utils.RequestUtils; |
|
|
|
import cn.chjyj.szwh.utils.SignUtils; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class UserServiceImpl implements UserService { |
|
|
|
/** |
|
|
|
* 日志 |
|
|
|
*/ |
|
|
|
private static Log log = LogFactory.getLog(UserServiceImpl.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserMapper userMapper; |
|
|
|
|
|
|
|
@ -35,20 +45,31 @@ public class UserServiceImpl implements UserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 远程获取用户信息 |
|
|
|
* @param userIsli |
|
|
|
* @param userIsli 用户 |
|
|
|
* @param token 用户请求凭据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public User getApiUser(String userIsli) { |
|
|
|
public User getApiUser(String userIsli,String token) { |
|
|
|
String userHost= ProperUtils.getSzwhProp("REAL_URL");//用户主机
|
|
|
|
if(StringUtils.isEmpty(userHost)){ |
|
|
|
userHost=""; |
|
|
|
} |
|
|
|
// 远程获取用户的信息
|
|
|
|
String userUrl=userHost+"/slb/usermgt/v1/user-info/"+userIsli; |
|
|
|
String token = "fdasfasd";//请求凭据;
|
|
|
|
// 执行请求操作
|
|
|
|
JSONObject json = RequestUtils.doGetUrlData(userHost,"api_token",token); |
|
|
|
log.info("rquest url:"+userUrl); |
|
|
|
// 创建签名
|
|
|
|
String sign= SignUtils.createSign("user_real"); |
|
|
|
log.info("user token:"+sign); |
|
|
|
// 请求头
|
|
|
|
Map<String,Object> hmap =new HashMap(); |
|
|
|
hmap.put("token",sign); |
|
|
|
hmap.put("Content-Type","application/json"); |
|
|
|
|
|
|
|
//执行请求
|
|
|
|
JSONObject json = RequestUtils.GetData(userUrl,hmap); |
|
|
|
log.info("request result:"+json.toString()); |
|
|
|
|
|
|
|
// 解析出用户
|
|
|
|
User user = new User(); |
|
|
|
user.setLegalsName(json.getString("leagal_name")); |
|
|
|
|