From 38a660add651fa6a1ac2b99ad9d1577bdcfbef06 Mon Sep 17 00:00:00 2001 From: zuihou <244387066@qq.com> Date: Tue, 4 Jul 2023 21:52:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B2=97=E4=BD=8D=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E6=A0=A1=E9=AA=8C=E5=94=AF=E4=B8=80=E6=80=A7=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=8F=AA=E5=88=A4=E6=96=AD=E5=90=8C=E4=B8=80=E7=BA=A7?= =?UTF-8?q?=E5=88=AB=E4=B8=8B=E7=9A=84=E5=B2=97=E4=BD=8D=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E9=87=8D=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lamp/authority/service/core/StationService.java | 7 ++++--- .../authority/service/core/impl/StationServiceImpl.java | 8 ++++---- .../lamp/authority/controller/core/StationController.java | 8 +++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/StationService.java b/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/StationService.java index 3fed012e4..d90893fd5 100644 --- a/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/StationService.java +++ b/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/StationService.java @@ -29,12 +29,13 @@ public interface StationService extends SuperCacheService, LoadService /** * 检测名称是否存在 * - * @param id id - * @param name name + * @param id id + * @param orgId 机构ID + * @param name 岗位名称 * @return boolean * @author zuihou * @date 2021/5/23 9:37 下午 * @create [2021/5/23 9:37 下午 ] [tangyh] [初始创建] */ - boolean check(Long id, String name); + boolean check(Long id, Long orgId, String name); } diff --git a/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/impl/StationServiceImpl.java b/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/impl/StationServiceImpl.java index b447a9ac8..617a5cfcf 100644 --- a/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/impl/StationServiceImpl.java +++ b/lamp-authority/lamp-authority-biz/src/main/java/top/tangyh/lamp/authority/service/core/impl/StationServiceImpl.java @@ -51,23 +51,23 @@ protected CacheKeyBuilder cacheKeyBuilder() { } @Override - public boolean check(Long id, String name) { + public boolean check(Long id, Long orgId, String name) { LbqWrapper wrap = Wraps.lbQ() - .eq(Station::getName, name).ne(Station::getId, id); + .eq(Station::getName, name).eq(Station::getOrgId, orgId).ne(Station::getId, id); return count(wrap) > 0; } @Override @Transactional(rollbackFor = Exception.class) public boolean save(Station model) { - ArgumentAssert.isFalse(check(null, model.getName()), StrUtil.format("岗位[{}]已经存在", model.getName())); + ArgumentAssert.isFalse(check(null, model.getOrgId(), model.getName()), StrUtil.format("岗位[{}]已经存在", model.getName())); return super.save(model); } @Override @Transactional(rollbackFor = Exception.class) public boolean updateById(Station model) { - ArgumentAssert.isFalse(check(model.getId(), model.getName()), StrUtil.format("岗位[{}]已经存在", model.getName())); + ArgumentAssert.isFalse(check(model.getId(), model.getOrgId(), model.getName()), StrUtil.format("岗位[{}]已经存在", model.getName())); return super.updateById(model); } diff --git a/lamp-authority/lamp-authority-controller/src/main/java/top/tangyh/lamp/authority/controller/core/StationController.java b/lamp-authority/lamp-authority-controller/src/main/java/top/tangyh/lamp/authority/controller/core/StationController.java index a4ef04a32..6a31fc446 100644 --- a/lamp-authority/lamp-authority-controller/src/main/java/top/tangyh/lamp/authority/controller/core/StationController.java +++ b/lamp-authority/lamp-authority-controller/src/main/java/top/tangyh/lamp/authority/controller/core/StationController.java @@ -51,20 +51,22 @@ @RequiredArgsConstructor public class StationController extends SuperCacheController { private final UserHelperService userHelperService; + @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "ID", dataType = DATA_TYPE_LONG, paramType = PARAM_TYPE_QUERY), + @ApiImplicitParam(name = "orgId", value = "orgId", dataType = DATA_TYPE_LONG, paramType = PARAM_TYPE_QUERY), @ApiImplicitParam(name = "name", value = "名称", dataType = DATA_TYPE_STRING, paramType = PARAM_TYPE_QUERY), }) @ApiOperation(value = "检测名称是否可用", notes = "检测名称是否可用") @GetMapping("/check") - public R check(@RequestParam(required = false) Long id, @RequestParam String name) { - return success(baseService.check(id, name)); + public R check(@RequestParam(required = false) Long id, @RequestParam Long orgId, @RequestParam String name) { + return success(baseService.check(id, orgId, name)); } @Override public R handlerSave(StationSaveDTO model) { SysUser sysUser = userHelperService.getUserByIdCache(ContextUtil.getUserId()); - if (sysUser!= null) { + if (sysUser != null) { model.setCreatedOrgId(sysUser.getOrgId()); } return super.handlerSave(model);