forked from Eagle-OJ/eagle-oj-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6df64d6
commit 0c59579
Showing
19 changed files
with
443 additions
and
201 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
eagle-oj-web/src/main/java/com/eagleoj/web/controller/IndexController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
eagle-oj-web/src/main/java/com/eagleoj/web/controller/format/admin/AddMailFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.eagleoj.web.controller.format.admin; | ||
|
||
import org.hibernate.validator.constraints.Email; | ||
import org.hibernate.validator.constraints.Length; | ||
import org.hibernate.validator.constraints.Range; | ||
import org.hibernate.validator.constraints.URL; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* @author Smith | ||
**/ | ||
public class AddMailFormat { | ||
|
||
@NotNull | ||
private Boolean isOpenMail; | ||
|
||
@Length(min = 1, max = 255) | ||
private String host; | ||
|
||
@Range(min = 1) | ||
private Integer port; | ||
|
||
@Email(message = "发件人地址非法") | ||
private String username; | ||
|
||
@Length(min = 1, max = 255) | ||
private String password; | ||
|
||
@Email(message = "测试收件人地址非法") | ||
private String testMailAddress; | ||
|
||
public Boolean getOpenMail() { | ||
return isOpenMail; | ||
} | ||
|
||
public void setOpenMail(Boolean openMail) { | ||
isOpenMail = openMail; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
} | ||
|
||
public void setHost(String host) { | ||
this.host = host; | ||
} | ||
|
||
public Integer getPort() { | ||
return port; | ||
} | ||
|
||
public void setPort(Integer port) { | ||
this.port = port; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public String getTestMailAddress() { | ||
return testMailAddress; | ||
} | ||
|
||
public void setTestMailAddress(String testMailAddress) { | ||
this.testMailAddress = testMailAddress; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
eagle-oj-web/src/main/java/com/eagleoj/web/file/FileService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.eagleoj.web.file; | ||
|
||
import com.eagleoj.judge.LanguageEnum; | ||
import com.eagleoj.web.controller.exception.WebErrorException; | ||
import com.eagleoj.web.setting.SettingEnum; | ||
import com.eagleoj.web.setting.SettingService; | ||
import com.eagleoj.web.util.FileUtil; | ||
import com.eagleoj.web.util.WebUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.InputStream; | ||
import java.util.UUID; | ||
|
||
/** | ||
* @author Smith | ||
**/ | ||
@Service | ||
public class FileService { | ||
|
||
@Autowired | ||
private SettingService settingService; | ||
|
||
@Autowired | ||
private FileUtil fileUtil; | ||
|
||
public boolean test(String accessKey, String secretKey, String endPoint, String bucket) { | ||
return fileUtil.test(accessKey, secretKey, endPoint, bucket); | ||
} | ||
|
||
public void refresh() { | ||
fileUtil.refresh(); | ||
} | ||
|
||
public String uploadCode(LanguageEnum lang, String code) { | ||
checkIsOpen(); | ||
String url = fileUtil.uploadCode(lang, code); | ||
WebUtil.assertNotNull(url, "上传代码出错"); | ||
return url; | ||
} | ||
|
||
public String uploadAvatar(InputStream is, String postfix) { | ||
checkIsOpen(); | ||
String url = fileUtil.uploadAvatar(is, postfix); | ||
WebUtil.assertNotNull(url, "上传头像出错"); | ||
return url; | ||
} | ||
|
||
private void checkIsOpen() { | ||
if (! settingService.isOpenStorage()) { | ||
throw new WebErrorException("未开启存储功能"); | ||
} | ||
} | ||
} |
Oops, something went wrong.