tangzy
2022-03-07 5967ac85f70929f3c7157eb6715d55e5ebcdd0d7
1。VR实景
2.文件上传接口
5 files modified
7 files added
471 ■■■■■ changed files
src/main/java/org/springblade/common/config/BladeConfiguration.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/resource/builder/oss/OssBuilder.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java 56 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/tagging/controller/TaggingController.java 51 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/tagging/entity/Tagging.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/vr/controller/VrController.java 126 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/vr/dto/VrDTO.java 34 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/vr/entity/Vr.java 58 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/vr/mapper/VrMapper.java 42 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/vr/mapper/VrMapper.xml 17 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/vr/service/impl/VrServiceImpl.java 41 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/vr/vo/VrVO.java 36 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/config/BladeConfiguration.java
@@ -72,6 +72,7 @@
        secureRegistry.excludePathPatterns("/qrCode/**");
        secureRegistry.excludePathPatterns("/blade-hd/hd/**");
        secureRegistry.excludePathPatterns("/tagging/tagging/**");
        secureRegistry.excludePathPatterns("/blade-resource/oss/endpoint/**");
        return secureRegistry;
    }
src/main/java/org/springblade/modules/resource/builder/oss/OssBuilder.java
@@ -132,6 +132,10 @@
            lqw.eq(Oss::getOssCode, ossCode);
        } else {
            lqw.eq(Oss::getStatus, OssStatusEnum.ENABLE.getNum());
            Oss o= ossService.getOne(lqw);
            if(Func.notNull(o)){
                key=o.getOssCode();
            }
        }
        Oss oss = CacheUtil.get(RESOURCE_CACHE, OSS_CODE, key, () -> {
            Oss o = ossService.getOne(lqw);
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -16,6 +16,8 @@
 */
package org.springblade.modules.resource.endpoint;
import io.minio.*;
import io.minio.errors.*;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
@@ -33,6 +35,14 @@
import org.springblade.modules.resource.service.IAttachService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
 * 对象存储端点
@@ -244,4 +254,50 @@
        return R.success("操作成功");
    }
    /**
     * 文件上传,个人头像上传
     *
     * @param file 图片对象
     */
    @PostMapping("put-files-talk")
    public String putFilestak(@RequestParam MultipartFile file) throws IOException, ServerException, InsufficientDataException, InternalException, InvalidResponseException, InvalidKeyException, NoSuchAlgorithmException, XmlParserException, ErrorResponseException {
        //填写你文件上传的地址以及相应信息
        String url = "http://223.82.109.183:2081";
        String access = "zhbaadmin";
        String secret = "zhbapassword";
        String bucket = "zhxy";
        MinioClient minioClient =
            MinioClient.builder()
                .endpoint(url)
                .credentials(access, secret)
                .build();
        // 检查存储桶是否已经存在
        boolean isExist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucket).build());
        if (!isExist) {
            // 创建一个名为zip的存储桶,用于zip文件。
            minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucket).build());
            minioClient.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).build());
        }
        String fileName = file.getOriginalFilename();
        String newName = "upload/picture/" + UUID.randomUUID().toString().replaceAll("-", "")
            + fileName.substring(fileName.lastIndexOf("."));
        InputStream in = file.getInputStream();
        String[] split = newName.split("/");
        //创建头部信息
        Map<String, String> headers = new HashMap<>(1 << 2);
        //添加自定义内容类型
        headers.put("Content-Type", "application/octet-stream");
        //上传
        minioClient.putObject(
            PutObjectArgs.builder().bucket(bucket).object(newName).stream(
                in, in.available(), -1)
                .headers(headers)
                .build());
        //文件推送
        String urls = "http://223.82.109.183:2081/zhxy/"+newName;
        //返回
        return urls;
    }
}
src/main/java/org/springblade/modules/tagging/controller/TaggingController.java
@@ -16,13 +16,18 @@
 */
