Browse Source

查看头像

tags/24080901
PoffyZhang 1 year ago
parent
commit
64c9ea149b
3 changed files with 65 additions and 2 deletions
  1. +20
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java
  2. +44
    -0
      pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java
  3. +1
    -1
      pmapi/src/test/resources/application.yml

+ 20
- 1
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.common.constant.RegionConst;
import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
@@ -31,6 +32,8 @@ import com.ningdatech.pmapi.user.model.vo.UserRoleVO;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import com.ningdatech.zwdd.ZwddIntegrationProperties;
import com.ningdatech.zwdd.client.ZwddClient;
import com.wflow.workflow.bean.dto.ProcessInstanceUserDto;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@@ -57,6 +60,10 @@ public class UserInfoManage {
private final UserInfoHelper userInfoHelper;
private final RegionCacheHelper regionCacheHelper;

private final ZwddIntegrationProperties zwddIntegrationProperties;

private final ZwddClient zwddClient;

public PageVo<ResUserInfoListVO> list(ReqUserInfoListPO req) {
PageVo<ResUserInfoListVO> pageVo = new PageVo<>();

@@ -409,7 +416,7 @@ public class UserInfoManage {
resUserDetailVO.setPhoneNo(userInfo.getMobile());
resUserDetailVO.setStatus(userInfo.getAvailable());
resUserDetailVO.setEmployeeCode(userInfo.getEmployeeCode());
resUserDetailVO.setAvatar(userInfo.getAvatar());
resUserDetailVO.setAvatar(makeAvatar(userInfo.getAvatar()));

// 装配用户角色信息列表
List<UserRole> userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class)
@@ -440,6 +447,18 @@ public class UserInfoManage {
return resUserDetailVO;
}

//生成头像 链接
private String makeAvatar(String avatar) {
try{
GenericResult<String> accessToken = zwddClient.getAccessToken();
String token = accessToken.getData();
String res = "https://" + zwddIntegrationProperties.getDomain() + "/media/download?" +
"access_token=" + token + "&media_id=" + avatar;
return res;
}catch (Exception e){}
return org.apache.commons.lang3.StringUtils.EMPTY;
}

public Map<String, ProcessInstanceUserDto> getUserMapByIds(Set<String> staterUsers) {
List<UserInfo> userInfos = iUserInfoService.listByIds(staterUsers);
return userInfos.stream().map(u -> {


+ 44
- 0
pmapi/src/test/java/com/ningdatech/pmapi/irs/IrsTest.java View File

@@ -136,6 +136,50 @@ public class IrsTest extends AppTests {
}
}

@Test
public void test5(){
CloseableHttpResponse response = null;
try {
String api = "/media/download";
GetClient getClient = getZwddExecutableClient().newGetClient(api);
//设置参数
getClient.addParameter("access_token", zwddClient.getAccessToken().getData());
getClient.addParameter("media_id", "$hQHNxoECo2pwZwMGDAEN2gAsOEkvNENaMmZ5UUVncDduWERralJxRW5aem45ODN5UHpKRjErcUxFeUkvTT0");
//调用API
//String result = getClient.get();
//System.err.println(result);
response = getClient.getB();
org.apache.http.HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
System.out.println(is);
File voice = new File("C:\\Users\\PoffyZhang\\Desktop\\log1.jpg");
OutputStream fos = new FileOutputStream(voice);
int cache = 10 * 1024;
byte[] buffer = new byte[cache];
int ch = 0;
StringBuffer sb = new StringBuffer();
while ((ch = is.read(buffer)) != -1) {
fos.write(buffer, 0, ch);
sb.append(buffer);
}
System.out.println(sb.toString());
is.close();
fos.flush();
fos.close();
} catch (Exception e) {
System.out.println(e);
}finally {
if (response != null) {
try {
//特别提醒:需要调用response的close方法关闭网络连接!!!
response.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
}

private static ExecutableClient zwddExecutableClient;
@Autowired
private ZwddIntegrationProperties zwddProperties;


+ 1
- 1
pmapi/src/test/resources/application.yml View File

@@ -1,3 +1,3 @@
spring:
profiles:
active: prod
active: dev

Loading…
Cancel
Save