| | |
| | | */ |
| | | package org.springblade.modules.architecture.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.google.zxing.WriterException; |
| | | import io.minio.*; |
| | | import io.minio.errors.*; |
| | |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.oss.model.BladeFile; |
| | | import org.springblade.core.oss.model.OssFile; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.life.entity.Life; |
| | |
| | | import org.springblade.modules.mechanism.entity.Mechanism; |
| | | import org.springblade.modules.mechanism.service.IMechanismService; |
| | | import org.springblade.modules.resource.builder.oss.OssBuilder; |
| | | import org.springblade.modules.resource.entity.Oss; |
| | | import org.springblade.modules.resource.service.IOssService; |
| | | import org.springframework.core.io.support.ResourceRegion; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | @RequestMapping("blade-architecture/architecture") |
| | | @Api(value = "", tags = "接口") |
| | | public class ArchitectureController extends BladeController { |
| | | |
| | | |
| | | private final IOssService ossService; |
| | | |
| | | private final IArchitectureService architectureService; |
| | | private final IMechanismService mechanismService; |
| | |
| | | } |
| | | |
| | | private String upload(ByteArrayInputStream in) throws IOException, InvalidKeyException, InvalidResponseException, InsufficientDataException, NoSuchAlgorithmException, ServerException, InternalException, XmlParserException, ErrorResponseException { |
| | | QueryWrapper<Oss> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0); |
| | | Oss one = ossService.getOne(wrapper); |
| | | //填写你文件上传的地址以及相应信息 |
| | | String url = "http://106.225.193.35:2081"; |
| | | String access = "zhbaadmin"; |
| | | String secret = "zhbapassword"; |
| | | String bucket = "zhxy"; |
| | | // String url = "http://106.225.193.35:2081"; |
| | | // String access = "zhbaadmin"; |
| | | // String secret = "zhbapassword"; |
| | | // String bucket = "zhxy"; |
| | | String url = one.getEndpoint(); |
| | | String access = one.getAccessKey(); |
| | | String secret = one.getSecretKey(); |
| | | String bucket = one.getBucketName(); |
| | | |
| | | MinioClient minioClient = |
| | | MinioClient.builder() |
| | | .endpoint(url) |
| | |
| | | .build()); |
| | | |
| | | //文件推送 |
| | | String urls = "https://dev.jxpskj.com:8023/zhxy/"+newName; |
| | | String urls = url + "/"+ bucket +"/" + newName; |
| | | //返回 |
| | | return urls; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 二维码重新生成 code url 转换 |
| | | */ |
| | | @GetMapping("/refreshCode") |
| | | public void refreshCode() throws IOException, ServerException, InsufficientDataException, NoSuchAlgorithmException, InternalException, InvalidResponseException, XmlParserException, InvalidKeyException, ErrorResponseException { |
| | | List<Architecture> list = architectureService.selectArchALL(); |
| | | for (Architecture architecture : list) { |
| | | int index = architecture.getCodeurl().lastIndexOf(",") +1; |
| | | String substring = architecture.getCodeurl().substring(index); |
| | | byte[] qrCodeImage = Base64Util.decode(substring); |
| | | ByteArrayInputStream inputStream = new ByteArrayInputStream(qrCodeImage); |
| | | String url = upload(inputStream); |
| | | architecture.setCodeurl(url); |
| | | architectureService.updateById(architecture); |
| | | //关闭流 |
| | | inputStream.close(); |
| | | } |
| | | } |
| | | } |