|
@@ -0,0 +1,47 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.ReflectUtil;
|
|
|
+import com.diagbot.util.RespDTOUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description: 通用方法
|
|
|
+ * @author: zhoutg
|
|
|
+ * @time: 2021/6/3 18:56
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class UserClientFacade {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserServiceClient userServiceClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置操作人姓名
|
|
|
+ *
|
|
|
+ * @param tList
|
|
|
+ * @param <T>
|
|
|
+ */
|
|
|
+ public <T> void setUserName(List<T> tList) {
|
|
|
+ if (ListUtil.isEmpty(tList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> userIdList = ReflectUtil.getPropertyList(tList, "modifier");
|
|
|
+ if (ListUtil.isNotEmpty(userIdList)) {
|
|
|
+ userIdList = userIdList.stream().distinct().collect(Collectors.toList());
|
|
|
+ RespDTO<Map<String, String>> mapRespDTO = userServiceClient.getUserInfoByIds(userIdList);
|
|
|
+ RespDTOUtil.respNGDealCover(mapRespDTO, "获取操作人失败");
|
|
|
+ Map<String, String> data = mapRespDTO.data;
|
|
|
+ for (T t : tList) {
|
|
|
+ ReflectUtil.setFieldValue(t, "modifier", data.get(ReflectUtil.getProperty(t, "modifier")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|