package org.springblade.modules.tagging.controller;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.zxing.WriterException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.common.utils.QRCodeUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
@@ -33,9 +38,16 @@
import org.springblade.modules.tagging.vo.TaggingVO;
import org.springblade.modules.tagging.service.ITaggingService;
import org.springblade.core.boot.ctrl.BladeController;
import sun.misc.BASE64Encoder;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import static org.springblade.common.config.qCodeConfig.*;
/**
 *  控制器
 * 控制器
 *
 * @author BladeX
 * @since 2022-02-17
@@ -60,7 +72,7 @@
    }
    /**
     * 分页
     * 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
@@ -71,7 +83,7 @@
    }
    /**
     * 自定义分页
     * 自定义分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
@@ -82,17 +94,36 @@
    }
    /**
     * 新增
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入tagging")
    public R save(@Valid @RequestBody Tagging tagging) {
    public R save(@Valid @RequestBody Tagging tagging) throws IOException, WriterException {
        String path = "D:\\QrCode\\";
        FileOutputStream fileOutputStream = null;
        //本地url地址
        String urlz = locaPath;
        System.out.println(urlz);
        //String url = "http://192.168.0.222:8080/#/mobileLayout/default?data=";
        String url = "http://171.34.197.243:786/#/mobileLayout/default?data=";
        JsonObject lan1 = new JsonObject();
        lan1.addProperty("methods", "goto");
        lan1.addProperty("jd", URLEncoder.encode(tagging.getJd(), "UTF-8"));
        lan1.addProperty("wd", URLEncoder.encode(tagging.getWd(), "UTF-8"));
        lan1.addProperty("name", URLEncoder.encode(tagging.getName(), "UTF-8"));
        String urls = url + lan1;
        //生成标注二维码
        byte[] qrCodeImage = QRCodeUtil.getQRCodeImage(urls, 350, 350);
        String encode = new BASE64Encoder().encode(qrCodeImage);
        //设置二维码
        String a = "data:image/png;base64," + encode;
        tagging.setQrcode(a);
        return R.status(taggingService.save(tagging));
    }
    /**
     * 修改
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
@@ -102,7 +133,7 @@
    }
    /**
     * 新增或修改
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
@@ -111,9 +142,9 @@
        return R.status(taggingService.saveOrUpdate(tagging));
    }
    /**
     * 删除
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 8)
@@ -121,6 +152,4 @@
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(taggingService.removeByIds(Func.toLongList(ids)));
    }
}
src/main/java/org/springblade/modules/tagging/entity/Tagging.java
@@ -16,6 +16,8 @@
 */
package org.springblade.modules.tagging.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -42,6 +44,9 @@
    private String name;
    private String jd;
    private String wd;
    @ColumnWidth(16)
    @ExcelProperty("二维码图片")
    private String qrcode;
}
src/main/java/org/springblade/modules/vr/controller/VrController.java
New file
@@ -0,0 +1,126 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.vr.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.vr.entity.Vr;
import org.springblade.modules.vr.vo.VrVO;
import org.springblade.modules.vr.service.IVrService;
import org.springblade.core.boot.ctrl.BladeController;
/**
 *  控制器
 *
 * @author BladeX
 * @since 2022-03-03
 */
