diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java index f5ab968d..fc8f93f5 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/config/security/rest/AuthorizationController.java @@ -99,6 +99,7 @@ public class AuthorizationController { throw new BadRequestException("验证码错误"); } String loginpre=""; + String shopId=""; // 判断是否是员工登录 if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) { if (StrUtil.isBlank(authUser.getMerchantName())) { @@ -109,7 +110,8 @@ public class AuthorizationController { if (merchant == null) { throw new BadRequestException("商户不存在"); } - loginpre=merchant.getShopId() + "@"; + loginpre = merchant.getShopId() + "@"; + shopId = merchant.getShopId(); } //生成token @@ -123,7 +125,12 @@ public class AuthorizationController { // SecurityContextHolder.getContext().setAuthentication(authentication); final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal(); // TbShopInfo byAccount = tbShopInfoRepository.findByAccount(jwtUserDto.getUsername()); - TbPlussShopStaff tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername()); + TbPlussShopStaff tbPlussShopStaff; + if (authUser.getLoginType() != null && "staff".equals(authUser.getLoginType())) { + tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername(),shopId); + } else { + tbPlussShopStaff = staffRepository.queryByAccount(authUser.getUsername()); + } if (tbPlussShopStaff != null && tbPlussShopStaff.getType().equals("staff")) { Integer isManage = tbPlussShopStaff.getIsManage(); if (isManage != null && isManage != 1) { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java index bebca5c4..8326bb57 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/StockController.java @@ -114,7 +114,7 @@ public class StockController { } - @Log("商品库存:上下架商品") + @Log("商品库存 上下架商品") @PutMapping("/grounding") @ApiOperation("上下架商品") public ResponseEntity grounding( @@ -141,7 +141,7 @@ public class StockController { return new ResponseEntity<>(HttpStatus.OK); } - @Log("商品库存:修改商品状态") + @Log("商品库存 修改商品状态") @PutMapping("productStatus") public ResponseEntity updateProductStatus(@RequestBody StockUpdateValueVO updateValueVO) { stockService.updateProductStatus(updateValueVO); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java index b7d4a6a5..f8429d07 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/repository/shop/TbPlussShopStaffRepository.java @@ -45,6 +45,9 @@ public interface TbPlussShopStaffRepository extends JpaRepository, JpaSpecificat * @return / */ Role findByName(String name); + Role findByNameAndShopId(String name,Integer shopId); /** * 删除多个角色 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/system/service/impl/RoleServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/system/service/impl/RoleServiceImpl.java index 650ddd28..1413ceea 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/system/service/impl/RoleServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/system/service/impl/RoleServiceImpl.java @@ -91,8 +91,8 @@ public class RoleServiceImpl implements RoleService { @Override @Transactional(rollbackFor = Exception.class) public void create(Role resources) { - if (roleRepository.findByName(resources.getName()) != null) { - throw new EntityExistException(Role.class, "username", resources.getName()); + if (roleRepository.findByNameAndShopId(resources.getName(),resources.getShopId()) != null) { + throw new BadRequestException("角色已存在"); } roleRepository.save(resources); } @@ -101,13 +101,12 @@ public class RoleServiceImpl implements RoleService { @Transactional(rollbackFor = Exception.class) public void update(Role resources) { Role role = roleRepository.findById(resources.getId()).orElseGet(Role::new); - ValidationUtil.isNull(role.getId(), "Role", "id", resources.getId()); - - Role role1 = roleRepository.findByName(resources.getName()); - - if (role1 != null && !role1.getId().equals(role.getId())) { - throw new EntityExistException(Role.class, "username", resources.getName()); + if (!resources.getName().equals(role.getName())) { + if (roleRepository.findByNameAndShopId(resources.getName(),resources.getShopId()) != null) { + throw new BadRequestException("修改失败,角色名称不可重复"); + } } + ValidationUtil.isNull(role.getId(), "Role", "id", resources.getId()); role.setName(resources.getName()); role.setDescription(resources.getDescription()); role.setDataScope(resources.getDataScope());