10 Commits
Author SHA1 Message Date
hellohao f02d865389 适配WebDAV ing 2024-01-22 22:19:07 +08:00
tiansh 48b0e1c5ca add:新增webdav相关功能 2024-01-22 17:34:47 +08:00
tiansh a04bbc1ea6 📝 2024-01-22 11:26:06 +08:00
tiansh 31b4426c10 📝 2024-01-22 11:13:26 +08:00
tiansh 766c125673 📝 2024-01-22 11:12:27 +08:00
tiansh 0de7e0e0fc 📝 2024-01-22 11:10:06 +08:00
tiansh f24a2d5557 📝 2024-01-22 11:09:21 +08:00
tiansh 87394258ad 📝 2024-01-22 11:08:40 +08:00
hello-hao 89a66a17b3 📝 2024-01-11 17:42:23 +08:00
hello-hao 3e4c90c8d9 :bug:修复上传失败问题 2024-01-11 17:03:48 +08:00
17 changed files with 340 additions and 143 deletions
+19 -23
View File
@@ -1,12 +1,23 @@
# Hellohao图像托管程序 - 也许这会是最优秀的图程序
![宣传图Banner](https://upload.cc/i1/2022/02/11/HSg5tX.png)
# Hellohao图像托管 - 也许这会是最优秀的图像托管程序
<p align="center">
<a href="https://www.hellohao.cn/" target="_blank">
<img width="1920px" src="https://upload.cc/i1/2022/02/11/HSg5tX.png">
</a>
</p>
![Visual Studio Marketplace Rating (Stars)](https://img.shields.io/visual-studio-marketplace/stars/ritwickdey.LiveServer?style=flat-square)
![https://img.shields.io/badge/license-AGPL-blue.svg?style=flat-square](https://img.shields.io/badge/license-AGPL-blue.svg?longCache=true&style=flat-square)
![https://img.shields.io/badge/license-AGPL-blue.svg?style=flat-square](https://img.shields.io/badge/license-AGPL-blue.svg?longCache=true&style=flat-square)
![https://img.shields.io/badge/language-java-orange.svg?style=flat-square](https://img.shields.io/badge/language-java-yellow.svg?longCache=true&style=popout-square)
<h3 align="center">赞助商</h3>
<p align="center">
<a href="https://www.eltyun.com/" target="_blank">
<img width="350px" src="https://t.tdo.ink/hellohao/s9ugmihq.png">
</a>
</p>
>:exclamation: 托管的所有开源代码可能存在作者修改/测试/调整等行为,均为实验性代码,故并不保证程序或功能的可用性,如果你想要部署程序,请下载我们提供的编译整合包进行安装部署。
@@ -27,21 +38,12 @@
[Core版](https://hellohao.cn):开源版的基础上增加`Backblaze(B2)` 并且可`同个对象存储商家`可开多个存储源(可添加至90+存储源)
### 更新日志 `20240102`
- 重构:相册页面UI显示效果
- 新增:相册页支持拖拽移动目录并支持了目录相互移动
- 新增:删除功能新增了强制删除选项
- 优化:大图片上传逻辑判断及展示效果
- 调整:用户个人信息失效时间,提高用户体验
- 调整:去除前端浏览器控制台输出Slogan
- 优化:七牛云存储源兼容了新地区的对接
- 优化:用户体验操作或提示
- 优化:系统处理图片的逻辑
### 更新日志 `20240111`
[^_^]: 程序宣传视频:[自制宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/)
- 修复本地存储源上传失败的情况
- 修复某些存储源目录创建不正确的问题
- 优化页面部分提示
### 主要功能
@@ -170,12 +172,6 @@
![站点设置](https://upload.cc/i1/2022/02/11/Hj7pWM.png)
[^_^]: ![首页](http://img.wwery.com/Hellohao/xI9TSKcI.png)
[^_^]: ![控制台详情](http://img.wwery.com/Hellohao/klytOMWr.png)
[^_^]: ![相册](http://img.wwery.com/Hellohao/2UQkXTHw.png)
[^_^]: ![多存储源](http://img.wwery.com/Hellohao/xXSMlsTg.png)
[^_^]: ![站点设置](http://img.wwery.com/Hellohao/n5zXistG.png)
### 桌面客户端(win/mac)
> 获取地址:[官网获取](https://www.hellohao.cn/app)
+11 -1
View File
@@ -130,7 +130,17 @@
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.5.1</version>
</dependency>
<!-- webdav-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>com.github.lookfirst</groupId>
<artifactId>sardine</artifactId>
<version>5.10</version>
</dependency>
<dependency>
<groupId>com.baidu.aip</groupId>
<artifactId>java-sdk</artifactId>
@@ -44,7 +44,7 @@ public class IndexController {
@Autowired private IRedisService iRedisService;
@Autowired private AppClientService appClientService;
public static String version = "20240102";
public static String version = "20240111";
@RequestMapping(value = "/")
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
model.addAttribute("name", "服务端程序(开源版)");
@@ -22,6 +22,10 @@ public interface ImgMapper {
Images selectByPrimaryKey(@Param("id") Long id);
Images selectImgByBrieflink(@Param("brieflink") String brieflink);
Images selectImgByShortlink(@Param("shortlink") String shortlink);
Integer counts(@Param("userid") Integer userid);
Integer setImg(Images images);
@@ -39,6 +39,8 @@ public class Images {
private String idname;
private Integer isRepeat;//如果没有开启查重的时候他是0,开启为1
private String searchname;
private String brieflink;
private String shortlink;
private String order;
}
+1
View File
@@ -14,5 +14,6 @@ public class Keys {
private Integer storageType;
private String keyname;
private String RootPath;//存入的目录
private Boolean SysTransmit;
}
@@ -3,6 +3,7 @@ package cn.hellohao.service;
import cn.hellohao.pojo.Images;
import cn.hellohao.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -21,6 +22,10 @@ public interface ImgService {
Images selectByPrimaryKey(Long id);
Images selectImgByBrieflink(String brieflink);
Images selectImgByShortlink(String shortlink);
Integer counts(Integer userid);
Integer setImg(Images images);
@@ -132,9 +132,10 @@ public class ClientService {
Images imgObj = new Images();
String imgnameEd = null;
Map<Map<String, String>, File> map = new HashMap<>();
String shortUuid_y = SetText.getShortUuid();
String shortUuid_s = SetText.getShortUuid();
if (file.exists()) {
Map<String, String> m1 = new HashMap<>();
String shortUuid_y = SetText.getShortUuid();
m1.put("prefix", prefix);
m1.put("name", shortUuid_y);
map.put(m1, file);
@@ -167,6 +168,8 @@ public class ClientService {
imgObj.setMd5key(md5key);
imgObj.setImguid(imguid);
imgObj.setFormat(fileMiME.getData().toString());
imgObj.setShortlink(shortUuid_y);
imgObj.setBrieflink(shortUuid_s);
imgObj.setIdname(imageFileName);
Msg insertRet = imgServiceImpl.insertImgDataForCheck(imgObj,u,confdata,file.getName());
if (insertRet.getCode().equals("000")) {
@@ -46,6 +46,16 @@ public class ImgServiceImpl implements ImgService {
return imgMapper.selectByPrimaryKey(id);
}
@Override
public Images selectImgByBrieflink(String brieflink) {
return imgMapper.selectImgByBrieflink(brieflink);
}
@Override
public Images selectImgByShortlink(String shortlink) {
return imgMapper.selectImgByShortlink(shortlink);
}
@Override
public Integer counts(Integer userid) {
// TODO Auto-generated method stub
@@ -131,10 +141,9 @@ public class ImgServiceImpl implements ImgService {
if(sysConfig.getCheckduplicate().equals("1")){
//查重
Images img = new Images();
img.setUserid(user.getId());
img.setUserid(user==null?0:user.getId());
img.setMd5key(images.getMd5key());
List<Images> list = imgMapper.selectImgUrlByMD5(img);
jsonObject.put("url", list.get(0).getImgurl());
if (list.size() > 0) {
jsonObject.put("url", list.get(0).getImgurl());
jsonObject.put("name", flilename);
@@ -1,102 +0,0 @@
package cn.hellohao.service.impl;
import cn.hellohao.pojo.Images;
import cn.hellohao.pojo.Keys;
import cn.hellohao.pojo.Msg;
import cn.hellohao.pojo.ReturnImage;
import cn.hellohao.utils.SetText;
import cn.hellohao.utils.TypeDict;
import com.UpYun;
import com.aliyun.oss.model.ObjectMetadata;
import org.springframework.stereotype.Service;
import java.io.File;
import java.util.List;
import java.util.Map;
@Service
public class UFileImageupload1 {
static UpYun uFile;
static Keys key;
/*
* 废弃方法待补位
* */
public ReturnImage ImageuploadUFile(
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
ReturnImage returnImage = new ReturnImage();
File file = null;
ObjectMetadata meta = new ObjectMetadata();
meta.setHeader("Content-Disposition", "inline");
try {
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
String ShortUID = SetText.getShortUuid();
file = entry.getValue();
Msg fileMiME = TypeDict.FileMiME(file);
meta.setHeader("content-type", fileMiME.getData().toString());
uFile.setContentMD5(UpYun.md5(file));
boolean result =
uFile.writeFile(
username + "/" + ShortUID + "." + entry.getKey(), file, true);
if (result) {
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
returnImage.setImgurl(
key.getRequestAddress()
+ "/"
+ username
+ "/"
+ ShortUID
+ "."
+ entry.getKey());
returnImage.setImgSize(entry.getValue().length());
returnImage.setCode("200");
} else {
returnImage.setCode("400");
System.err.println("上传失败");
}
}
} catch (Exception e) {
returnImage.setCode("500");
}
returnImage.setCode("500");
return returnImage;
}
public static Integer Initialize(Keys k) {
int ret = -1;
if (k.getAccessSecret() != null
&& k.getAccessKey() != null
&& k.getBucketname() != null
&& k.getRequestAddress() != null) {
if (!k.getAccessSecret().equals("")
&& !k.getAccessKey().equals("")
&& !k.getBucketname().equals("")
&& !k.getRequestAddress().equals("")) {
UpYun ufObj = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
List<UpYun.FolderItem> items = null;
try {
items = ufObj.readDir("/", null);
ret = 1;
uFile = ufObj;
key = k;
} catch (Exception e) {
System.out.println("UFile Object Is null");
ret = -1;
}
}
}
return ret;
}
public Boolean delUFile(Integer keyID, Images images) {
boolean b = true;
try {
boolean result = uFile.deleteFile(images.getImgname(), null);
} catch (Exception e) {
e.printStackTrace();
b = false;
}
return b;
}
}
@@ -129,13 +129,19 @@ public class UploadServicel {
}
}
}
// 判断路径格式 处理一下,去掉最前面的/
String RootPath = key.getRootPath().replace(" ", "");
if (!RootPath.equals("/")) {
updatePath = RootPath.substring(1) + "/" + updatePath;
}
// 先存数据库
Images imgObj = new Images();
String imgnameEd = null;
Map<Map<String, String>, File> map = new HashMap<>();
String shortUuid_y = SetText.getShortUuid();
String shortUuid_s = SetText.getShortUuid();
if (file.exists()) {
Map<String, String> m1 = new HashMap<>();
String shortUuid_y = SetText.getShortUuid();
m1.put("prefix", prefix);
m1.put("name", shortUuid_y);
map.put(m1, file);
@@ -168,6 +174,8 @@ public class UploadServicel {
imgObj.setMd5key(md5key);
imgObj.setImguid(imguid);
imgObj.setFormat(fileMiME.getData().toString());
imgObj.setShortlink(shortUuid_y);
imgObj.setBrieflink(shortUuid_s);
imgObj.setIdname(imgName);
// Integer insertRet = imgMapper.insertImgData(imgObj);
Msg insertRet = imgServiceImpl.insertImgDataForCheck(imgObj,u,confdata,file.getName());
@@ -176,6 +184,7 @@ public class UploadServicel {
}
long stime = System.currentTimeMillis();
System.out.println("上传前地址:"+updatePath);
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
if (returnImage.getCode().equals("200")) {
long etime = System.currentTimeMillis();
@@ -215,7 +224,6 @@ public class UploadServicel {
String md5 = jsonObj.getString("md5");
String classifications = jsonObj.getString("classifications");
Integer day = jsonObj.getInteger("day");
String source = jsonObj.getString("source");
String imgIdentifier = jsonObj.getString("imgIdentifier");
JSONArray jsonArray = new JSONArray();
classifications = classifications==null?"":classifications;
@@ -0,0 +1,226 @@
package cn.hellohao.service.impl;
import cn.hellohao.config.GlobalConstant;
import cn.hellohao.pojo.Images;
import cn.hellohao.pojo.Keys;
import cn.hellohao.pojo.Msg;
import cn.hellohao.pojo.ReturnImage;
import cn.hellohao.service.ImgService;
import cn.hellohao.service.KeysService;
import cn.hellohao.utils.TypeDict;
import com.github.sardine.impl.methods.HttpMkCol;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.*;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.IOException;
import java.util.Map;
@Service
public class WebDAVImageupload {
static CloseableHttpClient httpClient;
static Keys key;
@Autowired
private ImgService imgService;
@Autowired
private KeysService keysService;
private static Logger logger = LoggerFactory.getLogger(WebDAVImageupload.class);
public ReturnImage ImageuploadWebDAV(Map<Map<String, String>, File> fileMap, String username,Integer keyID) {
ReturnImage returnImage = new ReturnImage();
CloseableHttpClient httpClient =null;
Keys key = null;
try {
if(null==httpClient || null==key){
System.out.println("WebDAV = 存储源对象为空");
returnImage.setCode("500");
return returnImage;
}
} catch (Exception e) {
logger.error("ImageuploadWebDAV:61异常",e);
System.out.println("WebDAV = 存储源对象为空");
returnImage.setCode("500");
return returnImage;
}
File file = null;
try {
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
String prefix = entry.getKey().get("prefix");
String ShortUIDName = entry.getKey().get("name");
file = entry.getValue();
Msg fileMiME = TypeDict.FileMiME(file);
//webdav不能自动创建目录,上传件先创建目录
createDirectories(httpClient, key.getEndpoint(), "/" + username);
//上传文件
System.out.println("WebDAV地址:"+key.getEndpoint() + "/" + username + "/" + ShortUIDName + "." + prefix);
HttpPut httpPut = new HttpPut(key.getEndpoint() + "/" + username + "/" + ShortUIDName + "." + prefix);
FileEntity fileEntity = new FileEntity(file, ContentType.DEFAULT_BINARY);
httpPut.setEntity(fileEntity);
HttpResponse response = httpClient.execute(httpPut);
final int statusCode = response.getStatusLine().getStatusCode();
logger.info("WebDav上传响应代码:"+statusCode);
// System.out.println(response.getStatusLine().getStatusCode());//正常成功201 已经存在204(有可能204还代表其他意思)
// System.out.println("File upload response for " + file.getName() + ": " + response.getStatusLine());
EntityUtils.consume(response.getEntity());
// System.out.println(EntityUtils.toString(response.getEntity(),"UTF-8"));
if(statusCode >= 200 && statusCode < 300){
returnImage.setCode("200");
}else{
returnImage.setCode(Integer.toString(statusCode));
}
}
} catch (Exception e) {
logger.error("ImageuploadWebDAV:92异常",e);
returnImage.setCode("500");
}
return returnImage;
}
//webdav初始化
public static Integer Initialize(Keys k) {
int ret = -1;
if(k.getSysTransmit()==false){
if (StringUtils.isBlank(k.getAccessKey())
|| StringUtils.isBlank(k.getAccessSecret())
|| StringUtils.isBlank(k.getEndpoint())
|| StringUtils.isBlank(k.getRequestAddress())) {
return -1;
}
}else{
if (StringUtils.isBlank(k.getAccessKey())
|| StringUtils.isBlank(k.getAccessSecret())
|| StringUtils.isBlank(k.getEndpoint())) {
return -1;
}
}
String endpoint = k.getEndpoint();
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
new UsernamePasswordCredentials(k.getAccessKey(), k.getAccessSecret()));
CloseableHttpClient httpClientObj = HttpClients.custom()
.setDefaultCredentialsProvider(credentialsProvider)
.build();
try {
HttpUriRequest request = RequestBuilder.create("PROPFIND")
.setUri(endpoint +"/"+ k.getRootPath())
.addHeader("Depth", "1")
.setEntity(new StringEntity(
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
"<D:propfind xmlns:D=\"DAV:\">\n" +
" <D:allprop/>\n" +
"</D:propfind>",
ContentType.create("text/xml", "UTF-8")))
.build();
HttpResponse response = httpClientObj.execute(request);
System.out.println("=====>"+response.getStatusLine().getStatusCode());
if(response.getStatusLine().getStatusCode()==207 || response.getStatusLine().getStatusCode()==404){
ret = 1;
httpClient = httpClientObj;
key = k;
}else {
return -1;
}
EntityUtils.consume(response.getEntity());
} catch (Exception e) {
logger.error("WebDAV初始化失败", e);
return -1;
}
return ret;
}
public Boolean delWebDAV(Integer keyID, Images images) {
boolean b = true;
try {
Keys keys = keysService.selectKeys(images.getSource());
String rootPath = keys.getRootPath().equals("/")?"":keys.getRootPath();
String fileUrl = keys.getEndpoint()+"/"+images.getImgname();
System.err.println("删除缩yuan图:"+fileUrl);
HttpDelete httpDelete = new HttpDelete(fileUrl);
HttpResponse response = httpClient.execute(httpDelete);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 204) {
logger.info("File deleted: " + fileUrl);
// checkAndDeleteEmptyParentDirectories(httpClient,fileUrl);
} else {
logger.error("Failed to delete file: " + fileUrl);
}
EntityUtils.consume(response.getEntity());
} catch (Exception e) {
logger.error("WebDav删除异常:",e);
b = false;
}
return b;
}
public ResponseEntity<InputStreamResource> getWebDAV(String shortUuid) {
boolean b = true;
try {
Images images = null;
images = imgService.selectImgByShortlink(shortUuid);
Keys keys = keysService.selectKeys(images.getSource());
String rootPath = keys.getRootPath().equals("/")?"":keys.getRootPath();
String fileUrl = keys.getEndpoint()+"/"+images.getImgname();
HttpGet httpGet = new HttpGet(fileUrl);
HttpResponse response = httpClient.execute(httpGet);
// if (sardine.exists(keys.getEndpoint() + images.getImgname())) {
// InputStream inputStream = sardine.get(keys.getEndpoint() + images.getImgname());
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "image/jpeg");
// headers.add("Content-disposition", "attachment; filename=wallhaven-5g6yr3.jpg");
return ResponseEntity.ok()
.headers(headers)
//.header("Content-disposition", "attachment; filename=Nextcloud.png")
// .header("Content-Type", "image/jpg")
.body(new InputStreamResource(response.getEntity().getContent()));
// } else {
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
// }
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}
private static void createDirectories(CloseableHttpClient httpClient, String baseUrl, String directoryPath) throws Exception {
String[] directories = directoryPath.split("/");
String currentPath = baseUrl;
for (String directory : directories) {
currentPath += directory + "/";
HttpMkCol httpMkCol = new HttpMkCol(currentPath);
HttpResponse response = httpClient.execute(httpMkCol);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == 201) {
System.out.println("Directory created: " + currentPath);
} else if (statusCode == 405) {
System.out.println("Directory already exists: " + currentPath);
} else {
System.err.println("Failed to create directory: " + currentPath);
}
EntityUtils.consume(response.getEntity());
}
}
}
+29 -5
View File
@@ -111,6 +111,30 @@ public class FirstRun implements InitializingBean {
RunSqlScript.RunInsert(instartConfdata);
Print.Normal("Add table.confdata");
}
Integer ret7 =
RunSqlScript.RunSelectCount(judgeTable + " 'keys' and column_name = 'SysTransmit'");
if (ret7 == 0) {
RunSqlScript.RunInsert(sql7);
Print.Normal("Add keys.SysTransmit");
}
Integer ret8 =
RunSqlScript.RunSelectCount(judgeTable + " 'imgdata' and column_name = 'brieflink'");
if (ret8 == 0) {
RunSqlScript.RunInsert(sql8);
Print.Normal("Add imgdata.brieflink");
}
Integer ret9 =
RunSqlScript.RunSelectCount(judgeTable + " 'imgdata' and column_name = 'shortlink'");
if (ret9 == 0) {
RunSqlScript.RunInsert(sql9);
Print.Normal("Add imgdata.shortlink");
}
Integer ret10 =
RunSqlScript.RunSelectCount(" select count(*) from tbed.keys where storageType='9'");
if (ret10 == 0) {
RunSqlScript.RunInsert(sql10);
Print.Normal("Add Webdav Config");
}
RunSqlScript.RunInsert(index_imgdata);
RunSqlScript.RunInsert("ALTER TABLE tbed.`user` MODIFY id int auto_increment;");
Print.Normal("Stage success");
@@ -130,12 +154,12 @@ public class FirstRun implements InitializingBean {
private String sql3 ="CREATE TABLE `imgandalbum` (`imgname` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
private String sql4 ="CREATE TABLE `album` (`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumtitle` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`createdate` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `password` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
private String sql6 = "alter table imgdata add explains varchar(5000)";
//添加album表字段userid
private String sql7 = "alter table album add userid int(10)";
//添加imgdata表字段md5key
private String sql8 = "alter table imgdata add md5key varchar(5000)";
private String sql7 =
"alter table `keys` add SysTransmit varchar(50) DEFAULT NULL ;";
private String sql8 = "alter table `imgdata` add brieflink varchar(100) DEFAULT null ;";
private String sql9 = "alter table `imgdata` add shortlink varchar(100) DEFAULT null ;";
// 图片标识名字段
private String sql11 = "alter table `imgdata` add idname varchar(255) DEFAULT '未命名' ;";
private String sql10 = "INSERT INTO `tbed`.`keys`(`id`, `AccessKey`, `AccessSecret`, `Endpoint`, `Bucketname`, `RequestAddress`, `storageType`, `keyname`, `Region`, `RootPath`, `SysTransmit`) VALUES (null, '账号', '密码', '连接', '', '存储源请求域名', 9, 'WebDAV', NULL, '/', NULL);";
private String sql12 = "alter table tbed.user add `token` varchar(255)";
//创建客户端程序相关表
@@ -39,8 +39,6 @@ public class GetCurrentSource {
userService = userServiceImpl;
}
public static Group GetSource(Integer userid) {
//UserType 0-未分配 1-游客 2-用户 3-管理员
User user =null;
@@ -51,6 +51,8 @@ public class GetSource {
returnImage = ftpService.FtpUploadFile(fileMap, userpath,keyID);
}else if(type==8){
returnImage = s3Imageupload.ImageuploadS3(fileMap, userpath,keyID);
}else if(type==9){
returnImage = s3Imageupload.ImageuploadS3(fileMap, userpath,keyID);
}
else{
new StorageSourceInitException("GetSource类捕捉异常:未找到存储源");
+12 -3
View File
@@ -126,13 +126,14 @@
`format`,
about,
violation,
idname
idname,
brieflink,
shortlink
)
VALUES (null, #{imgname}, #{imgurl}, #{userid}, #{updatetime},#{sizes},#{abnormal},#{source},#{imgtype},
#{explains},#{md5key},#{imguid},#{format},#{about},null,#{idname})
#{explains},#{md5key},#{imguid},#{format},#{about},null,#{idname},#{brieflink},#{shortlink})
</insert>
<!-- 此用户下总数 -->
<select id="countimg" parameterType="integer" resultType="integer">
select count(*) from imgdata where userid = #{userid}
@@ -150,6 +151,14 @@
select * from imgdata where id = #{id}
</select>
<select id="selectImgByBrieflink" parameterType="string" resultType="cn.hellohao.pojo.Images">
select * from imgdata where binary brieflink = #{brieflink}
</select>
<select id="selectImgByShortlink" parameterType="string" resultType="cn.hellohao.pojo.Images">
select * from imgdata where binary shortlink = #{shortlink}
</select>
<select id="counts" resultType="integer">
select count(*) from imgdata where 1=1
<if test="userid != null">
+3 -1
View File
@@ -28,6 +28,7 @@
WHEN storageType=6 THEN '腾讯云'
WHEN storageType=7 THEN 'FTP'
WHEN storageType=8 THEN 'S3协议'
WHEN storageType=9 THEN 'WebDAV'
ELSE '未知' END AS storageName,
keyname
FROM `keys` GROUP BY storageType,id,storageName,keyname
@@ -51,7 +52,8 @@
RequestAddress = #{RequestAddress},
keyname = #{keyname},
Region = #{Region},
RootPath = #{RootPath}
RootPath = #{RootPath},
SysTransmit=#{SysTransmit}
WHERE
storageType = #{storageType}
</update>