add:手机号

This commit is contained in:
zhangqinlin
2021-12-17 14:40:50 +08:00
parent 62074af6d5
commit 223f2236dc
2 changed files with 140 additions and 118 deletions
@@ -6,10 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.Assert;
import com.jero.common.util.CommonUtils;
import com.jero.common.util.PasswordUtil;
import com.jero.common.util.RedisUtil;
import com.jero.common.util.*;
import com.jero.company.service.IPayContactsManagementService;
import com.jero.data.entity.DetailForCaseCommittee;
import com.jero.data.entity.PayCaseCommittee;
@@ -99,6 +96,9 @@ public class PayCaseCommitteeServiceImpl extends ServiceImpl<PayCaseCommitteeMap
if (!password.equals(verifyPassword)) {
throw new JeroBootException("新密码和确认密码不一致,请重新输入");
}
String salt = oConvertUtils.randomGen(8);
String passwordEncode = PasswordUtil.encrypt(phone,password,salt);
registerSelf.getPayContactsManagement().setPassword(passwordEncode);
payContactsManagementService.addMeeting(registerSelf.getPayContactsManagement());
redisUtil.del("_verification:_phone:" + phone);
}
@@ -1,6 +1,7 @@
package com.jero.meeting.controller;
import java.io.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
@@ -426,7 +427,6 @@ public class PayMeetingController extends JeroController<PayMeeting, IPayMeeting
//String publicKey = request.getParameter("publicKey");
//String token = request.getParameter("token");
//authenticationUtils.check(token, publicKey);
payMeetingService.addStandards(payMeeting);
return Result.OK("合并开票成功!");
}
@@ -448,121 +448,143 @@ public class PayMeetingController extends JeroController<PayMeeting, IPayMeeting
* @param id 传入文件id
* @param response
*/
@ApiOperation(value = "企业端会议下载资料", notes = "企业端会议下载资料")
@GetMapping(value = "/userDownload/{id}/{meetingId}")
public void download(@PathVariable String id, @PathVariable String meetingId, HttpServletResponse response, String type) {
// LoginUser sysUser =(LoginUser) SecurityUtils.getSubject().getPrincipal();
// String sysUserId = sysUser.getId();
// PayMeeting byId = payMeetingService.getById(meetingId);
// if(ObjectUtils.isEmpty(byId)){
// throw new JeroBootException("会议不存在..");
// }
// String meetingMinute = byId.getMeetingMinute();
// String meetingData = byId.getMeetingData();
// List<String>
// if(meetingMinute)
// List<String> meetingMinuteList = Arrays.asList(meetingMinute.split(","));
// List<String> meetingMinuteList = Arrays.asList(meetingMinute.split(","));
// // 查询数据表数据是否存在
// LambdaQueryWrapper<OSSFile> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.eq(OSSFile::getId,id);
// OSSFile ossFile = ossFileService.getOne(queryWrapper);
// if( null == ossFile){
// throw new JeroBootException("文件不存在..");
// }
// String fileUrl = ossFile.getUrl();
// InputStream inputStream = null;
// OutputStream outputStream = null;
// try {
// String fileName = "";
// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
// //本地下载
// String filePath = uploadpath + File.separator + fileUrl;
// File file = new File(filePath);
// if(!file.exists()){
// response.setStatus(404);
// throw new RuntimeException("文件不存在..");
// }
// // 文件名称
// fileName = file.getName();
// inputStream = new BufferedInputStream(new FileInputStream(filePath));
// }else if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
// // minio 下载
// // 通过MinioUtil查询时 只需要桶后面的路径
// String minioUrl = MinioUtil.getMinioUrl();
// // Linux/unix 系统下文件路径分隔符为"/" 获取minio与存储桶的路径
// minioUrl = minioUrl + MinioUtil.getBucketName() + "/";
// String url = fileUrl.replace(minioUrl, "");
// // 文件名称
// fileName = ossFile.getFileName();
// inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url);
// }
//
// ossFileService.updateById(ossFile);
// LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
// if (loginUser.getIsCompanyUser()) {
// Integer integer = ossFileService.searchDownloadTimes(ossFile.getId(), loginUser.getId());
// if (integer >= 5) {
// throw new JeroBootException("超出下载次数限制");
// }
// }
// ossFileService.saveDownloadTimes(ossFile.getId(), loginUser.getId());
//
// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1"));
// response.setContentType("application/force-download");// 设置强制下载不打开
// if (type == null) {
// fileName = StringUtils.lowerCase(fileName);
// if (fileName.contains(".jpg") || fileName.contains(".gif") || fileName.contains(".jpeg")) {
// response.setContentType("image/jpeg;image/jpg;image/gif;image/png");
// } else if (fileName.contains(".png")) {
// response.setContentType("image/png;image/jpg;image/gif;image/jpeg");
// }
// }
// outputStream = response.getOutputStream();
// byte[] buf = new byte[1024];
// int len;
// while ((len = inputStream.read(buf)) > 0) {
// outputStream.write(buf, 0, len);
// }
// response.flushBuffer();
// //统计下载和上传次数
// if ("download".equals(type)) {
// Integer downloadNumber = ossFile.getDownloadNumber();
// if (downloadNumber == null) {
// ossFile.setDownloadNumber(1);
// } else {
// ossFile.setDownloadNumber(downloadNumber + 1);
// }
// ossFileService.updateById(ossFile);
// } else {
// Integer viewNumber = ossFile.getViewNumber();
// if (viewNumber == null) {
// ossFile.setViewNumber(1);
// } else {
// ossFile.setViewNumber(viewNumber + 1);
// }
// ossFileService.updateAndPush(ossFile);
// }
// } catch (IOException e) {
// log.error("预览文件失败" + e.getMessage());
// response.setStatus(404);
// e.printStackTrace();
// } finally {
// if (inputStream != null) {
// try {
// inputStream.close();
// } catch (IOException e) {
// log.error(e.getMessage(), e);
// }
// }
// if (outputStream != null) {
// try {
// outputStream.close();
// } catch (IOException e) {
// log.error(e.getMessage(), e);
// }
// }
// }
//
LoginUser sysUser =(LoginUser) SecurityUtils.getSubject().getPrincipal();
String sysUserId = sysUser.getId();
PayMeeting byId = payMeetingService.getById(meetingId);
if(ObjectUtils.isEmpty(byId)){
throw new JeroBootException("会议不存在..");
}
String meetingMinute = byId.getMeetingMinute();
String meetingData = byId.getMeetingData();
List<String> fileList = null;
if(StringUtils.isNotBlank(meetingMinute)) {
fileList.addAll(Arrays.asList(meetingMinute.split(",")));
}
if(StringUtils.isNotBlank(meetingData)) {
fileList.addAll(Arrays.asList(meetingData.split(",")));
}
if(fileList==null||!fileList.contains(id)){
throw new JeroBootException("会议无此文件..");
}
BigDecimal meetingCosts = byId.getMeetingCosts();
//免费会议
if ("0".equals(meetingCosts.toString())){
QueryWrapper<PayMeetingSituation> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("meeting_id", meetingId);
queryWrapper1.eq("company_contact_id", sysUserId);
PayMeetingSituation one = payMeetingSituationService.getOne(queryWrapper1);
if (ObjectUtils.isEmpty(one)) {
throw new JeroBootException("会议报名并审核通过后才可查看文件");
}
Integer checkResult = one.getCheckResult();
if (checkResult != 1) {
throw new JeroBootException("会议报名并审核通过后才可查看文件");
}
}
// 查询数据表数据是否存在
LambdaQueryWrapper<OSSFile> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OSSFile::getId,id);
OSSFile ossFile = ossFileService.getOne(queryWrapper);
if( null == ossFile){
throw new JeroBootException("文件不存在..");
}
String fileUrl = ossFile.getUrl();
InputStream inputStream = null;
OutputStream outputStream = null;
try {
String fileName = "";
if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){
//本地下载
String filePath = uploadpath + File.separator + fileUrl;
File file = new File(filePath);
if(!file.exists()){
response.setStatus(404);
throw new RuntimeException("文件不存在..");
}
// 文件名称
fileName = file.getName();
inputStream = new BufferedInputStream(new FileInputStream(filePath));
}else if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
// minio 下载
// 通过MinioUtil查询时 只需要桶后面的路径
String minioUrl = MinioUtil.getMinioUrl();
// Linux/unix 系统下文件路径分隔符为"/" 获取minio与存储桶的路径
minioUrl = minioUrl + MinioUtil.getBucketName() + "/";
String url = fileUrl.replace(minioUrl, "");
// 文件名称
fileName = ossFile.getFileName();
inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url);
}
ossFileService.updateById(ossFile);
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (loginUser.getIsCompanyUser()) {
Integer integer = ossFileService.searchDownloadTimes(ossFile.getId(), loginUser.getId());
if (integer >= 5) {
throw new JeroBootException("超出下载次数限制");
}
}
ossFileService.saveDownloadTimes(ossFile.getId(), loginUser.getId());
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1"));
response.setContentType("application/force-download");// 设置强制下载不打开
if (type == null) {
fileName = StringUtils.lowerCase(fileName);
if (fileName.contains(".jpg") || fileName.contains(".gif") || fileName.contains(".jpeg")) {
response.setContentType("image/jpeg;image/jpg;image/gif;image/png");
} else if (fileName.contains(".png")) {
response.setContentType("image/png;image/jpg;image/gif;image/jpeg");
}
}
outputStream = response.getOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0) {
outputStream.write(buf, 0, len);
}
response.flushBuffer();
//统计下载和上传次数
if ("download".equals(type)) {
Integer downloadNumber = ossFile.getDownloadNumber();
if (downloadNumber == null) {
ossFile.setDownloadNumber(1);
} else {
ossFile.setDownloadNumber(downloadNumber + 1);
}
ossFileService.updateById(ossFile);
} else {
Integer viewNumber = ossFile.getViewNumber();
if (viewNumber == null) {
ossFile.setViewNumber(1);
} else {
ossFile.setViewNumber(viewNumber + 1);
}
ossFileService.updateAndPush(ossFile);
}
} catch (IOException e) {
log.error("预览文件失败" + e.getMessage());
response.setStatus(404);
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
}
}