优化
This commit is contained in:
@ -8,6 +8,8 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.BgtUser;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -31,6 +33,8 @@ public class AppBgtUserController extends BaseController {
|
||||
|
||||
private final IBgtUserService iBgtUserService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
/**
|
||||
* 实名认证
|
||||
*/
|
||||
@ -39,7 +43,13 @@ public class AppBgtUserController extends BaseController {
|
||||
@RepeatSubmit
|
||||
@PutMapping
|
||||
public AjaxResult<Boolean> realNameAuthentication(@Validated @RequestBody UserRealNameAuthenticationDTO dto) {
|
||||
return AjaxResult.success(iBgtUserService.realNameAuthentication(dto));
|
||||
Boolean b = iBgtUserService.realNameAuthentication(dto);
|
||||
if(b){
|
||||
//更新上下文和缓存
|
||||
SecurityUtils.updateUsername(dto.getUsername());
|
||||
tokenService.refreshToken(SecurityUtils.getLoginUser());
|
||||
}
|
||||
return AjaxResult.success(b);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.BgtLoginBody;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.util.DataUtil;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.framework.web.service.AppLoginService;
|
||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||
@ -133,6 +134,16 @@ public class AppLoginController
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/test")
|
||||
public void test(String name)
|
||||
{
|
||||
System.out.println(SecurityUtils.getUsername());
|
||||
SecurityUtils.updateUsername(name);
|
||||
tokenService.refreshToken(SecurityUtils.getLoginUser());
|
||||
System.out.println(SecurityUtils.getUsername());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取用户信息
|
||||
|
@ -296,7 +296,7 @@ public class UploadZipController {
|
||||
}
|
||||
}
|
||||
|
||||
private void moveFilesToRecordDirRecursively(File source, File destination, String timeStamp, List<AnnexRecord> annexRecordList, Long recruitId,String username,Long userId) throws IOException {
|
||||
private void moveFilesToRecordDirRecursively(File source, File destination, String timeStamp, List<AnnexRecord> annexRecordList, Long recruitId, String username, Long userId) throws IOException {
|
||||
if (source.isDirectory()) {
|
||||
String folderName = source.getName();
|
||||
String[] parts = folderName.split("_");
|
||||
@ -305,24 +305,30 @@ public class UploadZipController {
|
||||
File[] files = source.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
moveFilesToRecordDirRecursively(file, destination, timeStamp, annexRecordList, recruitId,username,userId);
|
||||
moveFilesToRecordDirRecursively(file, destination, timeStamp, annexRecordList, recruitId, username, userId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (parts.length > 1) {
|
||||
folderName = folderName + "_" + timeStamp;
|
||||
}
|
||||
File newDir = new File(destination, folderName);
|
||||
ensureDirectoryExists(newDir);
|
||||
File[] files = source.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
moveFilesToRecordDirRecursively(file, newDir, timeStamp, annexRecordList, recruitId,username,userId);
|
||||
moveFilesToRecordDirRecursively(file, newDir, timeStamp, annexRecordList, recruitId, username, userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
File destFile = new File(destination, source.getName());
|
||||
// 获取文件名和扩展名
|
||||
String fileName = source.getName();
|
||||
int dotIndex = fileName.lastIndexOf('.');
|
||||
String nameWithoutExtension = dotIndex == -1 ? fileName : fileName.substring(0, dotIndex);
|
||||
String extension = dotIndex == -1 ? "" : fileName.substring(dotIndex);
|
||||
|
||||
// 在文件名后面添加时间戳
|
||||
String newFileName = nameWithoutExtension + "_" + timeStamp + extension;
|
||||
File destFile = new File(destination, newFileName);
|
||||
|
||||
ensureDirectoryExists(destFile.getParentFile());
|
||||
try (InputStream in = new FileInputStream(source);
|
||||
OutputStream out = new FileOutputStream(destFile)) {
|
||||
@ -332,19 +338,17 @@ public class UploadZipController {
|
||||
out.write(buffer, 0, length);
|
||||
}
|
||||
}
|
||||
String relativePath = RECORD_DIR + File.separator +timeStamp+ getRelativePath(source, new File(TEMP_DIR));
|
||||
relativePath = relativePath.replace("\\", "/").replace("ruoyi/uploadPath", "/profile");
|
||||
System.out.println("文件在记录目录里的相对目录: " + relativePath);
|
||||
|
||||
// 存到数据库作为记录
|
||||
// 记录文件信息到数据库
|
||||
String relativePath = RECORD_DIR + File.separator + getRelativePath(destFile, new File(RECORD_DIR));
|
||||
relativePath = relativePath.replace("\\", "/").replace("ruoyi/uploadPath", "/profile");
|
||||
|
||||
String parentName = destination.getParentFile().getName();
|
||||
System.out.println("上上一级文件名: " + parentName);
|
||||
String[] split = parentName.split("_");
|
||||
String card = split[1];
|
||||
WgzUser wgzUser = wgzUserService.findByIdentityCard(card);
|
||||
|
||||
String name = destination.getName();
|
||||
System.out.println("上一级文件名: " + name);
|
||||
String type = "";
|
||||
if ("保险".equals(name)) {
|
||||
type = "2";
|
||||
@ -352,18 +356,19 @@ public class UploadZipController {
|
||||
if ("劳务合同".equals(name)) {
|
||||
type = "1";
|
||||
}
|
||||
AnnexRecord annex = new AnnexRecord();
|
||||
annex.setAnnexName(destFile.getName());
|
||||
annex.setAnnexUrl(relativePath);
|
||||
annex.setAnnexType(type);
|
||||
annex.setUserType(Constants.WGZ);
|
||||
annex.setUserId(wgzUser.getUserId());
|
||||
annex.setRecruitId(recruitId);
|
||||
annex.setCreateBy(username);
|
||||
annex.setUpdateBy(username);
|
||||
annex.setCreateUserId(userId);
|
||||
annex.setCreateUserType(Constants.BGT);
|
||||
annexRecordList.add(annex);
|
||||
|
||||
AnnexRecord annexRecord = new AnnexRecord();
|
||||
annexRecord.setAnnexName(newFileName);
|
||||
annexRecord.setAnnexUrl(relativePath);
|
||||
annexRecord.setAnnexType(type);
|
||||
annexRecord.setUserType(Constants.WGZ);
|
||||
annexRecord.setUserId(wgzUser.getUserId());
|
||||
annexRecord.setRecruitId(recruitId);
|
||||
annexRecord.setCreateBy(username);
|
||||
annexRecord.setUpdateBy(username);
|
||||
annexRecord.setCreateUserId(userId);
|
||||
annexRecord.setCreateUserType(Constants.BGT);
|
||||
annexRecordList.add(annexRecord);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user