提交代码

master
胡锐 6 months ago committed by yuanye
parent 2bce9d1966
commit 1a312d9b18
  1. 9
      bweb/src/main/java/com/bweb/controller/FileUploadController.java
  2. 4
      order/src/main/java/com/order/controller/OrderController.java
  3. 5
      service/pom.xml
  4. 100
      service/src/main/java/com/hfkj/common/obs/HuaWeiYunObs.java
  5. 7
      service/src/main/java/com/hfkj/config/CommonSysConfig.java
  6. 7
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  7. 19
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java
  8. 4
      service/src/main/resources/dev/commonConfig.properties

@ -1,10 +1,13 @@
package com.bweb.controller;
import com.hfkj.common.obs.HuaWeiYunObs;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.bweb.config.SysConfig;
import com.hfkj.config.CommonSysConst;
import com.hfkj.model.ResponseData;
import com.hfkj.service.FileUploadService;
import com.obs.services.model.PutObjectResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.coobird.thumbnailator.Thumbnails;
@ -72,6 +75,9 @@ public class FileUploadController {
out.write(file.getBytes());
out.flush();
fileNames.add(childPath + "/" + fileName);
PutObjectResult putObjectResult = HuaWeiYunObs.putObject(CommonSysConst.getSysConfig().getObsBucketName(),
childPath + "/" + fileName, new File(destDirName + "/" + fileName));
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
@ -132,6 +138,9 @@ public class FileUploadController {
if (fis.available() > 500000) {
Thumbnails.of(new FileInputStream(destDirName + File.separator + fileName)).scale(0.5).toFile(new File(destDirName + File.separator + fileName));
}
PutObjectResult putObjectResult = HuaWeiYunObs.putObject(CommonSysConst.getSysConfig().getObsBucketName(),
childPath + "/" + fileName, new File(destDirName + "/" + fileName));
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {

@ -8,6 +8,7 @@ import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.ResponseData;
import com.hfkj.model.UserSessionObject;
import com.hfkj.model.order.OrderChildModel;
@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -138,7 +140,7 @@ public class OrderController {
param.put("orderNo", orderNo);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(null);
return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(param)));
} catch (Exception e) {
log.error("error!",e);

@ -238,6 +238,11 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java-bundle</artifactId>
<version>[3.21.8,)</version>
</dependency>
</dependencies>
<build>
<resources>

@ -0,0 +1,100 @@
package com.hfkj.common.obs;
import com.hfkj.config.CommonSysConst;
import com.obs.services.ObsClient;
import com.obs.services.model.*;
import java.io.File;
import java.io.IOException;
/**
* 华为云obs 对象存储
* @author hurui
*/
public class HuaWeiYunObs {
public static String url = CommonSysConst.getSysConfig().getObsUrl();
private static String endPoint = CommonSysConst.getSysConfig().getObsEndPoint();
private static String accessKey = "CZVO7VAT8UV2RPYJUBD2";
private static String secretKey = "gyjrR8rYq9w2maPq9VmpRqoMqCJzQMH8vMctg7eE";
public static String bucketName = CommonSysConst.getSysConfig().getObsUrl();
/**
* 创建请求
* @return
*/
private static ObsClient createClient() {
return new ObsClient(accessKey, secretKey, endPoint);
}
/**
* 关闭请求
* @param obsClient
*/
private static void closeClient(ObsClient obsClient) {
try {
if (obsClient != null) {
obsClient.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 上传文件
* @param bucketName 桶名称
* @param objectName 对象名称 例如1.jpg
* @param file 文件路径
* @return
*/
public static PutObjectResult putObject(String bucketName,String objectName, File file) {
ObsClient client = createClient();
try {
return client.putObject(bucketName, objectName, file);
} catch (Exception e) {
e.printStackTrace();
} finally {
closeClient(client);
}
return null;
}
/**
* 上传文件
* @param fileUrl 文件路径
* @param bucketName 桶名称
* @param objectName 对象路径名称 例如temporary/1.jpg
* @return
*/
public static void obsUtilPutObject(String fileUrl,String bucketName,String objectName) throws IOException {
// 执行上传命令
new ProcessBuilder("/bin/bash", "-c", "obsutil cp "+ fileUrl + " obs://"+bucketName +"/"+ objectName).start();
}
/**
* 获取图片临时路径
* @param bucketName 桶名称
* @param objectName 对象名称 例如1.jpg
* @return
*/
public static String getImgSignedUrl(String bucketName,String objectName) {
ObsClient client = createClient();
try {
TemporarySignatureRequest request = new TemporarySignatureRequest(HttpMethodEnum.GET, 1800L);
request.setBucketName(bucketName);
request.setObjectKey(objectName);
TemporarySignatureResponse response = client.createTemporarySignature(request);
return response.getSignedUrl();
} catch (Exception e) {
e.printStackTrace();
} finally {
closeClient(client);
}
return null;
}
}

@ -66,6 +66,13 @@ public class CommonSysConfig {
*/
private String blxPostUrl;
/**
* 对象存储
*/
private String obsUrl;
private String obsBucketName;
private String obsEndPoint;
/**
* 汇联通卡券请求地址
*/

@ -68,4 +68,11 @@ public interface BsOrderService {
*/
List<BsOrder> getOrderList(Map<String,Object> param);
/**
* 查询用户订单列表
* @param param
* @return
*/
List<OrderModel> getUserOrderList(Map<String,Object> param);
}

@ -34,6 +34,7 @@ import org.thymeleaf.util.DateUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -301,4 +302,22 @@ public class BsOrderServiceImpl implements BsOrderService {
example.setOrderByClause("create_time desc");
return orderMapper.selectByExample(example);
}
@Override
public List<OrderModel> getUserOrderList(Map<String, Object> param) {
BsOrderExample example = new BsOrderExample();
BsOrderExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(MapUtils.getString(param, "order"))) {
criteria.andOrderNoLike("%"+MapUtils.getString(param, "order")+"%");
}
example.setOrderByClause("create_time desc");
List<OrderModel> orderModelList = new ArrayList<>();
List<BsOrder> orderList = orderMapper.selectByExample(example);
for (BsOrder order : orderList) {
orderModelList.add(getDetail(order.getOrderNo()));
}
return orderModelList;
}
}

@ -3,6 +3,10 @@ wechatMaSecret=
wechatMpAppid=
wechatMpSecret=
obsBucketName=phg-test
obsEndPoint=https://obs.cn-southwest-2.myhuaweicloud.com
obsUrl=https://phg-test.obs.cn-southwest-2.myhuaweicloud.com
huiPayPreorderNotifyUrl=https://phgcs.dctpay.com/order/notify/huipay
# ChongQingCNPC configuration parameters

Loading…
Cancel
Save