添加各个接口
parent
658298b072
commit
cffc10349c
|
@ -0,0 +1,71 @@
|
||||||
|
package com.four.system.Test;
|
||||||
|
|
||||||
|
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||||
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: 0107day02
|
||||||
|
* @Author: tzz
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class FastUtil {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FastFileStorageClient storageClient ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件 / 视频
|
||||||
|
*/
|
||||||
|
public String uploadFile(MultipartFile multipartFile) throws Exception{
|
||||||
|
long size = multipartFile.getSize();
|
||||||
|
|
||||||
|
String originalFilename = multipartFile.getOriginalFilename().
|
||||||
|
substring(multipartFile.getOriginalFilename().
|
||||||
|
lastIndexOf(".") + 1);
|
||||||
|
|
||||||
|
StorePath storePath = storageClient.uploadFile(multipartFile.getInputStream(),multipartFile.getSize(),originalFilename,null);
|
||||||
|
|
||||||
|
return storePath.getFullPath() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传图片
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String uploadImage(MultipartFile file) throws Exception{
|
||||||
|
String originalFilename = file.getOriginalFilename().
|
||||||
|
substring(file.getOriginalFilename().
|
||||||
|
lastIndexOf(".") + 1);
|
||||||
|
StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
|
||||||
|
file.getInputStream(),
|
||||||
|
file.getSize(),originalFilename , null);
|
||||||
|
return storePath.getFullPath() ;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除文件
|
||||||
|
*/
|
||||||
|
public String deleteFile(String fileUrl) {
|
||||||
|
if (StringUtils.isEmpty(fileUrl)) {
|
||||||
|
log.info("fileUrl == >>文件路径为空...");
|
||||||
|
return "文件路径不能为空";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StorePath storePath = StorePath.parseFromUrl(fileUrl);
|
||||||
|
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return "删除成功";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.four.system.controller;
|
||||||
|
|
||||||
|
import com.aliyun.facebody20191230.Client;
|
||||||
|
import com.aliyun.facebody20191230.models.SearchFaceAdvanceRequest;
|
||||||
|
import com.aliyun.facebody20191230.models.SearchFaceResponse;
|
||||||
|
import com.aliyun.tea.TeaException;
|
||||||
|
import com.aliyun.tea.TeaModel;
|
||||||
|
import com.aliyun.teautil.Common;
|
||||||
|
import com.aliyun.teautil.models.RuntimeOptions;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : tangzhaozhen
|
||||||
|
* @createTime : 2023/10/26 23:51
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class SampleTest {
|
||||||
|
|
||||||
|
public static com.aliyun.facebody20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
||||||
|
/*
|
||||||
|
初始化配置对象com.aliyun.teaopenapi.models.Config
|
||||||
|
Config对象存放 AccessKeyId、AccessKeySecret、endpoint等配置
|
||||||
|
*/
|
||||||
|
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
|
.setAccessKeyId("LTAI5tENBECpxHRiWzidh93H")
|
||||||
|
.setAccessKeySecret("MYHeKEYHsAZ1hDGDEKChnFNrglgJ24");
|
||||||
|
// 访问的域名
|
||||||
|
config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
|
||||||
|
return new com.aliyun.facebody20191230.Client(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFaceLanding(String images) throws Exception {
|
||||||
|
// 创建AccessKey ID和AccessKey Secret,请参考https://help.aliyun.com/document_detail/175144.html
|
||||||
|
// 如果您使用的是RAM用户的AccessKey,还需要为子账号授予权限AliyunVIAPIFullAccess,请参考https://help.aliyun.com/document_detail/145025.html
|
||||||
|
// 从环境变量读取配置的AccessKey ID和AccessKey Secret。运行代码示例前必须先配置环境变量。
|
||||||
|
String accessKeyId = "LTAI5tENBECpxHRiWzidh93H";
|
||||||
|
String accessKeySecret = "MYHeKEYHsAZ1hDGDEKChnFNrglgJ24";
|
||||||
|
Client client = SampleTest.createClient(accessKeyId, accessKeySecret);
|
||||||
|
//// 场景一,使用本地文件
|
||||||
|
// InputStream inputStream = new FileInputStream(new File("C:\\Users\\a2075\\Desktop\\SearchFace1.png"));
|
||||||
|
// // 场景二,使用任意可访问的url
|
||||||
|
URL url = new URL(images);
|
||||||
|
InputStream inputStream = url.openConnection().getInputStream();
|
||||||
|
SearchFaceAdvanceRequest searchFaceAdvanceRequest = new SearchFaceAdvanceRequest()
|
||||||
|
.setDbName("four_aliyun")
|
||||||
|
.setLimit(1)
|
||||||
|
.setImageUrlObject(inputStream);
|
||||||
|
RuntimeOptions runtime = new RuntimeOptions();
|
||||||
|
try {
|
||||||
|
// 复制代码运行请自行打印 API 的返回值
|
||||||
|
SearchFaceResponse searchFaceResponse = client.searchFaceAdvance(searchFaceAdvanceRequest, runtime);
|
||||||
|
// 获取整体结果
|
||||||
|
System.out.println(Common.toJSONString(TeaModel.buildMap(searchFaceResponse)));
|
||||||
|
|
||||||
|
// 获取单个字段:Confidence转换后的置信度
|
||||||
|
Float confidence = searchFaceResponse.getBody().getData().getMatchList().iterator().next().getFaceItems().iterator().next().getConfidence();
|
||||||
|
System.out.println("对比度为:"+confidence);
|
||||||
|
if (confidence > 75){
|
||||||
|
String entityId = searchFaceResponse.getBody().getData().getMatchList().iterator().next().getFaceItems().iterator().next().getEntityId();
|
||||||
|
System.out.println("confidence对比值为:"+confidence);
|
||||||
|
System.out.println("entityId为:"+entityId);
|
||||||
|
return entityId+"@qq.com";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} catch (TeaException teaException) {
|
||||||
|
// 获取整体报错信息
|
||||||
|
System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
|
||||||
|
// 获取单个字段
|
||||||
|
System.out.println(teaException.getCode());
|
||||||
|
return "500";
|
||||||
|
}
|
||||||
|
return "请先去录制人脸";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,8 @@ package com.four.system.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.four.common.core.domain.R;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
@ -27,10 +29,11 @@ import com.four.system.domain.SysUserRole;
|
||||||
import com.four.system.service.ISysDeptService;
|
import com.four.system.service.ISysDeptService;
|
||||||
import com.four.system.service.ISysRoleService;
|
import com.four.system.service.ISysRoleService;
|
||||||
import com.four.system.service.ISysUserService;
|
import com.four.system.service.ISysUserService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色信息
|
* 角色信息
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -97,6 +100,19 @@ public class SysRoleController extends BaseController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
*人脸
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/searchBaidu")
|
||||||
|
public R<?> searchBaidu(@RequestBody MultipartFile file){
|
||||||
|
String bodys = userService.searchBaidu(file);
|
||||||
|
return R.ok(bodys);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存角色
|
* 修改保存角色
|
||||||
*/
|
*/
|
||||||
|
@ -119,6 +135,7 @@ public class SysRoleController extends BaseController
|
||||||
return toAjax(roleService.updateRole(role));
|
return toAjax(roleService.updateRole(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存数据权限
|
* 修改保存数据权限
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.four.system.domain.SysDoctor;
|
||||||
import com.four.system.domain.SysRegistrationInformation;
|
import com.four.system.domain.SysRegistrationInformation;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.poi.hpsf.Decimal;
|
import org.apache.poi.hpsf.Decimal;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户 业务层
|
* 用户 业务层
|
||||||
|
@ -246,4 +247,7 @@ public interface ISysUserService
|
||||||
SysUser infoByUserEmail(String email);
|
SysUser infoByUserEmail(String email);
|
||||||
|
|
||||||
List<SysRegistrationInformation> findRegistrationInfoUserId(Long registrationInformationId);
|
List<SysRegistrationInformation> findRegistrationInfoUserId(Long registrationInformationId);
|
||||||
|
|
||||||
|
String searchBaidu(MultipartFile file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import javax.validation.Validator;
|
||||||
|
|
||||||
import com.four.common.core.domain.R;
|
import com.four.common.core.domain.R;
|
||||||
import com.four.common.core.web.domain.AjaxResult;
|
import com.four.common.core.web.domain.AjaxResult;
|
||||||
|
import com.four.system.Test.FastUtil;
|
||||||
|
import com.four.system.controller.SampleTest;
|
||||||
import com.four.system.domain.*;
|
import com.four.system.domain.*;
|
||||||
import com.four.system.service.ISysConfigService;
|
import com.four.system.service.ISysConfigService;
|
||||||
import org.apache.poi.hpsf.Decimal;
|
import org.apache.poi.hpsf.Decimal;
|
||||||
|
@ -31,6 +33,7 @@ import com.four.system.mapper.SysUserMapper;
|
||||||
import com.four.system.mapper.SysUserPostMapper;
|
import com.four.system.mapper.SysUserPostMapper;
|
||||||
import com.four.system.mapper.SysUserRoleMapper;
|
import com.four.system.mapper.SysUserRoleMapper;
|
||||||
import com.four.system.service.ISysUserService;
|
import com.four.system.service.ISysUserService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import static com.four.common.core.utils.SpringUtils.getAopProxy;
|
import static com.four.common.core.utils.SpringUtils.getAopProxy;
|
||||||
|
|
||||||
|
@ -66,6 +69,9 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
@Autowired
|
@Autowired
|
||||||
protected Validator validator;
|
protected Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FastUtil fastUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
*
|
*
|
||||||
|
@ -206,16 +212,6 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean checkEmailUnique() {
|
|
||||||
// Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
|
||||||
// SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
|
||||||
// if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
|
||||||
// {
|
|
||||||
// return UserConstants.NOT_UNIQUE;
|
|
||||||
// }
|
|
||||||
// return UserConstants.UNIQUE;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验email是否唯一
|
* 校验email是否唯一
|
||||||
|
@ -642,5 +638,32 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return userMapper.findRegistrationInfoUserId(registrationInformationId);
|
return userMapper.findRegistrationInfoUserId(registrationInformationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人脸登录
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String searchBaidu(MultipartFile file) {
|
||||||
|
String uploadImageFile = "";
|
||||||
|
try {
|
||||||
|
uploadImageFile = fastUtil.uploadImage(file);
|
||||||
|
if(null != uploadImageFile){
|
||||||
|
String faceLanding = SampleTest.getFaceLanding("http://101.34.252.165:8888/" + uploadImageFile);
|
||||||
|
if(!faceLanding.equals("请先录制人脸")){
|
||||||
|
return faceLanding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
return "请重新识别";
|
||||||
|
}
|
||||||
|
return "请先实名认证";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人脸登陆
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue