修改权限数据同步结果返回的数据
This commit is contained in:
parent
47bb0696a5
commit
7953f51000
@ -57,7 +57,7 @@ public class DataHandleController {
|
||||
|
||||
msgList.addAll(paperCompositionController.oldDataHandle());
|
||||
|
||||
userController.sync(response);
|
||||
msgList.addAll(userController.sync());
|
||||
return msgList;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import club.joylink.rtss.vo.client.user.WeChatBindStatusVO;
|
||||
import club.joylink.rtss.vo.user.AccountCreateVO;
|
||||
import club.joylink.rtss.vo.user.CreateAccountCheck;
|
||||
import club.joylink.rtss.vo.user.UserGenerateConfigVO;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.tomcat.util.http.fileupload.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -65,31 +66,11 @@ public class UserController {
|
||||
}
|
||||
@Role({RoleEnum.SuperAdmin, RoleEnum.Admin})
|
||||
@GetMapping(path = "sync")
|
||||
public String sync( HttpServletResponse response){
|
||||
public List<String> sync(){
|
||||
if(!this.syncService.initData()){
|
||||
return "正在同步。。。";
|
||||
throw new RuntimeException("正在同步。。。");
|
||||
}
|
||||
File file = this.syncService.sync();
|
||||
if(Objects.isNull(file) || !file.exists()){
|
||||
return "未找到统计的同步文件";
|
||||
}
|
||||
response.reset();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentLength((int) file.length());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + file.getName());
|
||||
try(BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
|
||||
byte[] buff = new byte[1024];
|
||||
OutputStream os = response.getOutputStream();
|
||||
int i = 0;
|
||||
while ((i = bis.read(buff)) != -1) {
|
||||
os.write(buff, 0, i);
|
||||
os.flush();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return "文件下载失败";
|
||||
}
|
||||
return "";
|
||||
return this.syncService.sync();
|
||||
}
|
||||
/**
|
||||
*分页获取用户数据
|
||||
|
@ -114,7 +114,7 @@ public class OldPermissionDataSyncService {
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public File sync(){
|
||||
public List<String> sync(){
|
||||
try{
|
||||
List<UserPermissionVO> userPermissionList = findUserPermissionData();
|
||||
Map<Long,List<SystemAbility>> funMapIdMap = this.findSystemAbilityGroupMapId();
|
||||
@ -124,8 +124,8 @@ public class OldPermissionDataSyncService {
|
||||
insertPermission(syncVOList);
|
||||
insertDistribute(distributeDataVOList);
|
||||
insertUserPermission(psList);
|
||||
File file = outErrorMsg();
|
||||
return file;
|
||||
return SYNC_RESULT_LIST.stream().map(d ->d.toString()).collect(Collectors.toList());
|
||||
|
||||
}catch (Exception e){
|
||||
log.error("用户权限同步失败 msg:" + e.getMessage(),e);
|
||||
throw e;
|
||||
@ -150,25 +150,29 @@ public class OldPermissionDataSyncService {
|
||||
return newList;
|
||||
}
|
||||
|
||||
private File outErrorMsg(){
|
||||
|
||||
BufferedWriter bw = null;
|
||||
try{
|
||||
File file = File.createTempFile("error",".txt");
|
||||
bw = new BufferedWriter(new FileWriter(file));
|
||||
bw.write("------------------------------\n");
|
||||
// bw.write("创建子系统错误【下架】的数据\n");
|
||||
/* private String getErrorMsg(){
|
||||
StringBuilder sb = new StringBuilder("------------------------------\n");
|
||||
// bw.write("创建子系统错误【下架】的数据\n");
|
||||
// bw.write(Joiner.on(",").join(xiajiaList));
|
||||
// bw.write("\n\n");
|
||||
// bw.write("------------------------------\n");
|
||||
// bw.write("创建子系统正常【创建失败】的数据\n");
|
||||
// bw.write(Joiner.on(",").join(zhengchangList));
|
||||
// bw.write("\n\n\n\n");
|
||||
bw.write("------------------------------\n");
|
||||
for (ErrorMsgVO errorMsgVO : SYNC_RESULT_LIST) {
|
||||
bw.write(errorMsgVO.toString());
|
||||
bw.write("\n");
|
||||
}
|
||||
sb.append("------------------------------\n");
|
||||
for (ErrorMsgVO errorMsgVO : SYNC_RESULT_LIST) {
|
||||
sb.append(errorMsgVO.toString());
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}*/
|
||||
/*private File outErrorMsg(){
|
||||
|
||||
BufferedWriter bw = null;
|
||||
try{
|
||||
File file = File.createTempFile("error",".txt");
|
||||
bw = new BufferedWriter(new FileWriter(file));
|
||||
bw.write(this.getErrorMsg());
|
||||
return file;
|
||||
}catch(Exception e){
|
||||
log.error("权限同步统计失败 msg:{}",e.getMessage(),e);
|
||||
@ -182,8 +186,7 @@ public class OldPermissionDataSyncService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
private void insertPermission(List<SyncVO> syncVOList){
|
||||
Set<Long> existPermissSet = Sets.newHashSet();
|
||||
|
@ -15,12 +15,7 @@ public class SyncServiceTest {
|
||||
@Test
|
||||
public void sync(){
|
||||
this.syncService.initData();
|
||||
File file = this.syncService.sync();
|
||||
if(Objects.isNull(file)){
|
||||
this.syncService.sync();
|
||||
|
||||
}else{
|
||||
System.out.println(file.getPath());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user