New file |
| | |
| | | { |
| | | "headers": { |
| | | "access-control-allow-origin": "*", |
| | | "date": "Tue, 21 Jan 2025 07:22:51 GMT", |
| | | "keep-alive": "timeout=25", |
| | | "transfer-encoding": "chunked", |
| | | "vary": "Accept-Encoding", |
| | | "x-acs-request-id": "4545720F-58C2-579E-A1CE-08FDDFDF3296", |
| | | "connection": "keep-alive", |
| | | "content-type": "application/json;charset=utf-8", |
| | | "access-control-expose-headers": "*", |
| | | "x-acs-trace-id": "2a95d25064c13621b98f3883185aadc1" |
| | | }, |
| | | "body": { |
| | | "RequestId": "4545720F-58C2-579E-A1CE-08FDDFDF3296", |
| | | "Data": { |
| | | "SubImages": [ |
| | | { |
| | | "FigureInfo": { |
| | | "face": { |
| | | "FigureCount": 1, |
| | | "FigureDetails": [ |
| | | { |
| | | "FigurePoints": [ |
| | | { |
| | | "X": 672, |
| | | "Y": 289 |
| | | }, |
| | | { |
| | | "X": 949, |
| | | "Y": 288 |
| | | }, |
| | | { |
| | | "X": 950, |
| | | "Y": 624 |
| | | }, |
| | | { |
| | | "X": 672, |
| | | "Y": 624 |
| | | } |
| | | ], |
| | | "FigureAngle": 0 |
| | | } |
| | | ] |
| | | } |
| | | }, |
| | | "SubImageId": 0, |
| | | "KvInfo": { |
| | | "KvCount": 6, |
| | | "Data": { |
| | | "address": "黑龙江省宁安市渤海镇玄武大街35号", |
| | | "ethnicity": "汉", |
| | | "sex": "女", |
| | | "name": "陆佳欣", |
| | | "idNumber": "231084200002060822", |
| | | "birthDate": "2000年2月6日" |
| | | }, |
| | | "KvDetails": { |
| | | "address": { |
| | | "KeyName": "address", |
| | | "ValueAngle": 1, |
| | | "Value": "黑龙江省宁安市渤海镇玄武大街35号", |
| | | "KeyConfidence": 100, |
| | | "ValueConfidence": 100 |
| | | }, |
| | | "ethnicity": { |
| | | "KeyName": "ethnicity", |
| | | "ValueAngle": 0, |
| | | "Value": "汉", |
| | | "KeyConfidence": 100, |
| | | "ValueConfidence": 100 |
| | | }, |
| | | "sex": { |
| | | "KeyName": "sex", |
| | | "ValueAngle": 0, |
| | | "Value": "女", |
| | | "KeyConfidence": 100, |
| | | "ValueConfidence": 100 |
| | | }, |
| | | "name": { |
| | | "KeyName": "name", |
| | | "ValueAngle": 0, |
| | | "Value": "陆佳欣", |
| | | "KeyConfidence": 100, |
| | | "ValueConfidence": 100 |
| | | }, |
| | | "idNumber": { |
| | | "KeyName": "idNumber", |
| | | "ValueAngle": 1, |
| | | "Value": "231084200002060822", |
| | | "KeyConfidence": 100, |
| | | "ValueConfidence": 100 |
| | | }, |
| | | "birthDate": { |
| | | "KeyName": "birthDate", |
| | | "ValueAngle": 0, |
| | | "Value": "2000年2月6日", |
| | | "KeyConfidence": 100, |
| | | "ValueConfidence": 100 |
| | | } |
| | | } |
| | | }, |
| | | "QualityInfo": { |
| | | "IsCopy": false |
| | | }, |
| | | "Type": "身份证正面", |
| | | "Angle": 0 |
| | | } |
| | | ], |
| | | "Height": 852, |
| | | "SubImageCount": 1, |
| | | "Width": 1136 |
| | | } |
| | | }, |
| | | "statusCode": 200 |
| | | } |
New file |
| | |
| | | package com.ruoyi.company.api.model; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @Schema(name = "修改手机号参数") |
| | | public class UpdatePhone { |
| | | |
| | | @Schema(description = "旧手机号", example = "13800138000") |
| | | private String oldPhone; |
| | | |
| | | @Schema(description = "新手机号", example = "13800138000") |
| | | private String newPhone; |
| | | |
| | | @Schema(description = "验证码", example = "123456") |
| | | private String code; |
| | | |
| | | @Schema(description = "登录密码", example = "123456") |
| | | private String password; |
| | | } |
| | |
| | | <groupId>org.projectlombok</groupId> |
| | | <artifactId>lombok</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>ocr_api20210707</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>darabonba-stream</artifactId> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | </project> |
New file |
| | |
| | | package com.ruoyi.common.core.utils; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | |
| | | public class UrlDownloader { |
| | | |
| | | /** |
| | | * 将指定的URL内容下载为输入流 |
| | | * |
| | | * @param urlString 要下载的URL |
| | | * @return 包含URL内容的输入流 |
| | | * @throws IOException 如果发生I/O错误 |
| | | */ |
| | | public static InputStream downloadAsStream(String urlString) throws IOException { |
| | | URL url = new URL(urlString); |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setRequestMethod("GET"); |
| | | connection.connect(); |
| | | |
| | | // 检查HTTP响应码 |
| | | int responseCode = connection.getResponseCode(); |
| | | if (responseCode != HttpURLConnection.HTTP_OK) { |
| | | throw new IOException("HTTP response code: " + responseCode); |
| | | } |
| | | |
| | | return connection.getInputStream(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String urlString = "https://example.com/file.txt"; // 替换为你要下载的URL |
| | | |
| | | try (InputStream inputStream = downloadAsStream(urlString)) { |
| | | // 这里你可以处理输入流,例如将其写入文件或进行其他操作 |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |
| | | // 处理读取的数据,例如写入文件或打印到控制台 |
| | | System.out.write(buffer, 0, bytesRead); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.common.core.utils.orc; |
| | | |
| | | import com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest; |
| | | import com.aliyun.ocr_api20210707.models.RecognizeAllTextResponse; |
| | | import com.aliyun.tea.TeaException; |
| | | import com.aliyun.tea.TeaModel; |
| | | import com.aliyun.teautil.models.RuntimeOptions; |
| | | import com.ruoyi.common.core.utils.UrlDownloader; |
| | | |
| | | import java.io.InputStream; |
| | | |
| | | public class OcrUtils { |
| | | |
| | | /** |
| | | * <b>description</b> : |
| | | * <p>使用AK&SK初始化账号Client</p> |
| | | * |
| | | * @return Client |
| | | * @throws Exception |
| | | */ |
| | | public static com.aliyun.ocr_api20210707.Client createClient() throws Exception { |
| | | // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。 |
| | | // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。 |
| | | com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() |
| | | // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。 |
| | | .setAccessKeyId("LTAI5tFSeci96NRF6p6UN69G") |
| | | // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 |
| | | .setAccessKeySecret("25t5zmWkueoQd81Zka70uPKRPgaMiV"); |
| | | // Endpoint 请参考 https://api.aliyun.com/product/ocr-api |
| | | config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com"; |
| | | return new com.aliyun.ocr_api20210707.Client(config); |
| | | } |
| | | |
| | | /** |
| | | * 证件识别 |
| | | */ |
| | | public static String idCard(InputStream bodyStream) throws Exception { |
| | | com.aliyun.ocr_api20210707.Client client = createClient(); |
| | | // 需要安装额外的依赖库,直接点击下载完整工程即可看到所有依赖。 |
| | | RecognizeAllTextRequest recognizeAllTextRequest = new RecognizeAllTextRequest() |
| | | .setBody(bodyStream) |
| | | .setType("IdCard") |
| | | .setOutputFigure(true); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | RecognizeAllTextResponse recognizeAllTextResponse = client.recognizeAllTextWithOptions(recognizeAllTextRequest, runtime); |
| | | System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(recognizeAllTextResponse))); |
| | | } catch (TeaException error) { |
| | | // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 |
| | | // 错误 message |
| | | System.out.println(error.getMessage()); |
| | | // 诊断地址 |
| | | System.out.println(error.getData().get("Recommend")); |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 |
| | | // 错误 message |
| | | System.out.println(error.getMessage()); |
| | | // 诊断地址 |
| | | System.out.println(error.getData().get("Recommend")); |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | try { |
| | | InputStream inputStream = UrlDownloader.downloadAsStream("https://ai.bdstatic.com/file/3C8C5B451BB4445697730217EC8648E3"); |
| | | idCard(inputStream); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>ocr_api20210707</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>darabonba-stream</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>cn.idev.excel</groupId> |
| | | <artifactId>fastexcel</artifactId> |
| | | </dependency> |
| | |
| | | @Operation(summary = "修改企业信息", tags = {"企业端"}) |
| | | @PutMapping("/updateCompany") |
| | | public R<Void> updateCompany(Company company){ |
| | | Long userId = SecurityUtils.getAppLoginUser().getUserId(); |
| | | Company companyDb = companyService.getOne(new LambdaQueryWrapper<Company>() |
| | | .eq(Company::getUserId, userId)); |
| | | company.setId(companyDb.getId()); |
| | | companyService.updateById(company); |
| | | return R.ok(); |
| | | } |
| | |
| | | package com.ruoyi.company.controller.front; |
| | | |
| | | import com.aliyun.ocr_api20210707.models.RecognizeAllTextResponse; |
| | | import com.aliyun.tea.*; |
| | | |
| | | public class Sample { |
| | | |
| | | /** |
| | | * <b>description</b> : |
| | | * <p>使用AK&SK初始化账号Client</p> |
| | | * @return Client |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | public static com.aliyun.ocr_api20210707.Client createClient() throws Exception { |
| | | // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。 |
| | | // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。 |
| | | com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config() |
| | | // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。 |
| | | .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")) |
| | | // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 |
| | | .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET")); |
| | | // Endpoint 请参考 https://api.aliyun.com/product/ocr-api |
| | | config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com"; |
| | | return new com.aliyun.ocr_api20210707.Client(config); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args_) throws Exception { |
| | | java.util.List<String> args = java.util.Arrays.asList(args_); |
| | | com.aliyun.ocr_api20210707.Client client = Sample.createClient(); |
| | | // 需要安装额外的依赖库,直接点击下载完整工程即可看到所有依赖。 |
| | | java.io.InputStream bodyStream = com.aliyun.darabonba.stream.Client.readFromFilePath("<your-file-path>"); |
| | | com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest recognizeAllTextRequest = new com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest() |
| | | .setBody(bodyStream) |
| | | .setType("IdCard") |
| | | .setOutputFigure(true); |
| | | com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | client.recognizeAllTextWithOptions(recognizeAllTextRequest, runtime); |
| | | } catch (TeaException error) { |
| | | // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 |
| | | // 错误 message |
| | | System.out.println(error.getMessage()); |
| | | // 诊断地址 |
| | | System.out.println(error.getData().get("Recommend")); |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 |
| | | // 错误 message |
| | | System.out.println(error.getMessage()); |
| | | // 诊断地址 |
| | | System.out.println(error.getData().get("Recommend")); |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.company.controller.front; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.CaptchaException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.annotation.InnerAuth; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.company.api.domain.User; |
| | | import com.ruoyi.company.api.domain.dto.MgtCompanyDTO; |
| | | import com.ruoyi.company.api.model.RegisterUser; |
| | | import com.ruoyi.company.api.model.UpdatePassword; |
| | | import com.ruoyi.company.api.model.UpdatePhone; |
| | | import com.ruoyi.company.api.model.UserDetail; |
| | | import com.ruoyi.company.service.CompanyService; |
| | | import com.ruoyi.company.service.UserService; |
| | |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.experimental.StandardException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | public class UserController { |
| | | private final UserService userService; |
| | | private final CompanyService companyService; |
| | | private final RedisService redisService; |
| | | |
| | | |
| | | @PostMapping("/register") |
| | | public R register(@RequestBody MgtCompanyDTO mgtCompanyDTO) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改手机号 |
| | | */ |
| | | @PutMapping("/updatePhone") |
| | | @Operation(summary = "修改手机号",tags = {"企业端"}) |
| | | public R<Void> updatePhone(@RequestBody UpdatePhone updatePhone) { |
| | | AppUser appLoginUser = SecurityUtils.getAppLoginUser(); |
| | | User user = userService.getById(appLoginUser.getUserId()); |
| | | if (!user.getPhone().equals(updatePhone.getOldPhone())) { |
| | | return R.fail("旧手机号错误"); |
| | | } |
| | | String verifyKey = CacheConstants.PHONE_CODE_KEY + StringUtils.nvl(user.getPhone(), ""); |
| | | String captcha = redisService.getCacheObject(verifyKey); |
| | | if (captcha == null) { |
| | | throw new CaptchaException("验证码已失效"); |
| | | } |
| | | redisService.deleteObject(verifyKey); |
| | | if (!updatePhone.getCode().equalsIgnoreCase(captcha)) { |
| | | throw new CaptchaException("验证码错误"); |
| | | } |
| | | |
| | | String password = SecurityUtils.encryptPassword(updatePhone.getPassword()); |
| | | if (!user.getPassword().equals(password)) { |
| | | return R.fail("密码错误"); |
| | | } |
| | | user.setPhone(updatePhone.getNewPhone()); |
| | | userService.updateById(user); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 修改密码 |
| | | */ |
| | | @PutMapping("/updatePassword") |
| | |
| | | } |
| | | //用户信息 |
| | | User userUpd = BeanUtils.copyBean(dto, User.class); |
| | | userUpd.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); |
| | | if (StringUtils.isNotBlank(dto.getPassword())){ |
| | | userUpd.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); |
| | | } |
| | | userUpd.setUserId(user.getUserId()); |
| | | userUpd.setUpdateBy(SecurityUtils.getUserId()); |
| | | userService.updateById(userUpd); |