分组增加可售时段
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.ysk.cashier.service.impl.productimpl;
|
||||
|
||||
import cn.ysk.cashier.dto.product.TbProductSortCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.repository.product.TbProductRepository;
|
||||
import cn.ysk.cashier.pojo.product.TbProductGroup;
|
||||
@@ -14,6 +15,7 @@ import cn.ysk.cashier.config.security.service.dto.OnlineUserDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cn.ysk.cashier.service.product.TbProductGroupService;
|
||||
import cn.ysk.cashier.mapper.product.TbProductGroupMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -86,6 +88,10 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbProductGroupDto create(TbProductGroup resources) {
|
||||
if (resources.getUseTime() == 1) {
|
||||
if (StringUtils.isBlank(resources.getSaleStartTime()) || StringUtils.isBlank(resources.getSaleEndTime()))
|
||||
throw new BadRequestException("可售时间不可为空");
|
||||
}
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
TbProductGroup save = tbProductGroupRepository.save(resources);
|
||||
@@ -96,6 +102,10 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbProductGroup resources) {
|
||||
if (resources.getUseTime() == 1) {
|
||||
if (StringUtils.isBlank(resources.getSaleStartTime()) || StringUtils.isBlank(resources.getSaleEndTime()))
|
||||
throw new BadRequestException("可售时间不可为空");
|
||||
}
|
||||
TbProductGroup tbProductGroup = tbProductGroupRepository.findById(resources.getId()).orElseGet(TbProductGroup::new);
|
||||
// TbProductGroup byName = tbProductGroupRepository.findByName(resources.getName(), resources.getShopId());
|
||||
// if (byName != null){
|
||||
@@ -187,7 +197,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateProductIds(AddProduct addProduct, String userName) {
|
||||
OnlineUserDto onlineUser = onlineUserService.getOne(addProduct.getKey());
|
||||
// OnlineUserDto onlineUser = onlineUserService.getOne(addProduct.getKey());
|
||||
|
||||
if (addProduct.getIds().size()<1){
|
||||
return new ResponseEntity<>("错误", HttpStatus.NOT_ACCEPTABLE);
|
||||
|
||||
Reference in New Issue
Block a user