|
@@ -1,21 +1,79 @@
|
|
|
package com.xzl.web.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.xzl.common.core.domain.entity.SysDictData;
|
|
|
+import com.xzl.common.core.domain.model.LoginBody;
|
|
|
+import com.xzl.system.service.ISysDictDataService;
|
|
|
import com.xzl.web.mapper.UserPortraitMapper;
|
|
|
import com.xzl.web.service.UserPortraitService;
|
|
|
+import com.xzl.web.utils.RequestUtils;
|
|
|
+import io.netty.handler.codec.json.JsonObjectDecoder;
|
|
|
+import org.apache.commons.collections.MapUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.yaml.snakeyaml.util.UriEncoder;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
public class UserPortraitServiceImpl implements UserPortraitService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserPortraitMapper userPortraitMapper;
|
|
|
+ @Autowired
|
|
|
+ private UserPortraitMapper userPortraitMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDictDataService dictDataService;
|
|
|
|
|
|
- @Override
|
|
|
- public List<String> getWordCloudInfo() {
|
|
|
- return userPortraitMapper.getWordCloudInfo();
|
|
|
+ @Override
|
|
|
+ public List<String> getWordCloudInfo() {
|
|
|
+ return userPortraitMapper.getWordCloudInfo();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public String loginNLP(LoginBody loginBody) {
|
|
|
+ String username = loginBody.getUsername();
|
|
|
+ String password = loginBody.getPassword();
|
|
|
+
|
|
|
+ // 取npl默认用户
|
|
|
+ SysDictData dictParam = new SysDictData();
|
|
|
+ dictParam.setDictType("nlp_default");
|
|
|
+ List<SysDictData> sysDictDataList = dictDataService.selectDictDataList(dictParam);
|
|
|
+ if (sysDictDataList != null && sysDictDataList.size() > 0) {
|
|
|
+ SysDictData sysDictData = sysDictDataList.get(0);
|
|
|
+ if ("1".equals(sysDictData.getDictValue())) {
|
|
|
+ username = "data1";
|
|
|
+ password = "617218bb2a6568ce";
|
|
|
+ }
|
|
|
+ }
|
|
|
+/*
|
|
|
+// String username = "data1";
|
|
|
+// String password = "Abc@1234";
|
|
|
+ // 密码加密
|
|
|
+ password = "617218bb2a6568ce";
|
|
|
+ */
|
|
|
+ // 调用登录
|
|
|
+ Map loginForm = new HashMap();
|
|
|
+ loginForm.put("username", username);
|
|
|
+ loginForm.put("password", password);
|
|
|
+ loginForm.put("userAgent", 1);
|
|
|
+ loginForm.put("client", "zdwxxtyc");
|
|
|
+ loginForm.put("saveUsername", true);
|
|
|
+ JSONObject json = RequestUtils.httpRequest2("http://10.70.192.135:8000/api/v2/auth/login/", "post", JSON.toJSONString(loginForm), null);
|
|
|
+ if ("SUCCESS".equals(MapUtils.getString(json, "status"))) {
|
|
|
+ JSONObject data = json.getJSONObject("data");
|
|
|
+ Map rs = new HashMap();
|
|
|
+ rs.put("uid", data.getString("uid"));
|
|
|
+ rs.put("nickname", data.getString("nickname"));
|
|
|
+ rs.put("status", data.getIntValue("status"));
|
|
|
+ rs.put("token", data.getString("token"));
|
|
|
+ rs.put("role", data.getIntValue("role"));
|
|
|
+ rs.put("language", "zh-CN");
|
|
|
+ rs.put("tier", 1);
|
|
|
+ return JSON.toJSONString(rs);
|
|
|
}
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|