parent
02be470cd3
commit
47f964b366
@ -1,43 +0,0 @@
|
||||
package com.ruoyi.web.controller.common;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.OssUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "OSS对象存储Controller")
|
||||
@RequestMapping("/oss")
|
||||
public class OssController {
|
||||
@Autowired
|
||||
OssUtils ossUtils;
|
||||
|
||||
@PostMapping("upload")
|
||||
public AjaxResult uploadFile(MultipartFile file) {
|
||||
//返回上传oss的url
|
||||
String url = ossUtils.uploadOneFile(file);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("fileName", file.getOriginalFilename());
|
||||
ajax.put("url", url);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
@PostMapping("uploadArrayFile")
|
||||
public List<String> uploadArrayFile(MultipartFile[] files) {
|
||||
//返回上传oss的url
|
||||
return ossUtils.uploadArrayFile(files);
|
||||
}
|
||||
|
||||
@PostMapping("deleteFile")
|
||||
public boolean deleteFile(@RequestBody String fileUrl) {
|
||||
//返回是否删除成功
|
||||
return ossUtils.deleteFile(fileUrl);
|
||||
}
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
package com.ruoyi.web.core.config;
|
||||
|
||||
import com.cyl.manager.ums.domain.entity.Member;
|
||||
import com.cyl.manager.ums.service.MemberService;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.model.LoginMember;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.framework.config.LocalDataUtil;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Configuration
|
||||
public class H5MemberInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
private static String[] WHITE_PATHS = {
|
||||
"/h5/sms/login",
|
||||
"/h5/wechat/login",
|
||||
"/h5/account/login",
|
||||
"/h5/register",
|
||||
"/h5/validate"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String requestUri = request.getRequestURI();
|
||||
boolean flag = true;
|
||||
if (!requestUri.startsWith("/h5/")) {
|
||||
return super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
for (String s : WHITE_PATHS) {
|
||||
if (requestUri.startsWith(s)) {
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
return super.preHandle(request, response, handler);
|
||||
}
|
||||
LoginMember loginMember = tokenService.getLoginMember(request);
|
||||
if (loginMember == null) {
|
||||
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
tokenService.verifyMemberToken(loginMember);
|
||||
//获取会员信息
|
||||
Member member = memberService.selectById(loginMember.getMemberId());
|
||||
if (member == null || member.getStatus() == 0) {
|
||||
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
//将会员信息存放至全局
|
||||
LocalDataUtil.setVar(Constants.MEMBER_INFO, member);
|
||||
|
||||
return super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package com.ruoyi.web.core.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class MvcConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public H5MemberInterceptor memberInterceptor() {
|
||||
return new H5MemberInterceptor();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(memberInterceptor());
|
||||
}
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
package com.fjp.lc.test.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.cyl.h5.controller.H5OrderController;
|
||||
import com.cyl.h5.domain.form.ApplyRefundForm;
|
||||
import com.cyl.manager.oms.domain.entity.Order;
|
||||
import com.cyl.manager.oms.domain.entity.OrderItem;
|
||||
import com.cyl.manager.oms.mapper.OrderMapper;
|
||||
import com.cyl.manager.oms.service.OrderService;
|
||||
import com.ruoyi.RuoYiApplication;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RuoYiApplication.class)
|
||||
@ActiveProfiles("dev")
|
||||
@Slf4j
|
||||
public class ControllerTest {
|
||||
@Autowired
|
||||
private H5OrderController h5OrderController;
|
||||
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
ApplyRefundForm applyRefundForm = new ApplyRefundForm();
|
||||
QueryWrapper<Order> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("pay_id", 6226229322123265l);
|
||||
Order order = orderMapper.selectOne(queryWrapper);
|
||||
applyRefundForm.setOrderId(order.getId());
|
||||
applyRefundForm.setApplyRefundType(1);
|
||||
applyRefundForm.setReason("不要了");
|
||||
applyRefundForm.setQuantity(1);
|
||||
applyRefundForm.setRefundAmount(new BigDecimal(0.01));
|
||||
h5OrderController.applyRefund(applyRefundForm);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,173 +0,0 @@
|
||||
package com.fjp.lc.test.service;
|
||||
|
||||
import com.ruoyi.RuoYiApplication;
|
||||
import com.ruoyi.common.utils.OssUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = RuoYiApplication.class)
|
||||
@ActiveProfiles("dev")
|
||||
public class OssTest {
|
||||
|
||||
@Autowired
|
||||
private OssUtils ossUtils;
|
||||
@Test
|
||||
public void download() {
|
||||
ossUtils.downloadFile("2022/12/306da8f7f6491046ba86633e4de8240b84微信图片_20220606114231.jpg");
|
||||
ossUtils.downloadFile("2022/12/29543652b023af4caeb5d9d74c2f98bdfb微信图片_20220606114231.jpg");
|
||||
ossUtils.downloadFile("2022/12/30237d83af8f8e494f98caff9ac87d8eed微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/03/119682c2bb40d54639b51f9819cb127f44400x400.png");
|
||||
ossUtils.downloadFile("2023/03/11a67b86d4dd6b4fc687f9044155c34083400x400blue.png");
|
||||
ossUtils.downloadFile("2023/07/26975a5546e4e14baca40ffde696ee3ffb微信图片_202304151221202.jpg");
|
||||
ossUtils.downloadFile("2023/07/26e89dd1d370b74598aba6dd7cced81f72微信图片_20230415121747.jpg");
|
||||
ossUtils.downloadFile("2023/07/2625f4fc4576974035990f35ffae4cbe89微信图片_202305311200104.jpg");
|
||||
ossUtils.downloadFile("2023/07/269436b74dd01f45a09e0d63c02bc2bc20微信图片_202207241638361.jpg");
|
||||
ossUtils.downloadFile("2023/07/2609fb7c7b52f04b29893fb7034d5488eb微信图片_20220822144529.jpg");
|
||||
ossUtils.downloadFile("2023/07/26561982918fbd4269abc1a87ea7c2f09b微信图片_20230518014301.jpg");
|
||||
ossUtils.downloadFile("2023/05/26572ddcb26dd64ea9aef1615c518311f2main.jpg");
|
||||
ossUtils.downloadFile("2023/07/26b0e6d79409c047afbf435c2e45b2864e微信图片_202305070430094.jpg");
|
||||
ossUtils.downloadFile("2023/07/268673a92f29ea4ed9a3503587c658fb7d微信图片_20230304190516.jpg");
|
||||
ossUtils.downloadFile("2023/08/14ff4bde97153a416e9cdde8035bc7e0f326db1efa38167a4cd5ab392cd7bb6b8fc9ed5b46ef3e460fe27f73aa280993004.jpg.png");
|
||||
ossUtils.downloadFile("2023/07/269922ae58ef074304a907f6524d13401c微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/12/03847a4833090f40de9c6b49f7d553608a微信图片_202303082336274.jpg");
|
||||
ossUtils.downloadFile("2023/12/034459c85e71e3402aba5eb7e0531201fd微信图片_202303082336273.jpg");
|
||||
ossUtils.downloadFile("2023/12/03d3e5fc569e7d42529c8a3b504ae4d92c微信图片_202303082336271.jpg");
|
||||
ossUtils.downloadFile("2023/12/0383e8c4d2be284355a07233bc1c38e6d7微信图片_202303082336272.jpg");
|
||||
ossUtils.downloadFile("2023/06/12539d8d04c72247c4bd4ac3820ae939a3227ddfae236d5a4adca97541f7937488dc033fc965331ca74b3a9d6daa9fd0e48225sy_content_good_stuff@2x.png");
|
||||
ossUtils.downloadFile("2023/03/113d7ab00580e44f9ab2d274c0e3f9cd89400x400.png");
|
||||
ossUtils.downloadFile("2023/03/11a1e8bc35653044d2a2012ef1a30dc5d9blue.png");
|
||||
ossUtils.downloadFile("2023/03/11ca202adcbef54a97879e3b6ca9214729red.png");
|
||||
ossUtils.downloadFile("2023/03/113be968d872ca4a0bb0d8fc08e13bb81fgrey.png");
|
||||
ossUtils.downloadFile("2023/03/112f186945ad444e71a6fdaf5a634577d0yellow.png");
|
||||
ossUtils.downloadFile("2023/03/11703d301ec87448a8ad8c754ca7c043e5blue.png");
|
||||
ossUtils.downloadFile("2023/06/126850de7100594b2cbe67ba10ac30315e227ddfae236d5a4adca97541f7937488dc033fc965331ca74b3a9d6daa9fd0e48225sy_content_good_stuff@2x.png");
|
||||
ossUtils.downloadFile("2023/06/1297a4dd69e5b14fe0bc8da968c0b2043f22dea3ccb9cd45412da6300c5ac7d8f68903bae3d53cef7f4dfeb38bbafe109a3755sy_content_digital@2x.png");
|
||||
ossUtils.downloadFile("2023/06/1261979f808cb04d108727cf3709ffa355226569ab1688ec4eb8a7a2d879f3cd36b303df12b214f50f49928b53ad113e11170bsy_content_apparel@2x.png");
|
||||
ossUtils.downloadFile("2023/06/123c2915e18c604f3290ff4876954f6aa32213fbf4b69d9041d68da50fdd71aa6b5403afbad6ea2bce46db8108e48eb2bed9d3sy_content_care@2x.png");
|
||||
ossUtils.downloadFile("2023/06/12beec9af7400c44deb3951fa5be95b0ae22e0ce080252874dd4b22e7559ac1478bf036ce7046f48eb4faba7f43849d2d7814dsy_content_rice@2x.png");
|
||||
ossUtils.downloadFile("2023/06/12cbeee94461d44d13bba3503682286e382231e1747caf7a4f9f9d54af5789d1d538033d7aaef21b2b4984abd8a07a2b97c49csy_content_drinks@2x.png");
|
||||
ossUtils.downloadFile("2023/06/121dde34bbb8024ac99e09af20e380d78822b62a9a9f2e8349cc9e0321a53e27bf780322d4a84f6c334c7d984484f04e87dbb1sy_content_sports@2x.png");
|
||||
ossUtils.downloadFile("2023/06/129a33a0881f4e4d279cc067e592b588612253d01aa5f365420e8b96cd93ee1893f6035a69224ec7904e2b94047f22ddfb5d19sy_content_other@2x.png");
|
||||
ossUtils.downloadFile("2023/03/119682c2bb40d54639b51f9819cb127f44400x400.png");
|
||||
ossUtils.downloadFile("2023/03/11a67b86d4dd6b4fc687f9044155c34083400x400blue.png");
|
||||
ossUtils.downloadFile("2023/07/26975a5546e4e14baca40ffde696ee3ffb微信图片_202304151221202.jpg");
|
||||
ossUtils.downloadFile("2023/07/26e89dd1d370b74598aba6dd7cced81f72微信图片_20230415121747.jpg");
|
||||
ossUtils.downloadFile("2023/07/2625f4fc4576974035990f35ffae4cbe89微信图片_202305311200104.jpg");
|
||||
ossUtils.downloadFile("2023/07/269436b74dd01f45a09e0d63c02bc2bc20微信图片_202207241638361.jpg");
|
||||
ossUtils.downloadFile("2023/07/2609fb7c7b52f04b29893fb7034d5488eb微信图片_20220822144529.jpg");
|
||||
ossUtils.downloadFile("2023/07/26561982918fbd4269abc1a87ea7c2f09b微信图片_20230518014301.jpg");
|
||||
ossUtils.downloadFile("2023/05/26572ddcb26dd64ea9aef1615c518311f2main.jpg");
|
||||
ossUtils.downloadFile("2023/07/26b0e6d79409c047afbf435c2e45b2864e微信图片_202305070430094.jpg");
|
||||
ossUtils.downloadFile("2023/07/268673a92f29ea4ed9a3503587c658fb7d微信图片_20230304190516.jpg");
|
||||
ossUtils.downloadFile("2023/08/14ff4bde97153a416e9cdde8035bc7e0f326db1efa38167a4cd5ab392cd7bb6b8fc9ed5b46ef3e460fe27f73aa280993004.jpg.png");
|
||||
ossUtils.downloadFile("2023/07/269922ae58ef074304a907f6524d13401c微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/26ecce066aa266490b9462dd6326ad1718微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/264d37c9c96f464a3c9a25cca77312e2a6微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/07/263ab3be7a6bb24ad7b809f550e0948939微信图片_20220801215429.png");
|
||||
ossUtils.downloadFile("2023/06/16f6c3727142d4486089a09dbd19762c39266fb233a90ba449bf9c082ebd592078dd1679204678mm5.jpg");
|
||||
ossUtils.downloadFile("2023/06/1654b558f7bbc241a8aecd5f017227a3e4266fb233a90ba449bf9c082ebd592078dd1679204678mm5.jpg");
|
||||
ossUtils.downloadFile("2023/06/1638b241a1b12d4a4ebf8c5eb08bc9986d266fb233a90ba449bf9c082ebd592078dd1679204678mm5.jpg");
|
||||
ossUtils.downloadFile("2023/06/16da593a9165834cabb4ab5ed2ba580cbd266fb233a90ba449bf9c082ebd592078dd1679204678mm5.jpg");
|
||||
ossUtils.downloadFile("2023/12/03847a4833090f40de9c6b49f7d553608a微信图片_202303082336274.jpg");
|
||||
ossUtils.downloadFile("2023/12/034459c85e71e3402aba5eb7e0531201fd微信图片_202303082336273.jpg");
|
||||
ossUtils.downloadFile("2023/12/03d3e5fc569e7d42529c8a3b504ae4d92c微信图片_202303082336271.jpg");
|
||||
ossUtils.downloadFile("2023/12/0383e8c4d2be284355a07233bc1c38e6d7微信图片_202303082336272.jpg");
|
||||
ossUtils.downloadFile("2023/08/148a3892f617f04af3ab2da2dbf50b2219269922ae58ef074304a907f6524d13401c微信图片_20220801215429.png.png");
|
||||
ossUtils.downloadFile("2023/05/266fb233a90ba449bf9c082ebd592078dd1679204678mm5.jpg");
|
||||
ossUtils.downloadFile("2023/05/2602dc3dc1e02f44289c89a5426b3922femain.jpg");
|
||||
ossUtils.downloadFile("2023/05/2688e9a4a5a22847eda09c555a0f16f3a52222.png");
|
||||
ossUtils.downloadFile("2023/07/26db1efa38167a4cd5ab392cd7bb6b8fc9ed5b46ef3e460fe27f73aa280993004.jpg");
|
||||
ossUtils.downloadFile("2023/07/26079a8b93ec924d44b11915cc17dfd53e微信图片_20230415122120.jpg");
|
||||
ossUtils.downloadFile("2023/07/267eaa27402fd44f2ea12801cd263b6a41微信图片_20230507043009.jpg");
|
||||
ossUtils.downloadFile("2023/07/26d9a42d98a1a244d094b39516be0241c9微信图片_20230415121747.jpg");
|
||||
ossUtils.downloadFile("2023/07/263c45b789fb254c2fbc6bb639357b3f5f微信图片_202305311200104.jpg");
|
||||
ossUtils.downloadFile("2023/07/269436b74dd01f45a09e0d63c02bc2bc20微信图片_202207241638361.jpg");
|
||||
ossUtils.downloadFile("2023/07/2609fb7c7b52f04b29893fb7034d5488eb微信图片_20220822144529.jpg");
|
||||
ossUtils.downloadFile("2023/07/268673a92f29ea4ed9a3503587c658fb7d微信图片_20230304190516.jpg");
|
||||
ossUtils.downloadFile("2023/07/26561982918fbd4269abc1a87ea7c2f09b微信图片_20230518014301.jpg");
|
||||
ossUtils.downloadFile("2023/12/187be2528584434a488b4580c363bc559d作品.jpg");
|
||||
ossUtils.downloadFile("2023/07/26f73d933b547a4574979ee7ae3ede47f4微信图片_202304151217474.jpg");
|
||||
ossUtils.downloadFile("2023/05/26972c7a98b6df49dab1fe839232bff5c31679204678mm5.jpg");
|
||||
ossUtils.downloadFile("2023/05/267c68f6226f2a443485699c8411e299d4main.jpg");
|
||||
ossUtils.downloadFile("2023/05/26db36f518447d4df98957285931c83d7c1r.jpg");
|
||||
ossUtils.downloadFile("2023/05/2629464fb14f79418985a99ba3238b8db624.jpg");
|
||||
ossUtils.downloadFile("2023/05/267c89e30b8f8c45d58161a4e78800d4813.jpg");
|
||||
ossUtils.downloadFile("2023/05/263a48cd980e5546f8b2db583f1753c6f64.jpg");
|
||||
ossUtils.downloadFile("2023/05/263252d6187d1647c186b5c3e703615e352222.png");
|
||||
ossUtils.downloadFile("2023/07/26fb45128fd4e44b049148db359ff53c01a82772585ab081455e14bbe92afbc64.jpg");
|
||||
ossUtils.downloadFile("2023/07/2619a2b65b4ac54d10a8ccd1078d800a7bc46ad9eba9cd72a0995a1ea0c3f06dd.jpg");
|
||||
ossUtils.downloadFile("2023/07/26d43585cc52dd43e7b33d29a8812bf766微信图片_202303292142191.jpg");
|
||||
ossUtils.downloadFile("2023/07/2636761e811dfb4c1192cf3aeaf6c32a78微信图片_20230329214219.jpg");
|
||||
ossUtils.downloadFile("2023/07/26af858c07e28044baabf4670f0a18d759微信图片_202303292142192.jpg");
|
||||
ossUtils.downloadFile("2023/07/2681376357d7ae42a5b78f318c23d57e14微信图片_202304151221203.jpg");
|
||||
ossUtils.downloadFile("2023/07/261e8252d98a2f46698ca78f15107cc49f微信图片_202304151221204.jpg");
|
||||
ossUtils.downloadFile("2023/07/26abbd8208878349669e0fb7ea6df11350微信图片_202304151221201.jpg");
|
||||
ossUtils.downloadFile("2023/07/267008c38e1fd54ea593693eed573963f7微信图片_20230415122120.jpg");
|
||||
ossUtils.downloadFile("2023/07/2635b63ed15d1345d08e6a685701cc58f1微信图片_202304151221202.jpg");
|
||||
ossUtils.downloadFile("2023/07/260c209bf387f6490db6505aee72e620f5微信图片_20230507043009.jpg");
|
||||
ossUtils.downloadFile("2023/07/268dcb6126ad73407eabb54baa2fb0ec80微信图片_202305070430091.jpg");
|
||||
ossUtils.downloadFile("2023/07/262df759a436784bc481080e25a2d9d708微信图片_202305070430092.jpg");
|
||||
ossUtils.downloadFile("2023/07/26666593a296a64088af4eb0647a4e2f20微信图片_202305070430094.jpg");
|
||||
ossUtils.downloadFile("2023/07/26e1c4d225037746bea54766d2d947aae2微信图片_202305070430093.jpg");
|
||||
ossUtils.downloadFile("2023/07/265d82761866ec44a1891a03dc079951de微信图片_20230415121747.jpg");
|
||||
ossUtils.downloadFile("2023/07/266b3a6d093bc344409937958a83422c4e微信图片_202304151217471.jpg");
|
||||
ossUtils.downloadFile("2023/07/26c681b61d879d48a8a50f219bf0b45423微信图片_202304151217474.jpg");
|
||||
ossUtils.downloadFile("2023/07/26c92bd48e55634ed18ce7a49f3488a5e5微信图片_202304151217472.jpg");
|
||||
ossUtils.downloadFile("2023/07/26160d66ecfa6d4e4480936c0627ab6168微信图片_202304151217473.jpg");
|
||||
ossUtils.downloadFile("2023/07/26e91ff64478f8405a817964730d35f645微信图片_20230531120010.jpg");
|
||||
ossUtils.downloadFile("2023/07/262d7e659fc9044a35a00717d927eb6201微信图片_202305311200101.jpg");
|
||||
ossUtils.downloadFile("2023/07/26b6d799a3e30e43c4900bd726f1d87c39微信图片_202305311200103.jpg");
|
||||
ossUtils.downloadFile("2023/07/26555fabd98cdf46a58c391898c63f62f2微信图片_202305311200102.jpg");
|
||||
ossUtils.downloadFile("2023/07/26f44d84cea13f4276b92c75d072aabeea微信图片_202305311200104.jpg");
|
||||
ossUtils.downloadFile("2023/07/2627916262b7c442a08c04f1b3738a1ccc微信图片_20220724163836.jpg");
|
||||
ossUtils.downloadFile("2023/07/26ef9876f509e14e0985fb045ea4f8d02f微信图片_202207241638361.jpg");
|
||||
ossUtils.downloadFile("2023/07/26f2ac39fef9d7491a8a3908df9695ab51微信图片_202207241638362.jpg");
|
||||
ossUtils.downloadFile("2023/07/2676b97cc6b45a43ba96756e9b21dcf2cb微信图片_202207241638363.jpg");
|
||||
ossUtils.downloadFile("2023/07/263867f3bf67f248ce9c31fe0985f40523微信图片_202208221445291.jpg");
|
||||
ossUtils.downloadFile("2023/07/26feafa3cc0e584620855759538098bc4f微信图片_202208221445292.jpg");
|
||||
ossUtils.downloadFile("2023/07/268699fd3e13bb42c5a941784fe85ff366微信图片_202208221445294.jpg");
|
||||
ossUtils.downloadFile("2023/07/26b717d87954914c60893fdff0bc6eb83d微信图片_202208221445293.jpg");
|
||||
ossUtils.downloadFile("2023/07/267af6e46a2119467ab7baf569f57e0136微信图片_202303041905163.jpg");
|
||||
ossUtils.downloadFile("2023/07/26386743e26a594bdcaaf4d481d5d34b0a微信图片_202303041905164.jpg");
|
||||
ossUtils.downloadFile("2023/07/26e258e26755474d12967277e16281c0f6微信图片_202303041905165.jpg");
|
||||
ossUtils.downloadFile("2023/07/267a9d29bb17a3403e84edc968fb2a5133微信图片_202305180143012.jpg");
|
||||
ossUtils.downloadFile("2023/07/26a1f38481c8784e2782f1857b35dfacc1微信图片_202305180143014.jpg");
|
||||
ossUtils.downloadFile("2023/07/267bc956e7bb97441e98af9d07aee71f1c微信图片_202305180143013.jpg");
|
||||
ossUtils.downloadFile("2023/07/26ee7b2f3365a848c6a952a7b9c4582023微信图片_2022080121");
|
||||
ossUtils.downloadFile("2023/05/268ee9e13df1fb499697550eec576b08af1.png");
|
||||
ossUtils.downloadFile("2023/05/26795e6f86285a4cc99c21d79f3ad06e1e2.jpg");
|
||||
ossUtils.downloadFile("2023/05/26772b2920bfd04a1faf85fe6a9ff5bb953.jpg");
|
||||
ossUtils.downloadFile("2023/05/2600944930702a442583d92c3bd6ba6af94.jpg");
|
||||
ossUtils.downloadFile("2023/05/26b6ba13ad4ade4ba881466c58cb21bfd8main.jpg");
|
||||
ossUtils.downloadFile("2023/05/262961530966aa48c5a5f13860b446a0df24.jpg");
|
||||
ossUtils.downloadFile("2023/05/26d678b548b96b437cb1ca4402771525c23.jpg");
|
||||
ossUtils.downloadFile("2023/05/264d31c21f18924e02bd386dd7be61809e4.jpg");
|
||||
ossUtils.downloadFile("2023/05/26ba2304c124294ff6b47e3b7bb9faa900a.jpg");
|
||||
ossUtils.downloadFile("2023/05/26dcc01da95cb7466095ee4be3e8e57943b.jpg");
|
||||
ossUtils.downloadFile("2023/05/266a1c5e16e05b45cfbe152af9ca558b70c.png");
|
||||
ossUtils.downloadFile("2023/07/2665647ec5442d4e72960fa1772b5a2befa82772585ab081455e14bbe92afbc64.jpg");
|
||||
ossUtils.downloadFile("2023/07/26759113e01b5f4230be78447d733de531微信图片_202304151221205.jpg");
|
||||
ossUtils.downloadFile("2023/07/264e6e7ee82cb144b498757c8c2b65bf83微信图片_20230507043009.jpg");
|
||||
ossUtils.downloadFile("2023/07/26898650b538c34de399e831417c4bb69a微信图片_202304151217474.jpg");
|
||||
ossUtils.downloadFile("2023/07/269e8efd18c2784fe29898d8f0885cc688微信图片_202305311200101.jpg");
|
||||
ossUtils.downloadFile("2023/07/2688d0c5787ae54b158b88a03a3f874c68微信图片_202305311200102.jpg");
|
||||
ossUtils.downloadFile("2023/07/26596a8e6b207a474fa4e7cf5560da251d微信图片_202207241638366.jpg");
|
||||
ossUtils.downloadFile("2023/07/26832713b49dd4488eaf3c3d46b9dfe83d微信图片_202207241638367.jpg");
|
||||
ossUtils.downloadFile("2023/07/26e9928d05666e47e488491e63d8d4c7d5微信图片_20220822144529.jpg");
|
||||
ossUtils.downloadFile("2023/07/26c442b5df35c140228dde498ef4b6c1d2微信图片_202303041905161.jpg");
|
||||
ossUtils.downloadFile("2023/07/26779b5452701140d9927c698825eb93e0微信图片_202305180143011.jpg");
|
||||
ossUtils.downloadFile("2023/07/26405414f3d4134af1a786585c6780f88c微信图片_202305180143014.jpg");
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
package com.fjp.lc.test.service;
|
||||
|
||||
import com.cyl.h5.domain.form.WechatLoginForm;
|
||||
import com.cyl.manager.ums.service.MemberWechatService;
|
||||
import com.ruoyi.RuoYiApplication;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = RuoYiApplication.class)
|
||||
@ActiveProfiles("dev")
|
||||
public class WechatTest {
|
||||
@Autowired
|
||||
private MemberWechatService memberWechatService;
|
||||
@Test
|
||||
public void testAuth() {
|
||||
WechatLoginForm f = new WechatLoginForm();
|
||||
f.setCode("081zPgHa1FbRQE0wGIIa1lgb1C1zPgHi");
|
||||
memberWechatService.login(f);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.ruoyi.common.core.domain;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RestResponse extends HashMap<String, Object> {
|
||||
public static RestResponse success(){
|
||||
return success("成功");
|
||||
}
|
||||
public static RestResponse success(String message){
|
||||
RestResponse restResponse = new RestResponse();
|
||||
restResponse.setSuccess(true);
|
||||
restResponse.setMessage(message);
|
||||
return restResponse;
|
||||
}
|
||||
|
||||
public static RestResponse failure(String message){
|
||||
RestResponse restResponse = new RestResponse();
|
||||
restResponse.setSuccess(false);
|
||||
restResponse.setMessage(message);
|
||||
return restResponse;
|
||||
}
|
||||
|
||||
|
||||
public RestResponse setSuccess(Boolean success) {
|
||||
if (success != null) put("success", success);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestResponse setMessage(String message) {
|
||||
if (message != null) put("message", message);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestResponse setData(Object data) {
|
||||
if (data != null) put("data", data);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestResponse setPage(Integer page) {
|
||||
if (page != null) put("page", page);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestResponse setCurrentPage(Integer currentPage){
|
||||
if (currentPage != null) put("currentPage", currentPage);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestResponse setLimit(Integer limit) {
|
||||
if (limit != null) put("limit", limit);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestResponse setTotal(Long total) {
|
||||
if (total != null) put("total", total);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestResponse setAny(String key, Object value) {
|
||||
if (key != null && value != null) put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean getSuccess(){
|
||||
return (Boolean) get("success");
|
||||
}
|
||||
public String getMessage(){
|
||||
return (String) get("message");
|
||||
}
|
||||
public String toString(){
|
||||
// return JSONObject.toJSONString(this);
|
||||
return JSONUtil.toJsonStr(this);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package com.ruoyi.system.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UploadImageVO {
|
||||
|
||||
|
||||
private String originUrl;//*"原图"
|
||||
|
||||
|
||||
private String thumbUrl;//缩略图
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.system.domain.FileInfo;
|
||||
|
||||
public interface FileInfoMapper extends BaseMapper<FileInfo> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package com.ruoyi.system.minioConfig;
|
||||
|
||||
import com.ruoyi.system.thirdparty.MinioProperties;
|
||||
import io.minio.MinioClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MinIoClientConfig {
|
||||
|
||||
@Bean
|
||||
public MinioClient minioClient(MinioProperties minioProps) {
|
||||
// 注入minio 客户端
|
||||
return MinioClient.builder()
|
||||
.endpoint(minioProps.getEndpoint())
|
||||
.credentials(minioProps.getAccessKey(), minioProps.getSecretKey())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.system.domain.FileInfo;
|
||||
import com.ruoyi.system.domain.vo.UploadImageVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface FileService extends IService<FileInfo> {
|
||||
|
||||
String uploadFile(MultipartFile file);
|
||||
|
||||
UploadImageVO uploadProductImage(MultipartFile file);
|
||||
UploadImageVO uploadCourseImage(MultipartFile file);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.ruoyi.system.thirdparty;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "minio")
|
||||
public class MinioProperties {
|
||||
|
||||
private String endpoint;
|
||||
|
||||
private String accessKey;
|
||||
|
||||
private String secretKey;
|
||||
|
||||
private String domain;
|
||||
|
||||
private String bucketName;
|
||||
|
||||
private String productImagePath;
|
||||
private String courseImagePath;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private String videoPath;
|
||||
|
||||
private Integer expireIn;
|
||||
}
|
||||
@ -0,0 +1,167 @@
|
||||
package com.ruoyi.system.thirdparty;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import io.minio.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MinioService {
|
||||
|
||||
|
||||
private final MinioClient minioClient;
|
||||
|
||||
/**
|
||||
* 查看存储bucket是否存在
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public Boolean bucketExists(String bucketName) {
|
||||
try {
|
||||
return minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
|
||||
} catch (Exception e) {
|
||||
log.error("查询bucket失败", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建存储bucket
|
||||
*/
|
||||
public void makeBucket(String bucketName) {
|
||||
try {
|
||||
minioClient.makeBucket(MakeBucketArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
log.error("创建bucket失败,", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置bucket权限为public
|
||||
*/
|
||||
public void setBucketPublic(String bucketName) {
|
||||
try {
|
||||
// 设置公开
|
||||
String sb = "{\"Version\":\"2012-10-17\"," +
|
||||
"\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":" +
|
||||
"{\"AWS\":[\"*\"]},\"Action\":[\"s3:ListBucket\",\"s3:ListBucketMultipartUploads\"," +
|
||||
"\"s3:GetBucketLocation\"],\"Resource\":[\"arn:aws:s3:::" + bucketName +
|
||||
"\"]},{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":[\"*\"]},\"Action\":[\"s3:PutObject\",\"s3:AbortMultipartUpload\",\"s3:DeleteObject\",\"s3:GetObject\",\"s3:ListMultipartUploadParts\"],\"Resource\":[\"arn:aws:s3:::" +
|
||||
bucketName +
|
||||
"/*\"]}]}";
|
||||
minioClient.setBucketPolicy(
|
||||
SetBucketPolicyArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.config(sb)
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
log.error("创建bucket失败,", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param bucketName bucket名称
|
||||
* @param path 路径
|
||||
* @param file 文件
|
||||
* @return Boolean
|
||||
*/
|
||||
public String upload(String bucketName, String path, MultipartFile file) {
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
if (StringUtils.isBlank(originalFilename)) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
String fileName = System.currentTimeMillis() + "";
|
||||
if (originalFilename.lastIndexOf(".") >= 0) {
|
||||
fileName += originalFilename.substring(originalFilename.lastIndexOf("."));
|
||||
}
|
||||
String objectName = DateUtils.parseDateToStr("yyyyMMdd", new Date()) + "/" + fileName;
|
||||
try {
|
||||
InputStream stream = new ByteArrayInputStream(file.getBytes());
|
||||
PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(bucketName).object(path + "/" + objectName)
|
||||
.stream(stream, file.getSize(), -1).contentType(file.getContentType()).build();
|
||||
//文件名称相同会覆盖
|
||||
minioClient.putObject(objectArgs);
|
||||
} catch (Exception e) {
|
||||
log.error("上传图片失败,", e);
|
||||
return null;
|
||||
}
|
||||
return objectName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*
|
||||
* @param bucketName bucket名称
|
||||
* @param path 路径
|
||||
* @param name 文件名
|
||||
* @param fileByte 文件内容
|
||||
* @param contentType contentType
|
||||
* @return objectName
|
||||
*/
|
||||
public String upload(String bucketName, String path, String name, byte[] fileByte, String contentType) {
|
||||
|
||||
String fileName = System.currentTimeMillis() + name.substring(name.lastIndexOf("."));
|
||||
String objectName = DateUtils.parseDateToStr("yyyyMMdd", new Date()) + "/" + fileName;
|
||||
try {
|
||||
InputStream stream = new ByteArrayInputStream(fileByte);
|
||||
PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(bucketName).object(path + "/" + objectName)
|
||||
.stream(stream, fileByte.length, -1).contentType(contentType).build();
|
||||
//文件名称相同会覆盖
|
||||
minioClient.putObject(objectArgs);
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败,", e);
|
||||
return null;
|
||||
}
|
||||
return objectName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param bucketName bucket名称
|
||||
* @param path 路径
|
||||
* @param fileName 文件名
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean remove(String bucketName, String path, String fileName) {
|
||||
try {
|
||||
minioClient.removeObject(RemoveObjectArgs.builder().bucket(bucketName).object(path + "/" + fileName).build());
|
||||
} catch (Exception e) {
|
||||
log.error("删除文件失败,", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文件是否存在
|
||||
*
|
||||
* @param bucketName bucket名称
|
||||
* @param path 路径
|
||||
* @param fileName 文件名
|
||||
* @return
|
||||
*/
|
||||
public Boolean isExist(String bucketName, String path, String fileName) {
|
||||
try {
|
||||
minioClient.statObject(StatObjectArgs.builder().bucket(bucketName).object(path + "/" + fileName).build());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue