From 5572e46e5bd1acd8ddd819f4105d6feb30eb2552 Mon Sep 17 00:00:00 2001 From: luodangjia <luodangjia> Date: 星期二, 21 一月 2025 15:04:33 +0800 Subject: [PATCH] 1 --- ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/Sample.java | 57 +++++++++++++++++++ ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/UserController.java | 34 +++++++++++ ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/domain/dto/MgtCompanyDTO.java | 1 ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java | 5 + ruoyi-modules/ruoyi-company/pom.xml | 5 + ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/CompanyController.java | 11 +++ ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/model/UpdatePassword.java | 10 +++ pom.xml | 6 ++ 8 files changed, 127 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a3e5dbe..ce987f1 100644 --- a/pom.xml +++ b/pom.xml @@ -318,6 +318,12 @@ <artifactId>ocr_api20210707</artifactId> <version>3.1.2</version> </dependency> + + <dependency> + <groupId>com.aliyun</groupId> + <artifactId>darabonba-stream</artifactId> + <version>0.0.1</version> + </dependency> <!--aliyun-oss--> <dependency> <groupId>com.aliyun.oss</groupId> diff --git a/ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/domain/dto/MgtCompanyDTO.java b/ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/domain/dto/MgtCompanyDTO.java index 9bc681e..3ce7881 100644 --- a/ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/domain/dto/MgtCompanyDTO.java +++ b/ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/domain/dto/MgtCompanyDTO.java @@ -108,7 +108,6 @@ private String phone; @Schema(description = "登录密码") - @NotBlank(message = "登录密码不能为空") private String password; } diff --git a/ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/model/UpdatePassword.java b/ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/model/UpdatePassword.java new file mode 100644 index 0000000..d43bd6b --- /dev/null +++ b/ruoyi-api/ruoyi-api-company/src/main/java/com/ruoyi/company/api/model/UpdatePassword.java @@ -0,0 +1,10 @@ +package com.ruoyi.company.api.model; + +import lombok.Data; + +@Data +public class UpdatePassword { + private String oldPassword; + private String newPassword; + private String confirmPassword; +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java index ceba746..c68955d 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java @@ -47,6 +47,11 @@ public R<SysUser> getUserById(Long userId, String source) { return R.fail("获取用户信息失败:" + throwable.getMessage()); } + + @Override + public R<?> updateUser(SysUser sysUser, String source) { + return R.fail("更新用户信息"); + } }; } } diff --git a/ruoyi-modules/ruoyi-company/pom.xml b/ruoyi-modules/ruoyi-company/pom.xml index d72cc3b..faef65c 100644 --- a/ruoyi-modules/ruoyi-company/pom.xml +++ b/ruoyi-modules/ruoyi-company/pom.xml @@ -93,7 +93,10 @@ <artifactId>ocr_api20210707</artifactId> </dependency> - + <dependency> + <groupId>com.aliyun</groupId> + <artifactId>darabonba-stream</artifactId> + </dependency> <dependency> <groupId>cn.idev.excel</groupId> diff --git a/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/CompanyController.java b/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/CompanyController.java index e6201f4..117074d 100644 --- a/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/CompanyController.java +++ b/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/CompanyController.java @@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -40,4 +41,14 @@ .eq(Company::getUserId, userId)); return R.ok(company); } + + /** + * 修改企业信息 + */ + @Operation(summary = "修改企业信息", tags = {"企业端"}) + @PutMapping("/updateCompany") + public R<Void> updateCompany(Company company){ + companyService.updateById(company); + return R.ok(); + } } diff --git a/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/Sample.java b/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/Sample.java new file mode 100644 index 0000000..fe44574 --- /dev/null +++ b/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/Sample.java @@ -0,0 +1,57 @@ +package com.ruoyi.company.controller.front; + +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); + } + } +} \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/UserController.java b/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/UserController.java index 0160c77..09c83e0 100644 --- a/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/UserController.java +++ b/ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/UserController.java @@ -8,6 +8,7 @@ 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.UserDetail; import com.ruoyi.company.service.CompanyService; import com.ruoyi.company.service.UserService; @@ -58,9 +59,42 @@ } @PutMapping("/updateUser") + @InnerAuth public R<Void> updateUser(@RequestBody User user){ user.setUpdateTime(LocalDateTime.now()); userService.updateById(user); return R.ok(); } + + /** + * 编辑联系人信息 + */ + @PutMapping("/updateUserDetail") + @Operation(summary = "编辑联系人信息",tags = {"企业端"}) + public R<Void> updateUserDetail(@RequestBody UserDetail userDetail) { + User user = userService.getById(userDetail.getUserId()); + BeanUtils.copyProperties(userDetail, user); + userService.updateById(user); + return R.ok(); + } + + /** + * 修改密码 + */ + @PutMapping("/updatePassword") + @Operation(summary = "修改密码",tags = {"企业端"}) + public R<Void> updatePassword(@RequestBody UpdatePassword updatePassword) { + AppUser appLoginUser = SecurityUtils.getAppLoginUser(); + User user = userService.getById(appLoginUser.getUserId()); + String oldPassword = SecurityUtils.encryptPassword(updatePassword.getOldPassword()); + if (!user.getPassword().equals(oldPassword)) { + return R.fail("旧密码错误"); + } + if (!updatePassword.getNewPassword().equals(updatePassword.getConfirmPassword())){ + return R.fail("两次密码不一致"); + } + user.setPassword(SecurityUtils.encryptPassword(updatePassword.getNewPassword())); + userService.updateById(user); + return R.ok(); + } } -- Gitblit v1.7.1