mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
add:新增webdav相关功能
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -138,9 +138,10 @@ public class UploadServicel {
|
||||
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);
|
||||
@@ -173,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());
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.auth.v.GlobalConstant;
|
||||
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.Print;
|
||||
import cn.hellohao.utils.TypeDict;
|
||||
import com.aliyun.oss.OSS;
|
||||
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) {
|
||||
CloseableHttpClient httpClient = (CloseableHttpClient)GlobalConstant.KeyMap.get(keyID).getObject();
|
||||
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,String brieflink) {
|
||||
boolean b = true;
|
||||
try {
|
||||
Images images = null;
|
||||
if(StringUtils.isBlank(shortUuid)){
|
||||
images = imgService.selectImgByBrieflink(brieflink);
|
||||
}else{
|
||||
// images = imgService.selectImgUrlByImgUID(imgUID);
|
||||
images = imgService.selectImgByShortlink(shortUuid);
|
||||
}
|
||||
Keys keys = keysService.selectKeys(images.getSource());
|
||||
String rootPath = keys.getRootPath().equals("/")?"":keys.getRootPath();
|
||||
String fileUrl = StringUtils.isBlank(shortUuid)?keys.getEndpoint()+"/"+images.getBriefimgname():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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -111,6 +111,18 @@ public class FirstRun implements InitializingBean {
|
||||
RunSqlScript.RunInsert(instartConfdata);
|
||||
Print.Normal("Add table.confdata");
|
||||
}
|
||||
Integer ret7 =
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'SysTransmit' and column_name = 'keys'");
|
||||
if (ret7 == 0) {
|
||||
RunSqlScript.RunInsert(sql7);
|
||||
Print.Normal("Add keys.SysTransmit");
|
||||
}
|
||||
Integer ret8 =
|
||||
RunSqlScript.RunSelectCount(judgeTable + " 'brieflink' and column_name = 'imgdata'");
|
||||
if (ret8 == 0) {
|
||||
RunSqlScript.RunInsert(sql8);
|
||||
Print.Normal("Add imgdata.brieflink");
|
||||
}
|
||||
RunSqlScript.RunInsert(index_imgdata);
|
||||
RunSqlScript.RunInsert("ALTER TABLE tbed.`user` MODIFY id int auto_increment;");
|
||||
Print.Normal("Stage success");
|
||||
@@ -130,10 +142,9 @@ 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 sql11 = "alter table `imgdata` add idname varchar(255) DEFAULT '未命名' ;";
|
||||
|
||||
|
||||
@@ -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类捕捉异常:未找到存储源");
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user