|
@@ -9,12 +9,14 @@ import com.caimei.www.pojo.document.OssArchivePdf;
|
|
|
import com.caimei.www.pojo.document.OssAuthorization;
|
|
|
import com.caimei.www.service.page.DocumentAuthService;
|
|
|
import com.caimei.www.service.redis.RedisService;
|
|
|
+import com.caimei.www.utils.ImageUtil;
|
|
|
import com.caimei.www.utils.RandomCodeGenerator;
|
|
|
import com.caimei.www.utils.SMSUtils;
|
|
|
import com.caimei.www.utils.VerifyCodeUtils;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
@@ -44,6 +46,9 @@ public class DocumentAuthServiceImpl implements DocumentAuthService {
|
|
|
@Resource
|
|
|
private RedisService redisService;
|
|
|
|
|
|
+ @Value("${caimei.wwwDomain}")
|
|
|
+ private String domain;
|
|
|
+
|
|
|
@Override
|
|
|
public JsonModel getAuthorizationCookie() {
|
|
|
String authorizationMobile = null;
|
|
@@ -133,31 +138,41 @@ public class DocumentAuthServiceImpl implements DocumentAuthService {
|
|
|
|
|
|
@Override
|
|
|
public JsonModel dataList(String name, Integer pageNum, Integer pageSize) {
|
|
|
- String endpoint = "https://oss-cn-shenzhen.aliyuncs.com";
|
|
|
- String accessKeyId = "LTAI4GBL3o4YkWnbKYgf2Xia";
|
|
|
- String accessKeySecret = "dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK";
|
|
|
- String bucketName = "caimei-oss";
|
|
|
pageNum = pageNum == null ? 1 : pageNum;
|
|
|
pageSize = pageSize == null ? 20 : pageSize;
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<OssArchive> ossArchiveList = documentAuthDao.findOssArchive(name);
|
|
|
PageInfo<OssArchive> pageInfo = null;
|
|
|
if (ossArchiveList != null && ossArchiveList.size() > 0) {
|
|
|
- OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
|
- // 设置URL过期时间为1个小时
|
|
|
- Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
|
|
|
for (OssArchive ossArchive : ossArchiveList) {
|
|
|
- List<OssArchivePdf> pdfList = documentAuthDao.findOssArchivePdf(ossArchive.getId());
|
|
|
- if (pdfList != null && pdfList.size() > 0) {
|
|
|
- for (OssArchivePdf pdf : pdfList) {
|
|
|
- String url = ossClient.generatePresignedUrl(bucketName, pdf.getOssName(), expiration).toString();
|
|
|
- pdf.setUrl(url);
|
|
|
- }
|
|
|
+ if (!StringUtils.isEmpty(ossArchive.getMainImage())) {
|
|
|
+ ossArchive.setMainImage(ImageUtil.getImageURL("product", ossArchive.getMainImage(), 0, domain));
|
|
|
}
|
|
|
+ List<OssArchivePdf> pdfList = documentAuthDao.findOssArchivePdf(ossArchive.getId());
|
|
|
+ ossArchive.setPdfList(pdfList);
|
|
|
}
|
|
|
pageInfo = new PageInfo<>(ossArchiveList);
|
|
|
- ossClient.shutdown();
|
|
|
}
|
|
|
return JsonModel.success(pageInfo);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JsonModel dataDetails(Integer pdfId) {
|
|
|
+ String endpoint = "https://oss-cn-shenzhen.aliyuncs.com";
|
|
|
+ String accessKeyId = "LTAI4GBL3o4YkWnbKYgf2Xia";
|
|
|
+ String accessKeySecret = "dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK";
|
|
|
+ String bucketName = "caimei-oss";
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
+ OssArchivePdf ossArchivePdf = documentAuthDao.findOssArchivePdfById(pdfId);
|
|
|
+ OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
|
+ // 设置URL过期时间为1个小时
|
|
|
+ Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
|
|
|
+ String url = ossClient.generatePresignedUrl(bucketName, ossArchivePdf.getOssName(), expiration).toString();
|
|
|
+ ossArchivePdf.setUrl(url);
|
|
|
+ OssArchive ossArchive = documentAuthDao.getOssArchive(ossArchivePdf.getArchiveId());
|
|
|
+ map.put("ossArchivePdf", ossArchivePdf);
|
|
|
+ map.put("ossArchive", ossArchive);
|
|
|
+ ossClient.shutdown();
|
|
|
+ return JsonModel.success(map);
|
|
|
+ }
|
|
|
}
|