Browse Source

增加专家报名临时链接生成接口及重定向接口

master
WendyYang 1 year ago
parent
commit
52e616e658
9 changed files with 92 additions and 3 deletions
  1. +21
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java
  2. +52
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java
  3. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/config/WebProperties.java
  4. +2
    -0
      pmapi/src/main/resources/application-dev.yml
  5. +2
    -0
      pmapi/src/main/resources/application-pre.yml
  6. +2
    -0
      pmapi/src/main/resources/application-prod.yml
  7. +2
    -0
      pmapi/src/main/resources/security/auth-dev.yml
  8. +2
    -0
      pmapi/src/main/resources/security/auth-pre.yml
  9. +2
    -0
      pmapi/src/main/resources/security/auth-prod.yml

+ 21
- 1
pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java View File

@@ -18,9 +18,12 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.IOException;

/**
* <p>
@@ -32,13 +35,30 @@ import javax.validation.constraints.NotNull;
*/
@RestController
@Api(tags = "专家管理相关接口")
@RequestMapping("/api/v1/expert")
@RequestMapping(value = {"/api/v1/expert", "/expert"})
@RequiredArgsConstructor
public class ExpertController {

private final ExpertManage expertManage;
private final ExpertAdminManage expertAdminManage;

/**
* 生成专家报名临时地址
*
* @return 生成专家报名临时地址
*/
@GetMapping("/getRegistrationUrl")
public String getRegistrationUrl() {
return expertManage.getRegistrationUrl();
}

@ApiIgnore
@GetMapping("/ephemeral/{uniqueId}/registration")
public void getRegistrationUrl(@PathVariable String uniqueId, HttpServletResponse response) throws IOException {
expertManage.redirectToRegistrationUrl(uniqueId, response);
}


@PostMapping("/registration")
@ApiOperation("社会专家报名")
@WebLog("社会专家报名")


+ 52
- 2
pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java View File

@@ -1,11 +1,15 @@
package com.ningdatech.pmapi.expert.manage;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.cache.model.cache.CacheKey;
import com.ningdatech.cache.repository.CachePlusOps;
import com.ningdatech.file.entity.vo.result.AttachFileVo;
import com.ningdatech.file.service.FileService;
import com.ningdatech.pmapi.common.model.FileBasicInfo;
import com.ningdatech.pmapi.common.util.BizUtils;
import com.ningdatech.pmapi.expert.assembler.ExpertInfoCmdAssembler;
import com.ningdatech.pmapi.expert.assembler.ExpertUserInfoAssembler;
import com.ningdatech.pmapi.expert.constant.ExpertAccountStatusEnum;
@@ -23,6 +27,7 @@ import com.ningdatech.pmapi.expert.model.req.ExpertUserBasicInfoSubmitRequest;
import com.ningdatech.pmapi.expert.model.vo.ExpertFullInfoVO;
import com.ningdatech.pmapi.expert.service.ExpertInfoService;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meeting.entity.config.WebProperties;
import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum;
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo;
import com.ningdatech.pmapi.sms.constant.VerificationCodeType;
@@ -37,10 +42,16 @@ import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@@ -51,7 +62,7 @@ import java.util.stream.Collectors;
* @author liuxinxin
* @date 2023/2/23 上午8:55
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class ExpertManage {
@@ -67,6 +78,44 @@ public class ExpertManage {
private final IUserRoleService iUserRoleService;
private final IRoleService iRoleService;
private final VerifyCodeCheckHelper verifyCodeCheckHelper;
private final CachePlusOps cachePlusOps;

private static final Duration REGISTER_EXPIRED_DURATION = Duration.ofDays(3);
private static final Duration REGISTER_GEN_DURATION = Duration.ofMinutes(30);

private static final String RK_REGISTER_UNIQUE_ID = "expert_registration_id:";
private static final String RK_REGISTER_UNIQUE_ID_LAST = RK_REGISTER_UNIQUE_ID + "last";

public synchronized String getRegistrationUrl() {
CacheKey lastKey = new CacheKey(RK_REGISTER_UNIQUE_ID_LAST, REGISTER_GEN_DURATION);
String lastUniqueId = cachePlusOps.get(lastKey);
if (StrUtil.isBlank(lastUniqueId)) {
lastUniqueId = BizUtils.uuid32();
CacheKey key = new CacheKey();
key.setKey(RK_REGISTER_UNIQUE_ID + lastUniqueId);
key.setExpire(REGISTER_EXPIRED_DURATION);
cachePlusOps.set(lastKey, lastUniqueId);
String gmtUserTime = LoginUserUtil.getUserId() + "#" + System.currentTimeMillis();
cachePlusOps.set(key, gmtUserTime);
}
return WebProperties.webUrl + "/pm/expert/ephemeral/" + lastUniqueId + "/registration";
}

public void redirectToRegistrationUrl(String uniqueId, HttpServletResponse response) throws IOException {
CacheKey cacheKey = new CacheKey(RK_REGISTER_UNIQUE_ID + uniqueId);
response.setContentType(MediaType.TEXT_PLAIN_VALUE);
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
try {
if (cachePlusOps.exists(cacheKey)) {
response.sendRedirect(WebProperties.webUrl + WebProperties.expertRegistrationUrl);
} else {
response.getWriter().write("专家报名链接已失效");
}
} catch (Exception e) {
log.error("专家报名链接重定向异常:", e);
response.getWriter().write("专家报名链接访问异常");
}
}


/**
@@ -95,7 +144,8 @@ public class ExpertManage {


@Transactional(rollbackFor = Exception.class)
public Long expertRecommendProofSubmit(List<DictionaryFieldInfo> recommendedWay, List<FileBasicInfo> recommendProofFile, Long expertUserId) {
public Long expertRecommendProofSubmit
(List<DictionaryFieldInfo> recommendedWay, List<FileBasicInfo> recommendProofFile, Long expertUserId) {
// 用户id
ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(expertUserId);
// 判断专家状态,是否可以进行证明材料提交


+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/config/WebProperties.java View File

@@ -16,10 +16,17 @@ import org.springframework.stereotype.Component;
@Component
public class WebProperties {

public static String expertRegistrationUrl;

public static String webUrl;

public static String provincialUrl;

@Value("${expert-registration.url:/expertEnroll}")
private void setExpertRegistrationUrl(String url) {
expertRegistrationUrl = url;
}

@Value("${web.url:}")
private void setWebUrl(String url) {
webUrl = url;


+ 2
- 0
pmapi/src/main/resources/application-dev.yml View File

@@ -238,5 +238,7 @@ login:
phone-verify-code:
skip: true
url: http://lspm.ningdatech.com/login
web:
url: http://lspm.ningdatech.com



+ 2
- 0
pmapi/src/main/resources/application-pre.yml View File

@@ -241,3 +241,5 @@ login:
phone-verify-code:
skip: true
url: http://60.188.225.145:8080/login
web:
url: http://60.188.225.145:8080

+ 2
- 0
pmapi/src/main/resources/application-prod.yml View File

@@ -241,3 +241,5 @@ login:
phone-verify-code:
skip: true
url: http://60.188.225.145/login
web:
url: http://60.188.225.145

+ 2
- 0
pmapi/src/main/resources/security/auth-dev.yml View File

@@ -38,6 +38,7 @@ security:
- /api/v1/irs/**
- /api/v1/wps-convert/**
- /api/v1/belong-org/business-strip/list
- /expert/ephemeral/*/registration
ignore-csrf-urls:
- /api/v1/user/auth/**
- /v2/api-docs
@@ -68,6 +69,7 @@ security:
- /api/v1/irs/**
- /api/v1/wps-convert/**
- /api/v1/belong-org/business-strip/list
- /expert/ephemeral/*/registration
role-map:
"engineer":
"project_manager":


+ 2
- 0
pmapi/src/main/resources/security/auth-pre.yml View File

@@ -38,6 +38,7 @@ security:
- /api/v1/irs/**
- /api/v1/wps-convert/**
- /api/v1/belong-org/business-strip/list
- /expert/ephemeral/*/registration
ignore-csrf-urls:
- /api/v1/user/auth/**
- /v2/api-docs
@@ -68,6 +69,7 @@ security:
- /api/v1/irs/**
- /api/v1/wps-convert/**
- /api/v1/belong-org/business-strip/list
- /expert/ephemeral/*/registration
role-map:
"engineer":
"project_manager":


+ 2
- 0
pmapi/src/main/resources/security/auth-prod.yml View File

@@ -38,6 +38,7 @@ security:
- /api/v1/irs/**
- /api/v1/wps-convert/**
- /api/v1/belong-org/business-strip/list
- /expert/ephemeral/*/registration
ignore-csrf-urls:
- /api/v1/user/auth/**
- /v2/api-docs
@@ -68,6 +69,7 @@ security:
- /api/v1/irs/**
- /api/v1/wps-convert/**
- /api/v1/belong-org/business-strip/list
- /expert/ephemeral/*/registration
role-map:
"engineer":
"project_manager":


Loading…
Cancel
Save