面试通过函详情及通过函生成和OSS服务器上传文件
This commit is contained in:
@@ -94,10 +94,11 @@ public class PDFUtils {
|
||||
* @param color 字体颜色
|
||||
*/
|
||||
private static void addContent(PdfReader reader, OutputStream outputStream, String content, float x, float y, BaseFont baseFont, float fontSize, int fontStyle, Color color) {
|
||||
PdfStamper stamper = null;
|
||||
try {
|
||||
//生成 paragraph 并放在正确位置
|
||||
//抠模板
|
||||
PdfStamper stamper = new PdfStamper(reader, outputStream);
|
||||
stamper = new PdfStamper(reader, outputStream);
|
||||
PdfContentByte over = stamper.getOverContent(1);
|
||||
Font font = new Font(baseFont, fontSize, fontStyle, color);
|
||||
Paragraph insertContent = new Paragraph(content, font);
|
||||
@@ -110,6 +111,14 @@ public class PDFUtils {
|
||||
stamper.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (stamper != null) {
|
||||
stamper.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,19 +22,16 @@ public class PassLetterUtils {
|
||||
* 返回通过函编码
|
||||
* @param partnerName 加盟商姓名
|
||||
* @param verifyCity 审批城市
|
||||
* @param passCode 通过函编码
|
||||
* @param passTime 审批通过时间
|
||||
*/
|
||||
public static String genPassLetter(String partnerName, String passCode, String verifyCity, DateTime passTime) {
|
||||
String randomNum = RandomUtil.randomNumbers(5);
|
||||
if (ObjectUtil.isEmpty(passCode)) {
|
||||
passCode = "HSAY" + DateUtil.format(passTime, "yyMMdd") + "-" + randomNum;
|
||||
}
|
||||
public static ByteArrayOutputStream genPassLetter(String partnerName, String passCode, String verifyCity, DateTime passTime) {
|
||||
String passTimeStr = DateUtil.format(passTime, "yyyy年MM月dd日");
|
||||
Document document = new Document();
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
//1. 创建 pdf document
|
||||
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
FileOutputStream outputStream = new FileOutputStream("passLetter.pdf");
|
||||
// FileOutputStream outputStream = new FileOutputStream("passLetter.pdf");
|
||||
PdfWriter.getInstance(document, outputStream);
|
||||
document.open();
|
||||
|
||||
@@ -44,21 +41,38 @@ public class PassLetterUtils {
|
||||
document.close();
|
||||
|
||||
//3. 填写通过函模板信息
|
||||
addContentToPdf(partnerName + " 先生/女士", 122, 640);
|
||||
addContentToPdf(passCode, 122, 558);
|
||||
addContentToPdf(verifyCity, 155, 494);
|
||||
addContentToPdf("60天", 135, 450);
|
||||
addContentToPdf(passTimeStr, 393, 152);
|
||||
return passCode;
|
||||
addContentToPdf(outputStream, partnerName + " 先生/女士", 122, 640);
|
||||
addContentToPdf(outputStream, passCode, 122, 558);
|
||||
addContentToPdf(outputStream, verifyCity, 155, 494);
|
||||
addContentToPdf(outputStream, "60天", 135, 450);
|
||||
addContentToPdf(outputStream, passTimeStr, 393, 152);
|
||||
return outputStream;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
document.close();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addContentToPdf(String content, float x, float y) {
|
||||
/**
|
||||
* 生成 passCode 的方法,拆分出来方便单独获取 passCode
|
||||
* @return
|
||||
*/
|
||||
public static String genPassCode(DateTime passTime) {
|
||||
String randomNum = RandomUtil.randomNumbers(5);
|
||||
String passCode = "HSAY" + DateUtil.format(passTime, "yyMMdd") + "-" + randomNum;
|
||||
return passCode;
|
||||
}
|
||||
|
||||
private static void addContentToPdf(ByteArrayOutputStream outputStream, String content, float x, float y) {
|
||||
try {
|
||||
PdfReader pdfReader = new PdfReader(Files.newInputStream(Paths.get("passLetter.pdf")));
|
||||
OutputStream outputStream = Files.newOutputStream(Paths.get("passLetter.pdf"));
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
PdfReader pdfReader = new PdfReader(inputStream);
|
||||
PDFUtils.putParagraphAbsolutely(pdfReader, outputStream, x, y, content, 20, new Color(255, 82,25));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.entity.HyPartnerInterviewDO;
|
||||
import com.cool.store.vo.EnterInterviewVO;
|
||||
import com.cool.store.vo.PartnerInterviewInfoVO;
|
||||
import com.cool.store.vo.PartnerPassLetterDetailVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -61,11 +62,16 @@ public interface HyPartnerInterviewMapper {
|
||||
/**
|
||||
* 根据会议 id 查询面试官 id
|
||||
*/
|
||||
String getInterviewerByInterviewId(@Param("interviewId") String interviewId);
|
||||
EnterInterviewVO getInterviewerByInterviewId(@Param("interviewId") String interviewId);
|
||||
|
||||
/**
|
||||
* 获取通知函详情
|
||||
*/
|
||||
PartnerPassLetterDetailVO getPassLetterDetail(@Param("interviewId") String interviewId);
|
||||
|
||||
/**
|
||||
* 生成通过函 pdf 后修改
|
||||
*/
|
||||
int updatePassLetterInfo(@Param("passCode") String passCode, @Param("passFileUrl") String passFileUrl, @Param("expiryDate") String expiryDate, @Param("interviewId") String interviewId);
|
||||
|
||||
}
|
||||
@@ -106,10 +106,10 @@
|
||||
<if test="record.contentTitle != null and record.contentTitle != ''">
|
||||
content_title = #{record.contentTitle},
|
||||
</if>
|
||||
<if test="record.subject != null and record.subject != ''">
|
||||
<if test="record.subject != null">
|
||||
subject = #{record.subject},
|
||||
</if>
|
||||
<if test="record.contentType != null and record.contentType != ''">
|
||||
<if test="record.contentType != null">
|
||||
content_type = #{record.contentType},
|
||||
</if>
|
||||
<if test="record.cover != null and record.cover != ''">
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
<association property="interviewerName" column="interviewerId" select="queryInterviewerName" javaType="string"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="partnerEnterInterviewVO" type="com.cool.store.vo.EnterInterviewVO">
|
||||
<association property="partnerName" column="partner_id" select="queryPartnerName"></association>
|
||||
<association property="interviewerName" column="interviewer" select="queryInterviewerName"></association>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="passLetterDetail" type="com.cool.store.vo.PartnerPassLetterDetailVO">
|
||||
<association property="partnerName" column="partner_id" select="queryPartnerName"></association>
|
||||
<association property="verifyCity" column="partner_id" select="getVerifyCity"></association>
|
||||
@@ -311,23 +316,44 @@
|
||||
</update>
|
||||
|
||||
<!-- 根据会议 id 获取面试官 id -->
|
||||
<select id="getInterviewerByInterviewId" resultType="java.lang.String">
|
||||
SELECT interviewer
|
||||
<select id="getInterviewerByInterviewId" resultMap="partnerEnterInterviewVO">
|
||||
SELECT interviewer, interviewer interviewer_id, partner_id
|
||||
FROM hy_partner_interview
|
||||
WHERE id = #{interviewId}
|
||||
</select>
|
||||
|
||||
<!-- 获取通知函详情 -->
|
||||
<select id="getPassLetterDetail" resultMap="passLetterDetail">
|
||||
SELECT pass_code, pass_file_url, expiry_date, partner_id
|
||||
SELECT auth_code, pass_code, pass_file_url, expiry_date, partner_id
|
||||
FROM hy_partner_interview
|
||||
WHERE id = #{interviewId}
|
||||
</select>
|
||||
<!-- 获取意向开店区域 -->
|
||||
<select id="getVerifyCity" resultType="string">
|
||||
SELECT want_shop_area
|
||||
FROM hy_partner_intent_info
|
||||
WHERE partner_id = #{partner_id}
|
||||
SELECT area_path
|
||||
FROM hy_open_area_info
|
||||
WHERE id = (
|
||||
SELECT want_shop_area
|
||||
FROM hy_partner_intent_info
|
||||
WHERE partner_id = #{partner_id}
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 生成通过函 pdf 后修改 -->
|
||||
<update id="updatePassLetterInfo">
|
||||
UPDATE hy_partner_interview
|
||||
<set>
|
||||
<if test="passCode != null and passCode != ''">
|
||||
pass_code = #{passCode},
|
||||
</if>
|
||||
<if test="passFileUrl != null and passFileUrl != ''">
|
||||
pass_file_url = #{passFileUrl},
|
||||
</if>
|
||||
<if test="expiryDate != null and expiryDate != ''">
|
||||
expiry_date = #{expiryDate}
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{interviewId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PartnerEnterInterviewVO {
|
||||
public class EnterInterviewVO {
|
||||
|
||||
@ApiModelProperty("userSig 进入会议需要的用户签名")
|
||||
private String userSign;
|
||||
@@ -12,4 +12,10 @@ public class PartnerEnterInterviewVO {
|
||||
@ApiModelProperty("面试官id")
|
||||
private String interviewerId;
|
||||
|
||||
@ApiModelProperty("面试官姓名")
|
||||
private String interviewerName;
|
||||
|
||||
@ApiModelProperty("加盟商姓名")
|
||||
private String partnerName;
|
||||
|
||||
}
|
||||
@@ -9,7 +9,10 @@ public class PartnerPassLetterDetailVO {
|
||||
@ApiModelProperty("加盟商姓名")
|
||||
private String partnerName;
|
||||
|
||||
@ApiModelProperty("编码")
|
||||
@ApiModelProperty("授权码")
|
||||
private String authCode;
|
||||
|
||||
@ApiModelProperty("通过函编码")
|
||||
private String passCode;
|
||||
|
||||
@ApiModelProperty("审核城市")
|
||||
|
||||
@@ -41,6 +41,11 @@
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ons20190214</artifactId>
|
||||
</dependency>
|
||||
<!-- OSS -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.cool.store.oss;
|
||||
|
||||
import com.aliyun.oss.ClientException;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.OSSException;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class OSSServer {
|
||||
|
||||
@Value("${oss.accessKeyId:null}")
|
||||
private String accessKeyId;
|
||||
@Value("${oss.accessKeySecret:null}")
|
||||
private String accessKeySecret;
|
||||
@Value("${oss.endpoint:null}")
|
||||
private String endpoint;
|
||||
@Value("${oss.bucket:null}")
|
||||
private String bucket;
|
||||
@Value("${corp.id:null}")
|
||||
private String corpId;
|
||||
|
||||
/**
|
||||
* 服务端上传文件的方法
|
||||
* ObjectName 为文件存放位置 + 名字,不可包含 bucket
|
||||
*/
|
||||
public String uploadFileServer(InputStream inputStream, String objectName) {
|
||||
// 创建OSSClient实例。
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||
try {
|
||||
// 创建PutObjectRequest对象。
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, objectName, inputStream);
|
||||
// 创建PutObject请求。
|
||||
ossClient.putObject(putObjectRequest);
|
||||
return "http://" + bucket + "." + endpoint + "/" + objectName;
|
||||
} catch (OSSException oe) {
|
||||
log.error("Caught an OSSException, which means your request made it to OSS, "
|
||||
+ "but was rejected with an error response for some reason.");
|
||||
log.error("Error Message:" + oe.getErrorMessage());
|
||||
log.error("Error Code:" + oe.getErrorCode());
|
||||
log.error("Request ID:" + oe.getRequestId());
|
||||
log.error("Host ID:" + oe.getHostId());
|
||||
} catch (ClientException ce) {
|
||||
log.error("Caught an ClientException, which means the client encountered "
|
||||
+ "a serious internal problem while trying to communicate with OSS, "
|
||||
+ "such as not being able to access the network.");
|
||||
log.error("Error Message:" + ce.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally {
|
||||
if (ossClient != null) {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.partner.EnterInterviewDto;
|
||||
import com.cool.store.request.EntrustOthersReq;
|
||||
import com.cool.store.request.FinishInterviewReq;
|
||||
import com.cool.store.request.GetInterviewListReq;
|
||||
import com.cool.store.request.ModifyInterviewTimeReq;
|
||||
import com.cool.store.vo.EnterInterviewVO;
|
||||
import com.cool.store.vo.interview.InterviewVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,4 +41,13 @@ public interface InterviewService {
|
||||
* @param request
|
||||
*/
|
||||
void finishInterview(FinishInterviewReq request);
|
||||
|
||||
/**
|
||||
* 进入面试间的方法
|
||||
* 修改一些面试状态
|
||||
* 最后返回 userSign 用于进入腾讯云音视频房间
|
||||
* @return userSign 进入视频所需签名
|
||||
*/
|
||||
EnterInterviewVO enterInterviewRoom(EnterInterviewDto dto);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.partner.EnterInterviewDto;
|
||||
import com.cool.store.vo.PartnerEnterInterviewVO;
|
||||
import com.cool.store.vo.EnterInterviewVO;
|
||||
import com.cool.store.vo.PartnerInterviewInfoVO;
|
||||
import com.cool.store.vo.PartnerPassLetterDetailVO;
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface PartnerInterviewService {
|
||||
* 最后返回 userSign 用于进入腾讯云音视频房间
|
||||
* @return userSign 进入视频所需签名
|
||||
*/
|
||||
PartnerEnterInterviewVO enterInterviewRoom(EnterInterviewDto dto);
|
||||
EnterInterviewVO enterInterviewRoom(EnterInterviewDto dto);
|
||||
|
||||
/**
|
||||
* 获取通知函详情
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.cool.store.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.cool.store.dto.partner.EnterInterviewDto;
|
||||
import com.cool.store.entity.HyPartnerInterviewDO;
|
||||
import com.cool.store.entity.HyPartnerInterviewPlanDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.HyPartnerInterviewMapper;
|
||||
import com.cool.store.mapper.HyPartnerInterviewPlanMapper;
|
||||
import com.cool.store.request.EntrustOthersReq;
|
||||
@@ -11,10 +14,14 @@ import com.cool.store.request.FinishInterviewReq;
|
||||
import com.cool.store.request.GetInterviewListReq;
|
||||
import com.cool.store.request.ModifyInterviewTimeReq;
|
||||
import com.cool.store.service.InterviewService;
|
||||
import com.cool.store.utils.TRTCUtils;
|
||||
import com.cool.store.vo.EnterInterviewVO;
|
||||
import com.cool.store.vo.interview.InterviewVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -28,9 +35,18 @@ import java.util.List;
|
||||
@Service
|
||||
public class InterviewServiceImpl implements InterviewService {
|
||||
|
||||
@Value("${trtc.sdkAppId}")
|
||||
private Long sdkAppId;
|
||||
|
||||
@Value("${trtc.secretKey}")
|
||||
private String key;
|
||||
|
||||
@Autowired
|
||||
private HyPartnerInterviewPlanMapper hyPartnerInterviewPlanMapper;
|
||||
|
||||
@Autowired
|
||||
private HyPartnerInterviewMapper interviewMapper;
|
||||
|
||||
@Autowired
|
||||
private HyPartnerInterviewMapper hyPartnerInterviewMapper;
|
||||
@Override
|
||||
@@ -97,6 +113,35 @@ public class InterviewServiceImpl implements InterviewService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入面试间的方法
|
||||
* 修改一些面试状态
|
||||
* 最后返回 userSign 用于进入腾讯云音视频房间
|
||||
*
|
||||
* @return userSign 进入视频所需签名
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public EnterInterviewVO enterInterviewRoom(EnterInterviewDto dto) {
|
||||
try {
|
||||
//1. 将面试状态改为 --> 2已开始
|
||||
interviewMapper.updateInterviewStatus(dto.getInterviewId(), 2);
|
||||
//3. 修改面试实际开始时间,以第一个人进来的时间为准,后续不再修改
|
||||
interviewMapper.updateActualStartTime(dto.getInterviewId(), DateUtil.now());
|
||||
//4. 修改加盟商或面试官进入面试时间
|
||||
interviewMapper.updateEnterTime(dto.getInterviewId(), dto.getUserType(), DateUtil.now());
|
||||
//5. 加盟商如果进入了,就修改面试计划表 is_partner_interview 字段
|
||||
interviewMapper.updateWhetherPartnerEnter(dto.getInterviewId());
|
||||
//6. 查询对应的面试官id、姓名及加盟商姓名
|
||||
EnterInterviewVO vo = interviewMapper.getInterviewerByInterviewId(dto.getInterviewId());
|
||||
//生成 userSign
|
||||
String userSig = TRTCUtils.genUserSig(sdkAppId, key, dto.getUserId());
|
||||
vo.setUserSign(userSig);
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(ErrorCodeEnum.INTERVIEW_ENTER_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,16 +2,16 @@ package com.cool.store.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cool.store.dto.partner.EnterInterviewDto;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.HyPartnerInterviewMapper;
|
||||
import com.cool.store.oss.OSSServer;
|
||||
import com.cool.store.service.PartnerInterviewService;
|
||||
import com.cool.store.utils.PDFUtils;
|
||||
import com.cool.store.utils.PassLetterUtils;
|
||||
import com.cool.store.utils.TRTCUtils;
|
||||
import com.cool.store.vo.PartnerEnterInterviewVO;
|
||||
import com.cool.store.vo.EnterInterviewVO;
|
||||
import com.cool.store.vo.PartnerInterviewInfoVO;
|
||||
import com.cool.store.vo.PartnerPassLetterDetailVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -19,8 +19,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
|
||||
@Service
|
||||
public class PartnerInterviewServiceImpl implements PartnerInterviewService {
|
||||
@@ -28,6 +27,9 @@ public class PartnerInterviewServiceImpl implements PartnerInterviewService {
|
||||
@Autowired
|
||||
private HyPartnerInterviewMapper interviewMapper;
|
||||
|
||||
@Autowired
|
||||
private OSSServer ossServer;
|
||||
|
||||
@Value("${trtc.sdkAppId}")
|
||||
private Long sdkAppId;
|
||||
|
||||
@@ -54,7 +56,7 @@ public class PartnerInterviewServiceImpl implements PartnerInterviewService {
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public PartnerEnterInterviewVO enterInterviewRoom(EnterInterviewDto dto) {
|
||||
public EnterInterviewVO enterInterviewRoom(EnterInterviewDto dto) {
|
||||
try {
|
||||
//1. 将面试状态改为 --> 2已开始
|
||||
interviewMapper.updateInterviewStatus(dto.getInterviewId(), 2);
|
||||
@@ -64,13 +66,11 @@ public class PartnerInterviewServiceImpl implements PartnerInterviewService {
|
||||
interviewMapper.updateEnterTime(dto.getInterviewId(), dto.getUserType(), DateUtil.now());
|
||||
//5. 加盟商如果进入了,就修改面试计划表 is_partner_interview 字段
|
||||
interviewMapper.updateWhetherPartnerEnter(dto.getInterviewId());
|
||||
//6. 查询对应的面试官id
|
||||
String interviewId = interviewMapper.getInterviewerByInterviewId(dto.getInterviewId());
|
||||
//6. 查询对应的面试官id、姓名及加盟商姓名
|
||||
EnterInterviewVO vo = interviewMapper.getInterviewerByInterviewId(dto.getInterviewId());
|
||||
//生成 userSign
|
||||
String userSig = TRTCUtils.genUserSig(sdkAppId, key, dto.getUserId());
|
||||
PartnerEnterInterviewVO vo = new PartnerEnterInterviewVO();
|
||||
vo.setUserSign(userSig);
|
||||
vo.setInterviewerId(interviewId);
|
||||
return vo;
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException(ErrorCodeEnum.INTERVIEW_ENTER_FAIL);
|
||||
@@ -84,17 +84,8 @@ public class PartnerInterviewServiceImpl implements PartnerInterviewService {
|
||||
@Override
|
||||
public PartnerPassLetterDetailVO passLetterDetail(String interviewId) {
|
||||
PartnerPassLetterDetailVO vo = interviewMapper.getPassLetterDetail(interviewId);
|
||||
//有效期为审批通过次日起第 60 天的 23:59:59,由此倒推 createTime
|
||||
DateTime expiryDate = DateUtil.parseDate(vo.getExpiryDate());
|
||||
DateTime createTime = DateUtil.offsetDay(expiryDate, -61);
|
||||
vo.setCreateTime(DateUtil.format(createTime, "yyyy-MM-dd"));
|
||||
//解析意向开店区域为市级行政区
|
||||
String verifyCity = vo.getVerifyCity();
|
||||
if (verifyCity == null) {
|
||||
String passCode = PassLetterUtils.genPassLetter(vo.getPartnerName(), verifyCity, vo.getPassCode(), createTime);
|
||||
vo.setPassCode(passCode);
|
||||
return vo;
|
||||
}
|
||||
String[] split = verifyCity.split("/");
|
||||
//根据长度来取市级行政区域
|
||||
if (split.length == 2) {
|
||||
@@ -106,9 +97,35 @@ public class PartnerInterviewServiceImpl implements PartnerInterviewService {
|
||||
} else {
|
||||
System.out.println("wrong");
|
||||
}
|
||||
String passCode = PassLetterUtils.genPassLetter(vo.getPartnerName(), verifyCity, vo.getPassCode(), createTime);
|
||||
vo.setPassCode(passCode);
|
||||
// TODO 调用生成通过函和修改数据库数据的方法
|
||||
String passCode = genPassLetterAndUpdateDB(vo, interviewId);
|
||||
//再查一次 vo
|
||||
vo = interviewMapper.getPassLetterDetail(interviewId);
|
||||
//有效期为审批通过次日起第 60 天的 23:59:59,由此倒推 createTime
|
||||
DateTime expiryDate = DateUtil.parseDate(vo.getExpiryDate());
|
||||
DateTime createTime = DateUtil.offsetDay(expiryDate, -60);
|
||||
vo.setCreateTime(DateUtil.format(createTime, "yyyy-MM-dd"));
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 暂时将生成 passLetter 并上传 OSS 和修改数据库对应信息的方法放在这里,实际应该在 800 的回调方法中
|
||||
* @return passCode
|
||||
*/
|
||||
private String genPassLetterAndUpdateDB(PartnerPassLetterDetailVO passLetterDetail, String interviewId) {
|
||||
//已经有 passCode 的话就不要再生成了,默认上游全部数据都正确
|
||||
if (ObjectUtil.isEmpty(passLetterDetail.getPassCode())) {
|
||||
DateTime createTime = DateUtil.date();
|
||||
String code = passLetterDetail.getPassCode() == null ? PassLetterUtils.genPassCode(createTime) : passLetterDetail.getPassCode();
|
||||
ByteArrayOutputStream outputStream = PassLetterUtils.genPassLetter(passLetterDetail.getPartnerName(), code, passLetterDetail.getVerifyCity(), createTime);
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
String passFileUrl = ossServer.uploadFileServer(inputStream, "partner/passLetter/" + code + ".pdf");
|
||||
//计算有效期截至日期
|
||||
DateTime expiryDate = DateUtil.offsetDay(createTime, 60);
|
||||
String expiryDateStr = DateUtil.format(expiryDate, "yyyy-MM-dd") + " 23:59:59";
|
||||
interviewMapper.updatePassLetterInfo(code, passFileUrl, expiryDateStr, interviewId);
|
||||
}
|
||||
return passLetterDetail.getPassCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.cool.store.controller;
|
||||
|
||||
import com.cool.store.dto.partner.EnterInterviewDto;
|
||||
import com.cool.store.request.*;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.InterviewService;
|
||||
import com.cool.store.vo.EnterInterviewVO;
|
||||
import com.cool.store.vo.interview.InterviewVO;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -65,6 +67,10 @@ public class InterviewController {
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/enter")
|
||||
@ApiOperation("进入面试间")
|
||||
public ResponseResult<EnterInterviewVO> enterInterviewRoom(@RequestBody EnterInterviewDto dto) {
|
||||
return ResponseResult.success(interviewService.enterInterviewRoom(dto));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,25 +3,14 @@ package com.cool.store.controller;
|
||||
import com.cool.store.dto.partner.EnterInterviewDto;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.PartnerInterviewService;
|
||||
import com.cool.store.utils.PDFUtils;
|
||||
import com.cool.store.vo.PartnerEnterInterviewVO;
|
||||
import com.cool.store.vo.EnterInterviewVO;
|
||||
import com.cool.store.vo.PartnerInterviewInfoVO;
|
||||
import com.cool.store.vo.PartnerPassLetterDetailVO;
|
||||
import com.lowagie.text.Document;
|
||||
import com.lowagie.text.Image;
|
||||
import com.lowagie.text.pdf.PdfWriter;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Api(tags = "加盟商资格面试")
|
||||
@RestController
|
||||
@RequestMapping("interview")
|
||||
@@ -38,7 +27,7 @@ public class InterviewController {
|
||||
|
||||
@PostMapping("/enter")
|
||||
@ApiOperation("进入面试间")
|
||||
public ResponseResult<PartnerEnterInterviewVO> enterInterviewRoom(@RequestBody EnterInterviewDto dto) {
|
||||
public ResponseResult<EnterInterviewVO> enterInterviewRoom(@RequestBody EnterInterviewDto dto) {
|
||||
return ResponseResult.success(interviewService.enterInterviewRoom(dto));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user