代码提交

This commit is contained in:
glj 2023-04-11 08:51:29 +08:00
parent ef795818c1
commit b23d0eb500
10 changed files with 178 additions and 27 deletions

View File

@ -1,8 +1,10 @@
package com.kening.vordm.vo; package com.kening.vordm.vo;
import lombok.Data; import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
public class EntityDataUserVo { public class EntityDataUserVo {
@ -131,4 +133,14 @@ public class EntityDataUserVo {
* 职称 * 职称
*/ */
private String professionalTitle; private String professionalTitle;
/**
* 职称
*/
private String key;
/**
* 文件信息
*/
private List<MultipartFile> filesArray;
} }

View File

@ -0,0 +1,20 @@
package com.kening.vordm.vo;
import lombok.Data;
@Data
public class FileVo {
//文件大小
private Long fileSize;
//获取文件类型
private String fileType;
//文件后缀
private String fileSuffix;
//文件存储路径
private String link;
}

View File

@ -0,0 +1,41 @@
package com.kening.vordm.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springblade.common.cache.CacheNames;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.redis.cache.BladeRedis;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author wanghongqing
* @date 2023/3/31 11:10
**/
@RestController
@RequestMapping("/captcha")
@RequiredArgsConstructor
@Api(value = "验证码校验接口", tags = "验证码校验")
public class CaptchaController extends BladeController {
private final BladeRedis bladeRedis;
@PostMapping("/validate")
@ApiOperation(value = "验证码校验", notes = "传入需要校验的验证码以及缓存Key")
public R<String> validDefaultTime(@RequestParam String code, @RequestParam String key) {
// 获取验证码
String redisCode = bladeRedis.get(CacheNames.CAPTCHA_KEY + key);
// 判断验证码
if (code == null || !StringUtil.equalsIgnoreCase(redisCode, code)) {
return R.fail(1404, "Verification code error");
}
return R.success("OK");
}
}

View File

@ -47,7 +47,7 @@ public class EntityDataController {
* @return * @return
*/ */
@PostMapping("/saveEntityData") @PostMapping("/saveEntityData")
public R saveEntityData(@RequestBody EntityDataUserVo entityDataUserVo) { public R saveEntityData(EntityDataUserVo entityDataUserVo) {
return R.data(entityDataService.saveEntityData(entityDataUserVo)); return R.data(entityDataService.saveEntityData(entityDataUserVo));
} }
} }

View File

@ -0,0 +1,50 @@
package com.kening.vordm.controller;
import cn.hutool.core.date.DateUtil;
import com.kening.vordm.vo.FileVo;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.oss.MinioTemplate;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RequestMapping("/ui/upload")
@RestController
@Slf4j
public class FileController {
/**
* 对象存储模块
*/
@Autowired
private MinioTemplate minioTemplate;
/**
* 上传文件
* @param file
* @return
*/
@PostMapping("/uploadFile")
public R upload(MultipartFile file){
BladeFile bladeFile = minioTemplate.putFile(file);
//获取文件大小
Long fileSize = file.getSize();
//获取文件类型
String fileType = file.getContentType();
//文件后缀
String fileSuffix = file.getOriginalFilename();
//文件存储路径
String link = bladeFile.getLink();
FileVo fileVo = new FileVo();
fileVo.setFileSize(fileSize);
fileVo.setFileType(fileType);
fileVo.setFileSuffix(fileSuffix);
fileVo.setLink(link);
return R.data(bladeFile);
}
}

View File

