yshop3.0-alpha版本

This commit is contained in:
hupeng
2020-06-27 16:29:35 +08:00
parent 31189da79e
commit 761840d8f2
1153 changed files with 27921 additions and 33489 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>yshop</artifactId>
<groupId>co.yixiang</groupId>
<version>2.2</version>
<version>3.0-alpha</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -23,7 +23,7 @@
<dependency>
<groupId>co.yixiang</groupId>
<artifactId>yshop-logging</artifactId>
<version>2.2</version>
<version>3.0-alpha</version>
</dependency>
<!--邮件依赖-->

View File

@ -13,6 +13,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Base64Utils;
import java.io.Serializable;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.HashMap;
@ -23,7 +24,7 @@ import java.util.Map;
* <p>
* 快递鸟即时查询API http://www.kdniao.com/api-track
*/
public class ExpressService {
public class ExpressService implements Serializable {
private final Log logger = LogFactory.getLog(ExpressService.class);
//请求url

View File

@ -1,30 +1,52 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意:
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖、分享、上传到码云、github等开源平台
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
*/
package co.yixiang.tools.express.config;
import co.yixiang.constant.ShopConstants;
import co.yixiang.enums.ShopCommonEnum;
import co.yixiang.tools.express.ExpressService;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import co.yixiang.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(ExpressProperties.class)
public class ExpressAutoConfiguration {
private final ExpressProperties properties;
public ExpressAutoConfiguration(ExpressProperties properties) {
this.properties = properties;
private static RedisUtils redisUtil;
@Autowired
public ExpressAutoConfiguration(RedisUtils redisUtil) {
this.redisUtil = redisUtil;
}
@Bean
public ExpressService expressService() {
ExpressService expressService = new ExpressService();
expressService.setProperties(properties);
return expressService;
public static ExpressService expressService() {
ExpressService expressService = (ExpressService)redisUtil.get(ShopConstants.YSHOP_EXPRESS_SERVICE);
if(expressService != null) return expressService;
ExpressProperties properties = new ExpressProperties();
String enable = redisUtil.getY("exp_enable");
String appId = redisUtil.getY("exp_appId");
String appKey = redisUtil.getY("exp_appKey");
properties.setAppId(appId);
properties.setAppKey(appKey);
if(ShopCommonEnum.ENABLE_2.getValue().toString().equals(enable)){
properties.setEnable(false);
}else{
properties.setEnable(true);
}
ExpressService service = new ExpressService();
service.setProperties(properties);
redisUtil.set(ShopConstants.YSHOP_EXPRESS_SERVICE,service);
return service;
}
}

View File

@ -5,13 +5,10 @@
*/
package co.yixiang.tools.express.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ConfigurationProperties(prefix = "yshop.express")
public class ExpressProperties {
private boolean enable;
private String appId;

View File

@ -7,10 +7,13 @@ package co.yixiang.tools.rest;
import cn.hutool.core.util.StrUtil;
import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.api.YshopException;
import co.yixiang.enums.ShopCommonEnum;
import co.yixiang.tools.domain.QiniuContent;
import co.yixiang.tools.service.LocalStorageService;
import co.yixiang.tools.service.QiNiuService;
import co.yixiang.tools.service.dto.LocalStorageDto;
import co.yixiang.utils.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
@ -35,25 +38,33 @@ import java.util.Map;
@SuppressWarnings("unchecked")
public class UploadController {
@Value("${file.localUrl}")
private String localUrl;
private final LocalStorageService localStorageService;
private final QiNiuService qiNiuService;
private final RedisUtils redisUtils;
public UploadController(LocalStorageService localStorageService, QiNiuService qiNiuService) {
public UploadController(LocalStorageService localStorageService, QiNiuService qiNiuService,
RedisUtils redisUtils) {
this.localStorageService = localStorageService;
this.qiNiuService = qiNiuService;
this.redisUtils = redisUtils;
}
@ApiOperation("上传文件")
@PostMapping
@AnonymousAccess
public ResponseEntity<Object> create(@RequestParam(defaultValue = "") String name, @RequestParam("file") MultipartFile[] files) {
public ResponseEntity<Object> create(@RequestParam(defaultValue = "") String name,
@RequestParam(defaultValue = "") String type,
@RequestParam("file") MultipartFile[] files) {
String localUrl = redisUtils.getY("admin_api_url");
if(StrUtil.isBlank(type)){
localUrl = redisUtils.getY("api_url") + "/api";
}
String mode = redisUtils.getY("file_store_mode");
StringBuilder url = new StringBuilder();
if (StrUtil.isNotEmpty(localUrl)) { //存在走本地
if (ShopCommonEnum.STORE_MODE_1.getValue().toString().equals(mode)) { //存在走本地
if(StrUtil.isBlank(localUrl)){
throw new YshopException("本地上传,请先登陆系统配置后台/移动端API地址");
}
for (MultipartFile file : files) {
LocalStorageDto localStorageDTO = localStorageService.create(name, file);
if ("".equals(url.toString())) {

View File

@ -102,7 +102,7 @@ public class LocalStorageServiceImpl extends BaseServiceImpl<LocalStorageMapper,
file.getPath(),
type,
FileUtil.getSize(multipartFile.getSize()),
SecurityUtils.getUsername()
"yshop"
);
this.save(localStorage);
return generator.convert(localStorage,LocalStorageDto.class);

View File

@ -28,10 +28,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
/**
* @author hupeng
@ -39,7 +35,7 @@ import java.util.Map;
*/
@Service
@AllArgsConstructor
//@CacheConfig(cacheNames = "qiniuContent")
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class QiniuContentServiceImpl extends BaseServiceImpl<QiniuContentMapper, QiniuContent> implements QiniuContentService {