代码优化

This commit is contained in:
马超 2020-10-06 22:55:25 +08:00
parent 199bb81633
commit 4c9a3bcbe2
6 changed files with 19 additions and 51 deletions

View File

@ -8,6 +8,16 @@ import org.springframework.stereotype.Component;
public class QiwenFileConfig {
private boolean remoteLogin;
private boolean shareMode;
public boolean isShareMode() {
return shareMode;
}
public void setShareMode(boolean shareMode) {
this.shareMode = shareMode;
}
public boolean isRemoteLogin() {
return remoteLogin;
}

View File

@ -36,11 +36,6 @@ public class FileController {
@Autowired
QiwenFileConfig qiwenFileConfig;
/**
* 是否开启共享文件模式
*/
public static Boolean isShareFile = true;
public static long treeid = 0;
/**
@ -123,7 +118,7 @@ public class FileController {
@ResponseBody
public RestResult<List<FileBean>> getFileList(FileBean fileBean, @RequestHeader("token") String token){
RestResult<List<FileBean>> restResult = new RestResult<>();
if(isShareFile){
if(qiwenFileConfig.isShareMode()){
fileBean.setUserId(2L);
}else {
//UserBean sessionUserBean = (UserBean) SecurityUtils.getSubject().getPrincipal();
@ -365,7 +360,7 @@ public class FileController {
result.setErrorMessage("未登录");
return result;
}
if (isShareFile){
if (qiwenFileConfig.isShareMode()){
if (sessionUserBean.getUserId() > 2){
result.setSuccess(false);
result.setErrorMessage("没权限,请联系管理员!");
@ -396,7 +391,7 @@ public class FileController {
sessionUserBean = (UserBean) SecurityUtils.getSubject().getPrincipal();
}
long userId = sessionUserBean.getUserId();
if (isShareFile){
if (qiwenFileConfig.isShareMode()){
userId = 2;
}
List<FileBean> file = fileService.selectFileByExtendName(getFileExtendsByType(fileBean.getFileType()), userId);
@ -424,7 +419,7 @@ public class FileController {
} else {
sessionUserBean = (UserBean) SecurityUtils.getSubject().getPrincipal();
}
if (isShareFile){
if (qiwenFileConfig.isShareMode()){
fileBean.setUserId(2L);
}else{
fileBean.setUserId(sessionUserBean.getUserId());

View File

@ -29,8 +29,6 @@ public class FiletransferController {
@Resource
IFiletransferService filetransferService;
@Resource
IFileService fileService;
@Resource
FileController fileController;
@ -148,7 +146,7 @@ public class FiletransferController {
RestResult<StorageBean> restResult = new RestResult<StorageBean>();
UserBean sessionUserBean = (UserBean) SecurityUtils.getSubject().getPrincipal();
StorageBean storageBean = new StorageBean();
if (FileController.isShareFile){
if (qiwenFileConfig.isShareMode()){
storageBean.setUserId(2L);
}else{
storageBean.setUserId(sessionUserBean.getUserId());

View File

@ -1,35 +0,0 @@
//package com.mac.scp.controller;
//
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.servlet.ModelAndView;
//
///**
// * 用户控制类
// *
// * @author ma116
// */
//@RestController
//public class RouterController {
//
//
// @RequestMapping("/file")
// @ResponseBody
// public ModelAndView file() {
// return new ModelAndView("/file.html");
// }
//
// @RequestMapping("/login")
// @ResponseBody
// public ModelAndView login() {
// return new ModelAndView("/login");
// }
//
// @RequestMapping("/register")
// @ResponseBody
// public ModelAndView register() {
// return new ModelAndView("/register");
// }
//
//}

View File

@ -33,8 +33,7 @@ import java.util.Map;
public class UserController {
@Resource
IUserService userService;
@Resource
IFiletransferService filetransferService;
@Autowired
IRemoteUserService remoteUserService;
@Autowired

View File

@ -1,6 +1,6 @@
server.port=8080
#eureka.client.register-with-eureka=false
#eureka.client.fetchRegistry=false
eureka.client.register-with-eureka=false
eureka.client.fetchRegistry=false
#eureka.client.server.waitTimeInMsWhenSyncEmpty=0
eureka.instance.hostname=localhost
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:8761/eureka/
@ -46,3 +46,4 @@ mybatis-plus.configuration.map-underscore-to-camel-case=false
mybatis-plus.global-config.banner=false
qiwen-file.remote-login=false
qiwen-file.share-mode=false