Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
修复了一些BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
easepan committed Mar 15, 2018
1 parent 379ecfa commit 07137a9
Show file tree
Hide file tree
Showing 12 changed files with 1,687 additions and 32 deletions.
46 changes: 34 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,50 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>com.zhazhapan.efo.EfoApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.zhazhapan.efo.EfoApplication</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
<goal>single</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.zhazhapan.efo.EfoApplication</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/com/zhazhapan/efo/interceptor/WebInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
level = interceptor.value();
}
}
if (level != InterceptorLevel.NONE) {
User user = (User) request.getSession().getAttribute(ValueConsts.USER_STRING);
if (Checker.isNull(user)) {
//读取token,自动登录
Cookie cookie = HttpUtils.getCookie(ValueConsts.TOKEN_STRING, request.getCookies());
if (Checker.isNotNull(cookie)) {
user = userService.login(ValueConsts.EMPTY_STRING, ValueConsts.EMPTY_STRING, cookie.getValue(),
response);
if (Checker.isNotNull(user)) {
request.getSession().setAttribute(ValueConsts.USER_STRING, user);
}
User user = (User) request.getSession().getAttribute(ValueConsts.USER_STRING);
if (Checker.isNull(user)) {
//读取token,自动登录
Cookie cookie = HttpUtils.getCookie(ValueConsts.TOKEN_STRING, request.getCookies());
if (Checker.isNotNull(cookie)) {
user = userService.login(ValueConsts.EMPTY_STRING, ValueConsts.EMPTY_STRING, cookie.getValue(),
response);
if (Checker.isNotNull(user)) {
request.getSession().setAttribute(ValueConsts.USER_STRING, user);
}
}
}
if (level != InterceptorLevel.NONE) {
boolean isRedirect = Checker.isNull(user) || (level == InterceptorLevel.ADMIN && user.getPermission() <
2) || (level == InterceptorLevel.SYSTEM && user.getPermission() < 3);
if (isRedirect) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void removeByFileId(long fileId) {
downloadDAO.removeByFileId(fileId);
}

@SuppressWarnings("unchecked")
@Override
public List<DownloadRecord> getAll(String user, String file, String category, int offset) {
return (List<DownloadRecord>) ServiceUtils.invokeFileFilter(downloadDAO, "getDownloadedBy", user, file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ public long getFileId(String localUrl) {
}
}

@SuppressWarnings("unchecked")
@Override
public List<FileBasicRecord> getBasicAll(String user, String file, String category, int offset) {
return (List<FileBasicRecord>) ServiceUtils.invokeFileFilter(fileDAO, "getBasicBy", user, file, category,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.zhazhapan.efo.service.impl;

import com.zhazhapan.efo.dao.UploadedDAO;
import com.zhazhapan.efo.model.DownloadRecord;
import com.zhazhapan.efo.model.FileBasicRecord;
import com.zhazhapan.efo.model.UploadedRecord;
import com.zhazhapan.efo.service.IUploadedService;
import com.zhazhapan.efo.util.ServiceUtils;
Expand All @@ -23,6 +21,7 @@ public class UploadedServiceImpl implements IUploadedService {
@Autowired
public UploadedServiceImpl(UploadedDAO uploadedDAO) {this.uploadedDAO = uploadedDAO;}

@SuppressWarnings("unchecked")
@Override
public List<UploadedRecord> getAll(String user, String file, String category, int offset) {
return (List<UploadedRecord>) ServiceUtils.invokeFileFilter(uploadedDAO, "getUploadedBy", user, file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ public String updateConfig(String config) {
User user = (User) request.getSession().getAttribute(ValueConsts.USER_STRING);
if (user.getPermission() > ValueConsts.TWO_INT) {
EfoApplication.settings.setJsonObject(config);
//打包成jar之后无法修改config.json文件
try {
FileExecutor.saveFile(NetUtils.urlToString(EfoApplication.class.getResource(DefaultValues
.SETTING_PATH)), EfoApplication.settings.toString());
} catch (IOException e) {
logger.error(e.getMessage());
return "{\"message\":\"internal error\"}";
return "{\"message\":\"internal error, cannot save\"}";
}
return "{\"message\":\"saved successfully\"}";
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ spring.servlet.multipart.max-file-size=1099511627776
spring.servlet.multipart.max-request-size=1099511627776
spring.devtools.restart.enabled=false
spring.devtools.restart.additional-paths=src/main
spring.profiles.active=production
#spring.profiles.active=prod
#spring.mvc.favicon.enabled=false
3 changes: 2 additions & 1 deletion src/main/resources/assets/js/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $("#file-input").fileinput({
uploadUrl: "/file",
uploadAsync: true,
maxFileCount: 100,
previewFileType: ['image', 'html', 'text', 'video', 'audio', 'flash'],
uploadExtraData: function () {
return {
categoryId: $("#category-id").val(),
Expand All @@ -10,7 +11,7 @@ $("#file-input").fileinput({
prefix: getQuery("prefix")
};
},
maxFilePreviewSize: 10485760
maxFilePreviewSize: 51200
}).on('fileuploaded', function (event, data, previewId, index) {
var json = data.response;
if (json.status === "success") {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"description": "用户名只能使用长度为4到16位的英文字母和数字,且必须以字母开始"
},
"defaultAuth": {
"isDownloadable": false,
"isDownloadable": true,
"isUploadable": true,
"isDeletable": false,
"isUpdatable": false,
Expand Down
Loading

0 comments on commit 07137a9

Please sign in to comment.