Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松 2024-11-21 14:37:35 +08:00
commit 30aac37ef2
3 changed files with 38 additions and 25 deletions

View File

@ -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<Object> queryBotButtonConfig(){
return new ResponseEntity<>(tbPlatformDictService.queryByType("appCenter"), HttpStatus.OK);
public ResponseEntity<Object> queryBotButtonConfig(@RequestParam(required = false, defaultValue = "appCenter") String type){
return new ResponseEntity<>(tbPlatformDictService.queryByType(type), HttpStatus.OK);
}
}

View File

@ -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<String,Object> queryAll(TbPlatformDictTypeQueryCriteria criteria, Pageable pageable){
pageable = PageRequest.of(0,50);
Page<TbPlatformDictType> page = tbPlatformDictTypeRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbPlatformDictTypeMapper::toDto));
}

View File

@ -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) {