@ -34,6 +34,9 @@ public class RemoteSensingSourceDataController {
@GetMapping("/SourceData") @GetMapping("/SourceData")
public R<IPage<RemoteSensingSourceData>> getRemoteSensingSourceData(DisasterInfo disasterInfo, Query query){ public R<IPage<RemoteSensingSourceData>> getRemoteSensingSourceData(DisasterInfo disasterInfo, Query query){
List<Long> disasterIds = disasterInfoService.getDisasterId(disasterInfo); List<Long> disasterIds = disasterInfoService.getDisasterId(disasterInfo);
if (disasterIds.isEmpty()){
return R.data(null);
}
return R.data(remoteSensingSourceDataService.page(Condition.getPage(query),new QueryWrapper<RemoteSensingSourceData>().in("disaster_id",disasterIds))); return R.data(remoteSensingSourceDataService.page(Condition.getPage(query),new QueryWrapper<RemoteSensingSourceData>().in("disaster_id",disasterIds)));
} }

View File

@ -46,23 +46,23 @@ implements DisasterInfoService {
public List<Long> getDisasterId(DisasterInfo disasterInfo){ public List<Long> getDisasterId(DisasterInfo disasterInfo){
QueryWrapper<DisasterInfo> qw = new QueryWrapper<>(); QueryWrapper<DisasterInfo> qw = new QueryWrapper<>();
if (disasterInfo.getDisasterType()!=null){ if (disasterInfo.getDisasterType()!=null){
qw.like("disaster_type",disasterInfo.getDisasterType()); qw.eq("disaster_type",disasterInfo.getDisasterType());
} }
if (disasterInfo.getDisasterCountry()!=null){ if (disasterInfo.getDisasterCountry()!=null){
qw.like("disaster_country",disasterInfo.getDisasterCountry()); qw.eq("disaster_country",disasterInfo.getDisasterCountry());
} }
if (disasterInfo.getDisasterTime()!=null){ if (disasterInfo.getDisasterTime()!=null){
qw.like("disaster_time",disasterInfo.getDisasterTime()); qw.eq("disaster_time",disasterInfo.getDisasterTime());
} }
List<DisasterInfo> disasterInfos = this.baseMapper.selectList(qw); List<DisasterInfo> disasterInfos = this.baseMapper.selectList(qw);
if (!disasterInfos.isEmpty()){
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
if (!disasterInfos.isEmpty()){
disasterInfos.stream().forEach(disasterInfo1 -> { disasterInfos.stream().forEach(disasterInfo1 -> {
ids .add(disasterInfo1.getId()); ids .add(disasterInfo1.getId());
}); });
return ids; return ids;
} }
return null; return ids;
} }
/** /**

View File

@ -9,12 +9,21 @@ import com.kening.vordm.mapper.EntityDataMapper;
import com.kening.vordm.mapper.GuestInfoMapper; import com.kening.vordm.mapper.GuestInfoMapper;
import com.kening.vordm.service.EntityDataService; import com.kening.vordm.service.EntityDataService;
import com.kening.vordm.vo.EntityDataUserVo; import com.kening.vordm.vo.EntityDataUserVo;
import com.kening.vordm.vo.FileVo;
import com.kening.vordm.vo.UserTenantVo; import com.kening.vordm.vo.UserTenantVo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.oss.MinioTemplate;
import org.springblade.core.oss.model.BladeFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -31,6 +40,11 @@ public class EntityDataServiceImpl extends ServiceImpl<EntityDataMapper, EntityD
private GuestInfoMapper guestInfoMapper; private GuestInfoMapper guestInfoMapper;
/**
* 对象存储模块
*/
private MinioTemplate minioTemplate;
@Override @Override
public IPage<EntityData> getEntityDataList(IPage<Object> page, EntityData entityData) { public IPage<EntityData> getEntityDataList(IPage<Object> page, EntityData entityData) {
return this.baseMapper.getEntityDataList(entityData, page); return this.baseMapper.getEntityDataList(entityData, page);
@ -83,5 +97,16 @@ public class EntityDataServiceImpl extends ServiceImpl<EntityDataMapper, EntityD
return this.baseMapper.insert(entityData)>1; return this.baseMapper.insert(entityData)>1;
} }
public static MultipartFile fileToMultipartFile(File file) {
MultipartFile result = null;
if (null != file) {
try (FileInputStream input = new FileInputStream(file)) {
result = new MockMultipartFile(file.getName().concat("temp"), file.getName(), "text/plain", input);
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
} }

View File

@ -1,19 +0,0 @@
<?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="com.kening.vordm.mapper.ContactMapper">
<resultMap id="BaseResultMap" type="com.kening.vordm.entity.Contact">
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
<result property="email" column="email" jdbcType="VARCHAR"/>
<result property="organization" column="organization" jdbcType="VARCHAR"/>
<result property="message" column="message" jdbcType="VARCHAR"/>
<result property="id" column="id" jdbcType="BIGINT"/>
</resultMap>
<sql id="Base_Column_List">
user_name,email,organization,
message,id
</sql>
</mapper>

View File

@ -65,6 +65,25 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-starter-oss</artifactId>
<exclusions>
<exclusion>
<artifactId>esdk-obs-java</artifactId>
<groupId>com.huaweicloud</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>2.0.8</version>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>