Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
09252dda7c
|
|
@ -108,8 +108,8 @@ public class LoginProperties {
|
|||
@Override
|
||||
protected char[] alphas() {
|
||||
// 生成随机数字和运算符
|
||||
// int n1 = num(1, 10), n2 = num(1, 10);
|
||||
int n1 = num(1, 5), n2 = num(1, 5);
|
||||
int n1 = num(1, 10), n2 = num(1, 10);
|
||||
// int n1 = num(1, 5), n2 = num(1, 5);
|
||||
int opt = num(3);
|
||||
|
||||
// 计算结果
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package cn.ysk.cashier.mybatis.entity;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
|
@ -12,6 +14,7 @@ import java.io.Serializable;
|
|||
@SuppressWarnings("serial")
|
||||
public class TagProductDepts extends Model<TagProductDepts> {
|
||||
//标签id
|
||||
@TableId(value = "tagId", type = IdType.NONE)
|
||||
private Integer tagId;
|
||||
//商品id
|
||||
private Integer productId;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@
|
|||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>sts20150401</artifactId>
|
||||
<version>1.1.4</version>
|
||||
</dependency>
|
||||
<!--支付宝依赖-->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
|
|
|
|||
|
|
@ -1,27 +1,14 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.rest;
|
||||
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.domain.QiniuConfig;
|
||||
import cn.ysk.cashier.domain.QiniuContent;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.service.QiNiuService;
|
||||
import cn.ysk.cashier.service.dto.QiniuQueryCriteria;
|
||||
import com.aliyun.sts20150401.models.AssumeRoleResponse;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -77,7 +64,7 @@ public class QiniuController {
|
|||
return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("上传版本文件")
|
||||
@Log("上传文件")
|
||||
@ApiOperation("上传文件")
|
||||
@AnonymousPostMapping
|
||||
public ResponseEntity<Object> uploadQiNiu(@RequestParam MultipartFile file){
|
||||
|
|
@ -89,13 +76,34 @@ public class QiniuController {
|
|||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("上传PC版本文件")
|
||||
@AnonymousPostMapping("uploadVersionFile")
|
||||
public ResponseEntity<Object> uploadVersionFile(@RequestParam MultipartFile file,@RequestParam String name){
|
||||
String url = qiNiuService.uploadVersionFile(file,qiNiuService.findCloud(),name);
|
||||
Map<String,Object> map = new HashMap<>(1);
|
||||
map.put("data",url);
|
||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
@GetMapping(value = "/getCredentials")
|
||||
@ApiOperation("获取上传临时凭证")
|
||||
public ResponseEntity<Object> getCredentials() {
|
||||
try {
|
||||
com.aliyun.sts20150401.Client client = new com.aliyun.sts20150401.Client(qiNiuService.findTempCloud());
|
||||
com.aliyun.sts20150401.models.AssumeRoleRequest assumeRoleRequest = new com.aliyun.sts20150401.models.AssumeRoleRequest();
|
||||
assumeRoleRequest.setRoleArn("acs:ram::1413456038175003:role/oss");
|
||||
assumeRoleRequest.setRoleSessionName("test");
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
AssumeRoleResponse response = client.assumeRoleWithOptions(assumeRoleRequest, runtime);
|
||||
return new ResponseEntity<>(response.getBody().getCredentials(),HttpStatus.OK);
|
||||
} catch (TeaException error) {
|
||||
throw new BadRequestException("获取失败,请联系管理员。"+error.getMessage());
|
||||
// System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
throw new BadRequestException("获取失败,请联系管理员。"+ _error.getMessage());
|
||||
// TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// // 错误 message
|
||||
// System.out.println(error.getMessage());
|
||||
// // 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import cn.ysk.cashier.service.dto.QiniuQueryCriteria;
|
|||
import com.dianguang.cloud.ossservice.config.CloudStorageConfig;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
|
@ -41,6 +42,8 @@ public interface QiNiuService {
|
|||
|
||||
CloudStorageConfig findCloud();
|
||||
|
||||
Config findTempCloud();
|
||||
|
||||
/**
|
||||
* 修改配置
|
||||
* @param qiniuConfig 配置
|
||||
|
|
|
|||
|
|
@ -1,23 +1,9 @@
|
|||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.domain.QiniuConfig;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.dianguang.cloud.ossservice.config.CloudStorageConfig;
|
||||
import com.dianguang.cloud.ossservice.service.OSSFactory;
|
||||
import com.qiniu.common.QiniuException;
|
||||
|
|
@ -93,6 +79,25 @@ public class QiNiuServiceImpl implements QiNiuService {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config findTempCloud() {
|
||||
Optional<QiniuConfig> qiniuConfig = qiNiuConfigRepository.findById(1L);
|
||||
QiniuConfig config= qiniuConfig.orElseGet(QiniuConfig::new);
|
||||
if(ObjectUtil.isNotEmpty(config)){
|
||||
com.aliyun.teaopenapi.models.Config config1 = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
// .setAccessKeyId(System.getenv("LTAI5tPdEfYSZcqHbjCrtPRD"))
|
||||
.setAccessKeyId(qiniuConfig.get().getAccessKey())
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret(qiniuConfig.get().getSecretKey());
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Sts
|
||||
config1.endpoint = "sts.cn-hangzhou.aliyuncs.com";
|
||||
return config1;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
|
|
|||
Loading…
Reference in New Issue