From 00638d069c765edae7be8e1da3a5087ad04a3d5c Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Thu, 21 Nov 2024 14:30:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=91=98=E5=B7=A5=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shopimpl/TbPlussShopStaffServiceImpl.java | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java index 60b3cca6..89303ea2 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbPlussShopStaffServiceImpl.java @@ -104,27 +104,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { @Override @Transactional(rollbackFor = Exception.class) public TbPlussShopStaffDto create(TbPlussShopStaff resources) { - if (org.apache.commons.lang3.StringUtils.isBlank(resources.getAccount())) { - throw new BadRequestException("员工账号为空"); - } - if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) { - throw new BadRequestException("员工账号已存在"); - } - if (!PhoneUtil.validator(resources.getPhone())){ - throw new BadRequestException("手机号格式有误"); - } + checkStaffParams(resources); - if (pattern.matcher(resources.getCode()).find()) { - throw new BadRequestException("员工编号不能包含中文"); - } - - if (resources.getRoleId()==null) { - throw new BadRequestException("请选择角色"); - } - - if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) { - throw new BadRequestException("最大优惠金额过大"); - } resources.setCreatedAt(Instant.now().toEpochMilli()); //添加收银系统后台账号 @@ -172,9 +153,8 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { resources.setPassword(null); } - if (pattern.matcher(resources.getCode()).find()) { - throw new BadRequestException("员工编号不能包含中文"); - } + checkStaffParams(resources); + TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new); User sysUser = userRepository.findByUsername(resources.getShopId()+"@"+tbPlussShopStaff.getAccount()); if(!tbPlussShopStaff.getAccount().equals(resources.getAccount())){ @@ -207,6 +187,33 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService { Integer.valueOf(resources.getShopId()), resources.getId(), resources.getPermissions()); } + private void checkStaffParams(TbPlussShopStaff resources) { + if (StringUtils.isBlank(resources.getAccount())) { + throw new BadRequestException("员工账号为空"); + } + if (userRepository.findByUsername(resources.getShopId()+"@"+resources.getAccount()) != null) { + throw new BadRequestException("员工账号已存在"); + } + if (!PhoneUtil.validator(resources.getPhone())){ + throw new BadRequestException("手机号格式有误"); + } + if (tbPlussShopStaffRepository.queryByAccount(resources.getAccount(),resources.getShopId()) != null) { + throw new BadRequestException("账号已存在"); + } + + if (pattern.matcher(resources.getCode()).find()) { + throw new BadRequestException("员工编号不能包含中文"); + } + + if (resources.getRoleId()==null) { + throw new BadRequestException("请选择角色"); + } + + if (resources.getMaxDiscountAmount().compareTo(new BigDecimal(100000000L)) > 0) { + throw new BadRequestException("最大优惠金额过大"); + } + } + @Override @Transactional(rollbackFor = Exception.class) public void updateStatus(TbPlussShopStaff resources) { From 4c5c8ef02eaf9ee984a683eba73dcc49f5f8b476 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 21 Nov 2024 14:35:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=90=A5=E9=94=80=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/controller/AppCenterController.java | 8 ++++++-- .../service/impl/TbPlatformDictTypeServiceImpl.java | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java index 716887ea..8b2f4b8b 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/AppCenterController.java @@ -4,10 +4,12 @@ import cn.ysk.cashier.service.TbPlatformDictService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.apache.ibatis.annotations.Param; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @RequiredArgsConstructor @@ -19,10 +21,12 @@ public class AppCenterController { @GetMapping @ApiOperation("获取应用中心列表") - public ResponseEntity queryBotButtonConfig(){ - return new ResponseEntity<>(tbPlatformDictService.queryByType("appCenter"), HttpStatus.OK); + public ResponseEntity queryBotButtonConfig(@RequestParam(required = false, defaultValue = "appCenter") String type){ + return new ResponseEntity<>(tbPlatformDictService.queryByType(type), HttpStatus.OK); } + + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java index cb4b64be..452d993d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/TbPlatformDictTypeServiceImpl.java @@ -9,6 +9,7 @@ import cn.ysk.cashier.utils.ValidationUtil; import lombok.RequiredArgsConstructor; import cn.ysk.cashier.repository.TbPlatformDictTypeRepository; import cn.ysk.cashier.service.TbPlatformDictTypeService; +import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; @@ -31,6 +32,7 @@ public class TbPlatformDictTypeServiceImpl implements TbPlatformDictTypeService @Override public Map queryAll(TbPlatformDictTypeQueryCriteria criteria, Pageable pageable){ + pageable = PageRequest.of(0,50); Page page = tbPlatformDictTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); return PageUtil.toPage(page.map(tbPlatformDictTypeMapper::toDto)); }