Browse Source

Merge remote-tracking branch 'origin/dev' into dev

tags/24080901
PoffyZhang 3 months ago
parent
commit
2c5ccb7bbf
8 changed files with 61 additions and 14 deletions
  1. +20
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java
  2. +3
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java
  3. +9
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java
  4. +3
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingNotifyHelper.java
  5. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/sms/constant/VoiceSmsTemplateConst.java
  6. +20
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/user/security/config/WebSecurityConfig.java
  7. +1
    -1
      hz-pm-api/src/main/resources/application-dev.yml
  8. +4
    -2
      hz-pm-api/src/main/resources/application-prod.yml

+ 20
- 6
hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java View File

@@ -1,5 +1,6 @@
package com.hz.pm.api.external;

import cn.hutool.http.useragent.UserAgentUtil;
import com.hz.pm.api.meeting.entity.config.WebProps;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.file.entity.File;
@@ -10,6 +11,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
@@ -26,8 +28,11 @@ public class FilePreviewClient {

private static final Logger log = LoggerFactory.getLogger(FilePreviewClient.class);

@Value("${mh.file-preview.host}")
private String mhFilePreviewUrl;
@Value("${mh.file-preview.public-host:}")
private String mhFilePreviewPublicUrl;

@Value("${mh.file-preview.private-host:}")
private String mhFilePreviewPrivateUrl;

private final FileService fileService;

@@ -37,10 +42,19 @@ public class FilePreviewClient {

private static final String PREVIEW_PATH_FMT = "%s/public/risen/core/resrc/view/pdf_view.html.do?strMap.remote_url=%s&strMap.ext=%s";

public String getFilePreviewUrl(Long fileId) {
String fileDownUrl = WebProps.apiUrl + FILE_DOWN_NO_AUTH_URL + fileId;
File file = fileService.getById(fileId);
return String.format(PREVIEW_PATH_FMT, mhFilePreviewUrl, fileDownUrl, file.getSuffix());
public String getFilePreviewUrl(Long fileId, HttpServletRequest request) {
String serverName = request.getServerName();
log.info("serverName:{}", serverName);
if (serverName.contains("weixin") || serverName.contains("10.54.38.13")) {
// 浙政钉访问需要转换为互联网可访问的地址
String fileDownUrl = WebProps.zzdApiUrl + FILE_DOWN_NO_AUTH_URL + fileId;
File file = fileService.getById(fileId);
return String.format(PREVIEW_PATH_FMT, mhFilePreviewPublicUrl, fileDownUrl, file.getSuffix());
} else {
String fileDownUrl = WebProps.apiUrl + FILE_DOWN_NO_AUTH_URL + fileId;
File file = fileService.getById(fileId);
return String.format(PREVIEW_PATH_FMT, mhFilePreviewPrivateUrl, fileDownUrl, file.getSuffix());
}
}

public void downloadFile(Long fileId, HttpServletResponse response) {


+ 3
- 2
hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java View File

@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
@@ -29,8 +30,8 @@ public class FilePreviewController {

@ApiOperation("获取文件的预览地址")
@GetMapping("/getFilePreviewUrl/{fileId}")
public String getFilePreviewUrl(@PathVariable Long fileId) {
return filePreviewClient.getFilePreviewUrl(fileId);
public String getFilePreviewUrl(@PathVariable Long fileId, HttpServletRequest request) {
return filePreviewClient.getFilePreviewUrl(fileId, request);
}

@ApiOperation("文件下载(不鉴权)")


+ 9
- 0
hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java View File

@@ -20,6 +20,10 @@ public class WebProps {

public static String apiUrl;

public static String zzdApiUrl;



@Value("${web.login.url:}")
private void setLoginUrl(String url) {
loginUrl = url;
@@ -30,4 +34,9 @@ public class WebProps {
apiUrl = url;
}

@Value("${web.zzd-api.url:}")
private void setZzdApiUrl(String url) {
zzdApiUrl = url;
}

}

+ 3
- 1
hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingNotifyHelper.java View File

@@ -193,7 +193,9 @@ public class MeetingNotifyHelper {
private void smsExperts(Meeting meeting, List<MeetingExpert> experts) {
String content = String.format(VoiceSmsTemplateConst.EXPERT_INVITE_SMS,
meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()),
meeting.getMeetingAddress());
meeting.getMeetingAddress(),
meeting.getConnecter(),
meeting.getContact());
Set<String> phones = CollUtils.fieldSet(experts, MeetingExpert::getMobile);
String submitKey;
if (environmentUtil.isDevEnv() && Boolean.TRUE.equals(inviteSkipSendSms)) {


+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/sms/constant/VoiceSmsTemplateConst.java View File

@@ -28,6 +28,6 @@ public class VoiceSmsTemplateConst {
*/
public static final String EXPERT_INVITE_CALL = "尊敬的专家您好,%s现邀请您作为专家参加%s会议,会议时间:%s,会议地点:%s。 确认参加请按 1,拒绝参加请按 2,重听请按星号键。请您选择";

public static final String EXPERT_INVITE_SMS = "【杭州数字信创】尊敬的专家您好,%s现邀请您作为专家参加%s会议,会议时间:%s,会议地点:%s。 确认参加请回复 1,拒绝参加请回复 2。请您选择";
public static final String EXPERT_INVITE_SMS = "【杭州数字信创】尊敬的专家您好,%s现邀请您作为专家参加%s会议,会议时间:%s,会议地点:%s。 确认参加请回复 1,拒绝参加请回复 2。如有疑问请联系:%s(%s)。";

}

+ 20
- 1
hz-pm-api/src/main/java/com/hz/pm/api/user/security/config/WebSecurityConfig.java View File

@@ -1,17 +1,23 @@
package com.hz.pm.api.user.security.config;

import com.hz.pm.api.common.model.constant.BizConst;
import com.hz.pm.api.common.model.constant.CommonConst;
import com.hz.pm.api.user.security.auth.code.AuthCodeLoginSecurityConfig;
import com.hz.pm.api.user.security.auth.credential.CredentialAuthSecurityConfig;
import com.hz.pm.api.user.security.handler.DefaultExpiredSessionStrategy;
import com.hz.pm.api.user.security.handler.DefaultLogoutSuccessHandler;
import com.hz.pm.api.user.security.auth.mh.MhAuthSecurityConfig;
import com.ningdatech.basic.util.NdJsonUtil;
import com.ningdatech.basic.util.StrPool;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;

import java.io.PrintWriter;
import java.util.Map;
import java.util.Set;

@@ -38,7 +44,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
assemblerPreAuthUrls(http);
http.formLogin()
.loginPage(authProperties.getAuthRequireUrl())
.and()
.exceptionHandling()
.authenticationEntryPoint(authenticationEntryPoint())
.and().apply(credentialAuthSecurityConfig)
.and().apply(authCodeLoginSecurityConfig)
.and().apply(mhAuthSecurityConfig)
@@ -68,6 +76,17 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.ignoringAntMatchers(authProperties.getIgnoreCsrfUrlsArray());
}

private AuthenticationEntryPoint authenticationEntryPoint() {
return (request, response, authException) -> {
response.setContentType(StrPool.CONTENT_TYPE);
response.setStatus(HttpStatus.UNAUTHORIZED.value());
PrintWriter writer = response.getWriter();
writer.write(NdJsonUtil.getInstance().writeValueAsString(BizConst.UNAUTHENTICATED));
writer.flush();
writer.close();
};
}

private void assemblerPreAuthUrls(HttpSecurity http) throws Exception {
Map<String, String[]> roleArrayMap = authProperties.getRoleArrayMap();
Set<String> roleSet = roleArrayMap.keySet();


+ 1
- 1
hz-pm-api/src/main/resources/application-dev.yml View File

@@ -189,7 +189,7 @@ mh:
detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList
upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin
file-preview:
host: http://ztzz2.hzswb.cn/yl
public-host: http://ztzz2.hzswb.cn/yl

auth-code:
secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2


+ 4
- 2
hz-pm-api/src/main/resources/application-prod.yml View File

@@ -182,6 +182,8 @@ web:
url: https://hzszxc.hzswb.cn:8443/project
api:
url: https://hzszxc.hzswb.cn:8443/hzpm
zzd-api:
url: https://weixin.hzszxc.hzswb.cn:8143/hzpm

mh:
sso:
@@ -199,8 +201,8 @@ mh:
purchase-notice:
open: true
file-preview:
# host: http://ztzz2.hzswb.cn/yl
host: http://172.18.43.208/yl
public-host: http://ztzz2.hzswb.cn/yl
private-host: http://172.18.43.208/yl

sms-send:
host: http://10.54.38.13:8081/mh-gateway/auth-single


Loading…
Cancel
Save