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)); } 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) {