diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java index bd0ee547..d12a0703 100644 --- a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java @@ -74,6 +74,14 @@ public class PasswordsController { return success(PasswordsConvert.INSTANCE.convert(passwords)); } + @GetMapping("/getLastPasswords") + @Operation(summary = "获得最新数据密码") + @PreAuthorize("@ss.hasPermission('setting:passwords:query')") + public CommonResult getLastPasswords() { + PasswordsDO passwords = passwordsService.getLastPasswords(); + return success(PasswordsConvert.INSTANCE.convert(passwords)); + } + @GetMapping("/jsonToXmlConverter") @Operation(summary = "json带密码转xml") @PreAuthorize("@ss.hasPermission('setting:passwords:query')") diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java index 973f3553..c85adfc5 100644 --- a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java @@ -60,6 +60,13 @@ public interface PasswordsService { */ PasswordsDO getPasswords(Long id); + /** + * 获得数据密码最新一条 + * + * @return 数据密码 + */ + PasswordsDO getLastPasswords(); + /** * 获得数据密码列表 * diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java index 83193119..31109172 100644 --- a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java @@ -159,6 +159,13 @@ public class PasswordsServiceImpl implements PasswordsService { return passwordsMapper.selectById(id); } + @Override + public PasswordsDO getLastPasswords() { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.orderByDesc("create_time").last("LIMIT 1"); + return passwordsMapper.selectOne(wrapper); + } + @Override public List getPasswordsList(Collection ids) { return passwordsMapper.selectBatchIds(ids);