mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
📝
This commit is contained in:
@@ -13,6 +13,8 @@ public interface ImgMapper {
|
||||
|
||||
List<Images> selectimg(Images images);
|
||||
|
||||
Integer insertImgData(Images images);
|
||||
|
||||
Integer countimg(@Param("userid") Integer userid);
|
||||
|
||||
Integer deleimg(@Param("id") Integer id);
|
||||
|
||||
@@ -35,8 +35,8 @@ public class Images {
|
||||
private String yyyy;
|
||||
private String[] classifuidlist; //类别uid集合
|
||||
private String classificationuid; //类别uid集合
|
||||
|
||||
private String idname;
|
||||
private Integer isRepeat;//如果没有开启查重的时候他是0,开启为1
|
||||
|
||||
public Images() {
|
||||
super();
|
||||
@@ -56,7 +56,8 @@ public class Images {
|
||||
Integer imgtype, String updatetime, String username, Integer storageType, String starttime, String stoptime,
|
||||
String explains, String md5key, String notes, String useridlist, String imguid, String albumtitle,
|
||||
String password, Integer selecttype,Long countNum,Integer monthNum,String yyyy,
|
||||
String format,String about,Integer great,String[] classifuidlist,String classificationuid,String violation,String idname) {
|
||||
String format,String about,Integer great,String[] classifuidlist,String classificationuid,String violation,
|
||||
String idname,Integer isRepeat) {
|
||||
this.id = id;
|
||||
this.imgname = imgname;
|
||||
this.imgurl = imgurl;
|
||||
@@ -88,6 +89,7 @@ public class Images {
|
||||
this.classificationuid = classificationuid;
|
||||
this.violation = violation;
|
||||
this.idname = idname;
|
||||
this.isRepeat = isRepeat;
|
||||
|
||||
}
|
||||
|
||||
@@ -339,6 +341,14 @@ public class Images {
|
||||
public void setIdname(String idname) {
|
||||
this.idname = idname;
|
||||
}
|
||||
|
||||
public Integer getIsRepeat() {
|
||||
return isRepeat;
|
||||
}
|
||||
|
||||
public void setIsRepeat(Integer isRepeat) {
|
||||
this.isRepeat = isRepeat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import org.springframework.stereotype.Service;
|
||||
public interface ImgService {
|
||||
List<Images> selectimg(Images images);
|
||||
|
||||
Integer insertImgData(Images images);
|
||||
|
||||
Integer deleimg(Integer id);
|
||||
|
||||
Integer deleimgForImgUid(String imguid);
|
||||
|
||||
@@ -20,6 +20,11 @@ public class ImgServiceImpl implements ImgService {
|
||||
return imgMapper.selectimg(images);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer insertImgData(Images images) {
|
||||
return imgMapper.insertImgData(images);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleimg(Integer id) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -33,7 +33,7 @@ public class KODOImageupload {
|
||||
static BucketManager bucketManager;
|
||||
static Keys key;
|
||||
|
||||
public ReturnImage ImageuploadKODO(Map<String, File> fileMap, String username, Integer keyID){
|
||||
public ReturnImage ImageuploadKODO(Map<Map<String, String>, File> fileMap, String username, Integer keyID){
|
||||
ReturnImage returnImage = new ReturnImage();
|
||||
Configuration cfg;
|
||||
if (key.getEndpoint().equals("1")) {
|
||||
@@ -49,19 +49,20 @@ public class KODOImageupload {
|
||||
}
|
||||
UploadManager uploadManager = new UploadManager(cfg);
|
||||
Auth auth = Auth.create(key.getAccessKey(), key.getAccessSecret());
|
||||
String upToken = auth.uploadToken(key.getBucketname(),null,7200,null);
|
||||
String upToken = auth.uploadToken(key.getBucketname(), null, 7200, null);
|
||||
File file = null;
|
||||
try {
|
||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
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();
|
||||
try {
|
||||
Response response = uploadManager.put(file,username + "/" + ShortUID + "." + entry.getKey(),upToken);
|
||||
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
||||
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
|
||||
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
|
||||
returnImage.setImgSize(entry.getValue().length());
|
||||
returnImage.setCode("200");
|
||||
Response response =
|
||||
uploadManager.put(
|
||||
file, username + "/" + ShortUIDName + "." + prefix, upToken);
|
||||
DefaultPutRet putRet =
|
||||
new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
||||
|
||||
} catch (QiniuException ex) {
|
||||
returnImage.setCode("400");
|
||||
Response r = ex.response;
|
||||
@@ -72,7 +73,8 @@ public class KODOImageupload {
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
returnImage.setCode("200");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("500");
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.netease.cloud.auth.BasicCredentials;
|
||||
import com.netease.cloud.auth.Credentials;
|
||||
import com.netease.cloud.services.nos.NosClient;
|
||||
import com.netease.cloud.services.nos.model.ObjectListing;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
@@ -18,20 +19,19 @@ public class NOSImageupload {
|
||||
static NosClient nosClient;
|
||||
static Keys key;
|
||||
|
||||
public ReturnImage Imageupload(Map<String, File> fileMap, String username,Integer keyID){
|
||||
public ReturnImage Imageupload(Map<Map<String, String>, File> fileMap, String username,Integer keyID){
|
||||
ReturnImage returnImage = new ReturnImage();
|
||||
File file = null;
|
||||
try {
|
||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
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();
|
||||
nosClient.putObject(key.getBucketname(), username + "/" + ShortUID+ "." + entry.getKey(), file);
|
||||
returnImage.setImgname(username + "/" + ShortUID+ "." + entry.getKey());
|
||||
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
|
||||
returnImage.setImgSize(entry.getValue().length());
|
||||
returnImage.setCode("200");
|
||||
nosClient.putObject(
|
||||
key.getBucketname(), username + "/" + ShortUIDName + "." + prefix, file);
|
||||
}
|
||||
}catch (Exception e){
|
||||
returnImage.setCode("200");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("500");
|
||||
}
|
||||
@@ -42,25 +42,25 @@ public class NOSImageupload {
|
||||
|
||||
public static Integer Initialize(Keys k) {
|
||||
int ret = -1;
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ){
|
||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ){
|
||||
// 初始化
|
||||
Credentials credentials = new BasicCredentials(k.getAccessKey(), k.getAccessSecret());
|
||||
NosClient nosObj = new NosClient(credentials);
|
||||
nosObj.setEndpoint(k.getEndpoint());
|
||||
ObjectListing objectListing = null;
|
||||
try {
|
||||
objectListing = nosObj.listObjects(k.getBucketname());
|
||||
ret = 1;
|
||||
nosClient = nosObj;
|
||||
key = k;
|
||||
}catch (Exception e){
|
||||
System.out.println("NOS Object Is null");
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(k.getAccessKey())
|
||||
|| StringUtils.isBlank(k.getAccessSecret())
|
||||
|| StringUtils.isBlank(k.getEndpoint())
|
||||
|| StringUtils.isBlank(k.getBucketname())
|
||||
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||
return -1;
|
||||
}
|
||||
Credentials credentials = new BasicCredentials(k.getAccessKey(), k.getAccessSecret());
|
||||
NosClient nosObj = new NosClient(credentials);
|
||||
nosObj.setEndpoint(k.getEndpoint());
|
||||
ObjectListing objectListing = null;
|
||||
try {
|
||||
objectListing = nosObj.listObjects(k.getBucketname());
|
||||
ret = 1;
|
||||
nosClient = nosObj;
|
||||
key = k;
|
||||
}catch (Exception e){
|
||||
System.out.println("NOS Object Is null");
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.utils.SetText;
|
||||
import cn.hellohao.utils.TypeDict;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.ObjectListing;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
@@ -20,31 +22,32 @@ public class OSSImageupload {
|
||||
static OSS ossClient;
|
||||
static Keys key;
|
||||
|
||||
public ReturnImage ImageuploadOSS(Map<String, File> fileMap, String username,Integer keyID){
|
||||
public ReturnImage ImageuploadOSS(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<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss");
|
||||
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);
|
||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
||||
System.out.println("待上传的图片:"+username + "/" + ShortUID + "." + entry.getKey());
|
||||
ossClient.putObject(key.getBucketname(), username + "/" + ShortUID + "." + entry.getKey(),file);
|
||||
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename()
|
||||
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
|
||||
returnImage.setImgSize(file.length());
|
||||
returnImage.setCode("200");
|
||||
PutObjectRequest putObjectRequest =
|
||||
new PutObjectRequest(
|
||||
key.getBucketname(),
|
||||
username + "/" + ShortUIDName + "." + prefix,
|
||||
file,
|
||||
meta);
|
||||
ossClient.putObject(putObjectRequest);
|
||||
}
|
||||
}catch (Exception e){
|
||||
returnImage.setCode("200");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("500");
|
||||
}
|
||||
return returnImage;
|
||||
|
||||
}
|
||||
|
||||
public static Integer Initialize(Keys k) {
|
||||
|
||||
@@ -18,30 +18,30 @@ public class USSImageupload {
|
||||
static UpYun upyun;
|
||||
static Keys key;
|
||||
|
||||
public ReturnImage ImageuploadUSS(Map<String, File> fileMap, String username,Integer keyID) {
|
||||
public ReturnImage ImageuploadUSS(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<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
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);
|
||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
||||
upyun.setContentMD5(UpYun.md5(file));
|
||||
boolean result = upyun.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");
|
||||
boolean result =
|
||||
upyun.writeFile(username + "/" + ShortUIDName + "." + prefix, file, true);
|
||||
if (result) {
|
||||
|
||||
} else {
|
||||
System.err.println("上传失败");
|
||||
returnImage.setCode("400");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
returnImage.setCode("200");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("500");
|
||||
}
|
||||
|
||||
@@ -46,12 +46,13 @@ public class UploadServicel {
|
||||
ImgreviewMapper imgreviewMapper;
|
||||
@Autowired
|
||||
ImgTempService imgTempService;
|
||||
|
||||
@Autowired private KeysServiceImpl keysService;
|
||||
|
||||
public Msg uploadForLoc(HttpServletRequest request,
|
||||
MultipartFile multipartFile, Integer setday, String imgUrl) {
|
||||
Msg msg = new Msg();
|
||||
try{
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
|
||||
String userip = GetIPS.getIpAddr(request);
|
||||
@@ -110,19 +111,19 @@ public class UploadServicel {
|
||||
if(md5key==null || md5key.equals("")){
|
||||
md5key = UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1){
|
||||
Images imaOBJ = new Images();
|
||||
imaOBJ.setMd5key(md5key);
|
||||
imaOBJ.setUserid(u==null?0:u.getId());
|
||||
if(imgMapper.md5Count(imaOBJ)>0){
|
||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
||||
jsonObject.put("url", images.get(0).getImgurl());
|
||||
jsonObject.put("name",file.getName());
|
||||
jsonObject.put("imguid",images.get(0).getImguid());
|
||||
msg.setData(jsonObject);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
// if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1){
|
||||
// Images imaOBJ = new Images();
|
||||
// imaOBJ.setMd5key(md5key);
|
||||
// imaOBJ.setUserid(u==null?0:u.getId());
|
||||
// if(imgMapper.md5Count(imaOBJ)>0){
|
||||
// List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
||||
// jsonObject.put("url", images.get(0).getImgurl());
|
||||
// jsonObject.put("name",file.getName());
|
||||
// jsonObject.put("imguid",images.get(0).getImguid());
|
||||
// msg.setData(jsonObject);
|
||||
// return msg;
|
||||
// }
|
||||
// }
|
||||
String prefix = file.getName().substring(file.getName().lastIndexOf(".")+1);
|
||||
//判断黑名单
|
||||
if (uploadConfig.getBlacklist() != null) {
|
||||
@@ -136,43 +137,78 @@ public class UploadServicel {
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, File> map = new HashMap<>();
|
||||
// 先存数据库
|
||||
final Images imgObj = new Images();
|
||||
String imgnameEd = null;
|
||||
final Map<Map<String, String>, File> map = new HashMap<>();
|
||||
if (file.exists()) {
|
||||
map.put(prefix, file);//prefix
|
||||
Map<String, String> m1 = new HashMap<>();
|
||||
String shortUuid_y = SetText.getShortUuid();
|
||||
m1.put("prefix", prefix);
|
||||
m1.put("name", shortUuid_y);
|
||||
map.put(m1, file);
|
||||
|
||||
// map.put(prefix, file);
|
||||
imgnameEd = updatePath + "/" + shortUuid_y + "." + prefix;
|
||||
imgObj.setImgname(imgnameEd);
|
||||
if(key.getStorageType().equals(5)){
|
||||
imgObj.setImgurl(key.getRequestAddress() + "/ota/" + imgnameEd);
|
||||
}else {
|
||||
imgObj.setImgurl(key.getRequestAddress() + "/" + imgnameEd);
|
||||
}
|
||||
imgObj.setSizes(Long.toString(file.length()));
|
||||
}
|
||||
|
||||
|
||||
imgObj.setUpdatetime(df.format(new Date()));
|
||||
imgObj.setSource(key.getId());
|
||||
imgObj.setUserid(u == null ? 0 : u.getId());
|
||||
|
||||
if(setday == 1 || setday == 3 || setday == 7 || setday == 30){
|
||||
imgObj.setImgtype(1);
|
||||
ImgTemp imgDataExp = new ImgTemp();
|
||||
imgDataExp.setDeltime(plusDay(setday));
|
||||
imgDataExp.setImguid(imguid);
|
||||
imgTempService.insertImgExp(imgDataExp);
|
||||
}else{
|
||||
imgObj.setImgtype(0);
|
||||
}
|
||||
imgObj.setAbnormal(userip);
|
||||
imgObj.setMd5key(md5key);
|
||||
imgObj.setImguid(imguid);
|
||||
imgObj.setFormat(fileMiME.getData().toString());
|
||||
userMapper.insertimg(imgObj);
|
||||
final Integer insertRet = imgMapper.insertImgData(imgObj);
|
||||
if (insertRet == 0) {
|
||||
Images imaOBJ = new Images();
|
||||
imaOBJ.setMd5key(md5key);
|
||||
imaOBJ.setUserid(u == null ? 0 : u.getId());
|
||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
||||
if (images.size() > 0) {
|
||||
Keys imgFromKey = keysService.selectKeys(images.get(0).getSource());
|
||||
if(imgFromKey.getStorageType().equals(5)){
|
||||
jsonObject.put("url",imgFromKey.getRequestAddress() + "/ota/"+ images.get(0).getImgname());
|
||||
}else{
|
||||
jsonObject.put("url", images.get(0).getImgurl());
|
||||
}
|
||||
jsonObject.put("name", file.getName());
|
||||
jsonObject.put("imguid", images.get(0).getImguid());
|
||||
System.err.println("已经有啦,哈哈哈哈哈啊哈!!!!!!!!");
|
||||
System.err.println(jsonObject.toJSONString());
|
||||
msg.setData(jsonObject);
|
||||
return msg;
|
||||
} else {
|
||||
msg.setInfo("未获取到指定图像");
|
||||
msg.setCode("110501");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
long stime = System.currentTimeMillis();
|
||||
Map<ReturnImage, Integer> m = null;
|
||||
ReturnImage returnImage = GetSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
||||
Images img = new Images();
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
if(returnImage.getCode().equals("200")){
|
||||
String imgurl = returnImage.getImgurl();
|
||||
Long imgsize = returnImage.getImgSize();
|
||||
String imgname = returnImage.getImgname();
|
||||
img.setImgurl(imgurl);
|
||||
img.setUpdatetime(df.format(new Date()));
|
||||
img.setSource(key.getId());
|
||||
img.setUserid(u == null ? 0 : u.getId());
|
||||
img.setSizes(imgsize.toString());
|
||||
if(uploadConfig.getUrltype()==2){
|
||||
img.setImgname(imgname);
|
||||
}else{
|
||||
img.setImgname(SetText.getSubString(imgname, key.getRequestAddress() + "/", ""));
|
||||
}
|
||||
if(setday == 1 || setday == 3 || setday == 7 || setday == 30){
|
||||
img.setImgtype(1);
|
||||
ImgTemp imgDataExp = new ImgTemp();
|
||||
imgDataExp.setDeltime(plusDay(setday));
|
||||
imgDataExp.setImguid(imguid);
|
||||
imgTempService.insertImgExp(imgDataExp);
|
||||
}else{
|
||||
img.setImgtype(0);
|
||||
}
|
||||
img.setAbnormal(userip);
|
||||
img.setMd5key(md5key);
|
||||
img.setImguid(imguid);
|
||||
img.setFormat(fileMiME.getData().toString());
|
||||
userMapper.insertimg(img);
|
||||
|
||||
long etime = System.currentTimeMillis();
|
||||
Print.Normal("上传图片所用总时长:" + String.valueOf(etime - stime) + "ms");
|
||||
jsonObject.put("url", img.getImgurl());
|
||||
|
||||
@@ -78,15 +78,17 @@ public class deleImages {
|
||||
errorIds.add(image.getImgurl());
|
||||
}
|
||||
}
|
||||
myProgress.setDelSuccessCount(successCount);
|
||||
myProgress.setDelSuccessImgList(ids);
|
||||
myProgress.setDelErrorImgListt(errorIds);
|
||||
if (imgIds.length == (i + 1)) {
|
||||
myProgress.setDelOCT(1);
|
||||
} else {
|
||||
myProgress.setDelOCT(0);
|
||||
if(uuid!=null){
|
||||
myProgress.setDelSuccessCount(successCount);
|
||||
myProgress.setDelSuccessImgList(ids);
|
||||
myProgress.setDelErrorImgListt(errorIds);
|
||||
if (imgIds.length == (i + 1)) {
|
||||
myProgress.setDelOCT(1);
|
||||
} else {
|
||||
myProgress.setDelOCT(0);
|
||||
}
|
||||
iRedisService.setTimeValue(uuid, JSONObject.toJSONString(myProgress), 24L);
|
||||
}
|
||||
iRedisService.setTimeValue(uuid, JSONObject.toJSONString(myProgress), 24L);
|
||||
// if (null != httpSession) {
|
||||
// httpSession.setAttribute("myProgressForDel", myProgress);
|
||||
// }
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
* @date 2019/11/7 17:12
|
||||
*/
|
||||
public class GetSource {
|
||||
public static ReturnImage storageSource(Integer type, Map<String, File> fileMap, String userpath,Integer keyID){
|
||||
public static ReturnImage storageSource(Integer type, Map<Map<String, String>, File> fileMap, String userpath,Integer keyID){
|
||||
NOSImageupload nosImageupload = SpringContextHolder.getBean(NOSImageupload.class);
|
||||
OSSImageupload ossImageupload = SpringContextHolder.getBean(OSSImageupload.class);
|
||||
USSImageupload ussImageupload = SpringContextHolder.getBean(USSImageupload.class);
|
||||
|
||||
@@ -27,43 +27,35 @@ public class LocUpdateImg {
|
||||
return isDele;
|
||||
}
|
||||
|
||||
public static ReturnImage ImageuploadLOC(Map<String, File> fileMap, String username,Integer keyID) throws Exception {
|
||||
KeysServiceImpl keysService = SpringContextHolder.getBean(KeysServiceImpl.class);
|
||||
final Keys key = keysService.selectKeys(keyID);
|
||||
public static ReturnImage ImageuploadLOC(
|
||||
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||
ReturnImage returnImage = new ReturnImage();
|
||||
String filePath =GlobalConstant.LOCPATH + File.separator;
|
||||
File file = null;
|
||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
System.out.println("待上传的图片:"+username + File.separator + ShortUID + "." + entry.getKey());
|
||||
File dest = new File(filePath + username + File.separator+ ShortUID + "." + entry.getKey());
|
||||
File temppath = new File(filePath + username+ File.separator );
|
||||
String filePath = GlobalConstant.LOCPATH + File.separator;
|
||||
try {
|
||||
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||
String prefix = entry.getKey().get("prefix");
|
||||
String ShortUIDName = entry.getKey().get("name");
|
||||
File dest = new File(filePath + username + File.separator + ShortUIDName + "." + prefix);
|
||||
if (!dest.getParentFile().exists()) {
|
||||
dest.getParentFile().mkdirs();
|
||||
dest.getParentFile().mkdirs();
|
||||
}
|
||||
try {
|
||||
InputStream fileInputStream = new FileInputStream(entry.getValue());
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest));
|
||||
byte[] bs = new byte[1024];
|
||||
int len;
|
||||
while ((len = fileInputStream.read(bs)) != -1) {
|
||||
bos.write(bs, 0, len);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
returnImage.setImgname(username + "/" +ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename()
|
||||
returnImage.setImgurl(key.getRequestAddress() +"/ota/"+username + "/" + ShortUID + "." + entry.getKey());
|
||||
returnImage.setImgSize(entry.getValue().length());
|
||||
returnImage.setCode("200");
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("500");
|
||||
System.err.println("上传失败");
|
||||
InputStream fileInputStream = new FileInputStream(entry.getValue());
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest));
|
||||
byte[] bs = new byte[1024];
|
||||
int len;
|
||||
while ((len = fileInputStream.read(bs)) != -1) {
|
||||
bos.write(bs, 0, len);
|
||||
}
|
||||
bos.flush();
|
||||
bos.close();
|
||||
}
|
||||
returnImage.setCode("200");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("500");
|
||||
System.err.println("上传失败");
|
||||
}
|
||||
return returnImage;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,51 @@
|
||||
</if>
|
||||
order by a.id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertImgData" parameterType="cn.hellohao.pojo.Images">
|
||||
INSERT INTO imgdata (
|
||||
id,
|
||||
imgname,
|
||||
imgurl,
|
||||
userid,
|
||||
updatetime,
|
||||
sizes,
|
||||
abnormal,
|
||||
`source`,
|
||||
imgtype,
|
||||
explains,
|
||||
md5key,
|
||||
imguid,
|
||||
`format`,
|
||||
about,
|
||||
violation,
|
||||
idname
|
||||
)
|
||||
select * from (
|
||||
SELECT NULL id,
|
||||
#{imgname} imgname,
|
||||
#{imgurl} imgurl,
|
||||
#{userid} userid,
|
||||
#{updatetime} updatetime,
|
||||
#{sizes} sizes,
|
||||
#{abnormal} abnormal,
|
||||
#{source} `source`,
|
||||
#{imgtype} imgtype,
|
||||
#{explains} explains,
|
||||
#{md5key} md5key,
|
||||
#{imguid} imguid,
|
||||
#{format} `format`,
|
||||
#{about} about,
|
||||
null violation,
|
||||
#{idname} idname
|
||||
) temp_t
|
||||
|
||||
where not exists (
|
||||
select md5key from imgdata img_t where temp_t.md5key = img_t.md5key
|
||||
) and (select (select checkduplicate from sysconfig where id =1)=1)
|
||||
</insert>
|
||||
|
||||
|
||||
<!-- 此用户下总数 -->
|
||||
<select id="countimg" parameterType="integer" resultType="integer">
|
||||
select count(*) from imgdata where userid = #{userid}
|
||||
|
||||
Reference in New Issue
Block a user