@RestController
@AllArgsConstructor
@RequestMapping("blade-vr/vr")
@Api(value = "", tags = "接口")
public class VrController extends BladeController {
    private final IVrService vrService;
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入vr")
    public R<Vr> detail(Vr vr) {
        Vr detail = vrService.getOne(Condition.getQueryWrapper(vr));
        return R.data(detail);
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入vr")
    public R<IPage<Vr>> list(Vr vr, Query query) {
        IPage<Vr> pages = vrService.page(Condition.getPage(query), Condition.getQueryWrapper(vr));
        return R.data(pages);
    }
    /**
     * 自定义分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入vr")
    public R<IPage<VrVO>> page(VrVO vr, Query query) {
        IPage<VrVO> pages = vrService.selectVrPage(Condition.getPage(query), vr);
        return R.data(pages);
    }
    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入vr")
    public R save(@Valid @RequestBody Vr vr) {
        return R.status(vrService.save(vr));
    }
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入vr")
    public R update(@Valid @RequestBody Vr vr) {
        return R.status(vrService.updateById(vr));
    }
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入vr")
    public R submit(@Valid @RequestBody Vr vr) {
        return R.status(vrService.saveOrUpdate(vr));
    }
    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(vrService.removeByIds(Func.toLongList(ids)));
    }
}
src/main/java/org/springblade/modules/vr/dto/VrDTO.java
New file
@@ -0,0 +1,34 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.vr.dto;
import org.springblade.modules.vr.entity.Vr;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * 数据传输对象实体类
 *
 * @author BladeX
 * @since 2022-03-03
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class VrDTO extends Vr {
    private static final long serialVersionUID = 1L;
}
src/main/java/org/springblade/modules/vr/entity/Vr.java
New file
@@ -0,0 +1,58 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.vr.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
 * 实体类
 *
 * @author BladeX
 * @since 2022-03-03
 */
@Data
@TableName("sys_vr")
@ApiModel(value = "Vr对象", description = "Vr对象")
public class Vr implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
    * VR名称
    */
        @ApiModelProperty(value = "VR名称")
        @TableField("VrName")
    private String vrname;
    /**
    * VR地址
    */
        @ApiModelProperty(value = "VR地址")
        @TableField("VrUrl")
    private String vrurl;
}
src/main/java/org/springblade/modules/vr/mapper/VrMapper.java
New file
@@ -0,0 +1,42 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.vr.mapper;
import org.springblade.modules.vr.entity.Vr;
import org.springblade.modules.vr.vo.VrVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
 *  Mapper 接口
 *
 * @author BladeX
 * @since 2022-03-03
 */
public interface VrMapper extends BaseMapper<Vr> {
    /**
     * 自定义分页
     *
     * @param page
     * @param vr
     * @return
     */
    List<VrVO> selectVrPage(IPage page, VrVO vr);
}
src/main/java/org/springblade/modules/vr/mapper/VrMapper.xml
New file
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.vr.mapper.VrMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="vrResultMap" type="org.springblade.modules.vr.entity.Vr">
        <id column="id" property="id"/>
        <result column="VrName" property="vrname"/>
        <result column="VrUrl" property="vrurl"/>
    </resultMap>
    <select id="selectVrPage" resultMap="vrResultMap">
        select * from sys_vr where is_deleted = 0
    </select>
</mapper>
src/main/java/org/springblade/modules/vr/service/impl/VrServiceImpl.java
New file
@@ -0,0 +1,41 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.vr.service.impl;
import org.springblade.modules.vr.entity.Vr;
import org.springblade.modules.vr.vo.VrVO;
import org.springblade.modules.vr.mapper.VrMapper;
import org.springblade.modules.vr.service.IVrService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
/**
 *  服务实现类
 *
 * @author BladeX
 * @since 2022-03-03
 */
@Service
public class VrServiceImpl extends ServiceImpl<VrMapper, Vr> implements IVrService {
    @Override
    public IPage<VrVO> selectVrPage(IPage<VrVO> page, VrVO vr) {
        return page.setRecords(baseMapper.selectVrPage(page, vr));
    }
}
src/main/java/org/springblade/modules/vr/vo/VrVO.java
New file
@@ -0,0 +1,36 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.vr.vo;
import org.springblade.modules.vr.entity.Vr;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
/**
 * 视图实体类
 *
 * @author BladeX
 * @since 2022-03-03
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "VrVO对象", description = "VrVO对象")
public class VrVO extends Vr {
    private static final long serialVersionUID = 1L;
}