|
@@ -7,12 +7,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dragoninfo.dcuc.common.entity.ApiResult;
|
|
|
import com.dragoninfo.dcuc.common.entity.ApiResultPage;
|
|
|
import com.dragoninfo.dcuc.common.entity.ApiSearchReq;
|
|
|
+import com.dragoninfo.dcuc.common.entity.SearchParam;
|
|
|
import com.dragoninfo.dcuc.common.utils.ResponseUtil;
|
|
|
import com.dragonsoft.dcuc.approve.business.external.IDcucBusiness;
|
|
|
import com.dragonsoft.dcuc.approve.constants.ApproveBeanConstants;
|
|
|
import com.dragonsoft.dcuc.approve.model.vo.dcuc.ApiOrgResultVo;
|
|
|
import com.dragonsoft.dcuc.approve.model.vo.dcuc.ApiPoliceResultVo;
|
|
|
import com.dragonsoft.dcuc.approve.model.vo.dcuc.OauthUserVO;
|
|
|
+import com.dragonsoft.dcuc.approve.model.vo.dcuc.UserLabel2RespVO;
|
|
|
import com.dragonsoft.dcuc.approve.properties.ApproveProperties;
|
|
|
import com.dragonsoft.dcuc.approve.utils.ProofsUtil;
|
|
|
import com.dragonsoft.duceap.base.entity.http.ResponseDTO;
|
|
@@ -20,6 +22,7 @@ import com.dragonsoft.duceap.base.entity.http.ResponseStatus;
|
|
|
import com.dragonsoft.duceap.base.entity.security.SecurityUser;
|
|
|
import com.dragonsoft.duceap.base.utils.UserContextUtils;
|
|
|
import com.dragonsoft.duceap.commons.util.json.JsonUtils;
|
|
|
+import com.dragonsoft.duceap.core.search.enums.SearchOperator;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@@ -29,18 +32,21 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.http.*;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.net.URI;
|
|
|
import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
- * @author lidr
|
|
|
+ * @author lidr huangziquan
|
|
|
* @date 2021/2/23
|
|
|
*/
|
|
|
-@Service
|
|
|
+@Component
|
|
|
public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DcucBusinessImpl.class);
|
|
|
|
|
@@ -61,6 +67,11 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
*/
|
|
|
public static final String POLICE_DETAIL_API = "/api/user-service/v3/users/police/%s";
|
|
|
|
|
|
+
|
|
|
+ * 用户标签查询
|
|
|
+ */
|
|
|
+ public static final String LABEL_USER_API = "/api/user-service/v1/users/label/search";
|
|
|
+
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
private ApproveProperties approveProperties;
|
|
@@ -228,6 +239,71 @@ public class DcucBusinessImpl implements IDcucBusiness {
|
|
|
return oauthUserVO;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<UserLabel2RespVO> getUserByLabelCode(String orgCode, String labelCode) {
|
|
|
+ SearchParam labelSearchParam = new SearchParam();
|
|
|
+ labelSearchParam.setOperator(SearchOperator.eq.name());
|
|
|
+ labelSearchParam.setValue(labelCode);
|
|
|
+
|
|
|
+ SearchParam orgCodeSearchParam = new SearchParam();
|
|
|
+ orgCodeSearchParam.setOperator(SearchOperator.eq.name());
|
|
|
+ orgCodeSearchParam.setValue(orgCode);
|
|
|
+
|
|
|
+ Map<String, SearchParam> filters = new HashMap<>(2);
|
|
|
+ filters.put("orgCode", orgCodeSearchParam);
|
|
|
+ filters.put("labelCode", labelSearchParam);
|
|
|
+
|
|
|
+ ApiSearchReq apiSearchReq = ApiSearchReq.reqInfo(1, 1000, filters);
|
|
|
+
|
|
|
+ ApiResultPage<UserLabel2RespVO> page = labelPage(apiSearchReq);
|
|
|
+ Long total = page.getTotal();
|
|
|
+ List<UserLabel2RespVO> content = page.getContent();
|
|
|
+
|
|
|
+ return content;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows(JsonProcessingException.class)
|
|
|
+ public ApiResultPage<UserLabel2RespVO> labelPage(ApiSearchReq apiSearchReq) {
|
|
|
+ Assert.notNull(apiSearchReq);
|
|
|
+ String requestName = "获取人员标签列表";
|
|
|
+
|
|
|
+ String userServiceUrl = approveProperties.getUserServiceUrl();
|
|
|
+ String url = userServiceUrl + LABEL_USER_API;
|
|
|
+
|
|
|
+ HttpHeaders httpHeaders = HttpHeaders.EMPTY;
|
|
|
+ SecurityUser currentUser = UserContextUtils.getCurrentUser();
|
|
|
+ if (ObjectUtil.isNotNull(currentUser)) {
|
|
|
+ httpHeaders = ProofsUtil.buildHttpHeaders(currentUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ RequestEntity<ApiSearchReq> apiSearchReqRequestEntity = new RequestEntity<>(apiSearchReq, httpHeaders, HttpMethod.POST, URI.create(url));
|
|
|
+ logger.info(requestName + "参数:{}", JsonUtils.toJSONString(apiSearchReqRequestEntity));
|
|
|
+ ResponseEntity<String> resEntity = restTemplate.exchange(apiSearchReqRequestEntity, String.class);
|
|
|
+ String jsonString = JsonUtils.toJSONString(resEntity);
|
|
|
+ logger.info(requestName + "返回参数:{}", jsonString);
|
|
|
+ if (!resEntity.getStatusCode().is2xxSuccessful()) {
|
|
|
+ logger.error(requestName + "信息错误:{}", jsonString);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String body = resEntity.getBody();
|
|
|
+ ApiResult apiResult = JSONObject.parseObject(body, ApiResult.class);
|
|
|
+ if (ObjectUtil.isNull(apiResult)) {
|
|
|
+ logger.error(requestName + "信息错误:{}", body);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (!apiResult.getStatusCode().equalsIgnoreCase(ResponseStatus.SUCCESS_CODE)) {
|
|
|
+ logger.error(requestName + "信息错误:{}", body);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Object result = apiResult.getResult();
|
|
|
+ String resultJson = objectMapper.writeValueAsString(result);
|
|
|
+ TypeReference<ApiResultPage<UserLabel2RespVO>> typeReference = new TypeReference<ApiResultPage<UserLabel2RespVO>>() {
|
|
|
+ };
|
|
|
+ return objectMapper.readValue(resultJson, typeReference);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@SneakyThrows(JsonProcessingException.class)
|
|
|
public ApiResultPage<ApiPoliceResultVo> policePage(ApiSearchReq apiSearchReq) {
|