更改商品bug
This commit is contained in:
@@ -44,19 +44,11 @@ public class TbProductController {
|
||||
|
||||
private final TbProductService tbProductService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbProduct:list')")
|
||||
public void exportTbProduct(HttpServletResponse response, TbProductQueryCriteria criteria) throws IOException {
|
||||
tbProductService.download(tbProductService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/product")
|
||||
@ApiOperation("查询/product")
|
||||
public ResponseEntity<Object> queryTbProduct(TbProductQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
public ResponseEntity<Object> queryTbProduct(TbProductQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbProductService.queryAll(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/{product}")
|
||||
|
||||
@@ -102,7 +102,7 @@ public class TbProductGroupController {
|
||||
*/
|
||||
@GetMapping("/addProduct")
|
||||
public ResponseEntity<Object> ProductList(TbProductQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
return new ResponseEntity<>(tbProductService.queryAll(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,20 +44,20 @@ public class TbShopInfoController {
|
||||
|
||||
private final TbShopInfoService tbShopInfoService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbShopInfo:list')")
|
||||
public void exportTbShopInfo(HttpServletResponse response, TbShopInfoQueryCriteria criteria) throws IOException {
|
||||
tbShopInfoService.download(tbShopInfoService.queryAll(criteria), response);
|
||||
}
|
||||
// @Log("导出数据")
|
||||
// @ApiOperation("导出数据")
|
||||
// @GetMapping(value = "/download")
|
||||
// @PreAuthorize("@el.check('tbShopInfo:list')")
|
||||
// public void exportTbShopInfo(HttpServletResponse response, TbShopInfoQueryCriteria criteria) throws IOException {
|
||||
// tbShopInfoService.download(tbShopInfoService.queryAll(criteria), response);
|
||||
// }
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/shop/list")
|
||||
@ApiOperation("查询/shop/list")
|
||||
@PreAuthorize("@el.check('tbShopInfo:list')")
|
||||
public ResponseEntity<Object> queryTbShopInfo(TbShopInfoQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopInfoService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
return new ResponseEntity<>(tbShopInfoService.queryAll(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/{shopId}")
|
||||
|
||||
@@ -55,7 +55,7 @@ public class TbProductGroupDto implements Serializable {
|
||||
private Integer sort;
|
||||
|
||||
/** 商品列表 */
|
||||
private List<String> productIds;
|
||||
private List<Integer> productIds;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
|
||||
@@ -121,4 +121,10 @@ public class TbProductQueryCriteria{
|
||||
|
||||
@Query
|
||||
private String typeEnum;
|
||||
|
||||
private Integer page;
|
||||
|
||||
private Integer size;
|
||||
|
||||
private String sort;
|
||||
}
|
||||
@@ -65,4 +65,10 @@ public class TbShopInfoQueryCriteria{
|
||||
/** 精确 */
|
||||
@Query
|
||||
private Integer status;
|
||||
|
||||
private Integer page;
|
||||
|
||||
private Integer size;
|
||||
|
||||
private String sort;
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import cn.ysk.cashier.base.BaseMapper;
|
||||
import cn.ysk.cashier.pojo.product.TbProductGroup;
|
||||
import cn.ysk.cashier.dto.product.TbProductGroupDto;
|
||||
|
||||
import cn.ysk.cashier.utils.ListUtil;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import org.mapstruct.Mapping;
|
||||
@@ -38,13 +39,7 @@ import java.util.stream.Collectors;
|
||||
public interface TbProductGroupMapper extends BaseMapper<TbProductGroupDto, TbProductGroup> {
|
||||
// 自定义的字符串到整数列表的转换方法
|
||||
default List<Integer> map(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 分割字符串,然后将每个数字字符串转换为Integer,收集到List中
|
||||
return Arrays.stream(value.split(","))
|
||||
.map(Integer::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
return ListUtil.stringChangeIntegerList(value);
|
||||
}
|
||||
|
||||
// 如果需要从DTO转回实体,也可能需要实现反向的映射方法
|
||||
|
||||
@@ -80,7 +80,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
|
||||
TbProductGroup tbProductGroup = tbProductGroupRepository.findById(productGroup).orElseGet(TbProductGroup::new);
|
||||
TbProductGroupDto dto = tbProductGroupMapper.toDto(tbProductGroup);
|
||||
if (!CollectionUtils.isEmpty(dto.getProductIds())){
|
||||
return tbProductRepository.findByIds(ListUtil.stringChangeIntegerList(dto.getProductIds()));
|
||||
return tbProductRepository.findByIds(dto.getProductIds());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -37,10 +37,13 @@ import cn.ysk.cashier.pojo.shop.TbShopUnit;
|
||||
import cn.ysk.cashier.repository.shop.TbShopUnitRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
@@ -68,7 +71,9 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbProductQueryCriteria criteria, Pageable pageable){
|
||||
public Map<String,Object> queryAll(TbProductQueryCriteria criteria){
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
//查询商品数据
|
||||
Page<TbProduct> page = tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
List<String> productId = new ArrayList<>();
|
||||
@@ -147,7 +152,7 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
|
||||
//单位
|
||||
CompletableFuture<TbShopUnit> tbShopUnits = CompletableFuture.supplyAsync(() ->
|
||||
tbShopUnitRepository.searchUnit(Integer.valueOf(tbProduct.getUnitId())));
|
||||
tbShopUnitRepository.searchUnit(Integer.valueOf(StringUtils.isEmpty(tbProduct.getUnitId())? null:tbProduct.getUnitId() )));
|
||||
//sku
|
||||
CompletableFuture<List<TbProductSku>> tbProductSkus = CompletableFuture.supplyAsync(() ->
|
||||
tbProductSkuRepository.searchSku(tbProduct.getId().toString()));
|
||||
@@ -163,8 +168,6 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
if (tbProduct.getUnitId() == null){
|
||||
tbProductVo.setUnitId(null);
|
||||
tbProductVo.setUnitName(null);
|
||||
}else {
|
||||
tbProductVo.setUnitName(tbShopUnits.get().getName());
|
||||
}
|
||||
//套餐
|
||||
if (tbProduct.getGroupSnap() == null){
|
||||
@@ -203,7 +206,7 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProductDto> queryAll(TbProductQueryCriteria criteria){
|
||||
public List<TbProductDto> queryAlls(TbProductQueryCriteria criteria){
|
||||
return tbProductMapper.toDto(tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@@ -225,6 +228,7 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
if (resources.getCategoryId() == null){
|
||||
throw new BadRequestException("必填内容未填写");
|
||||
}
|
||||
product.setImages(resources.getImages().toString());
|
||||
product.setCategoryId(String.valueOf(resources.getCategoryId()));
|
||||
product.setIsDel(0);
|
||||
product.setIsDelete(0);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||
public Map<String,Object> queryAll(TbShopCategoryQueryCriteria criteria, Pageable pageable){
|
||||
|
||||
// Page<TbShopCategory> page = tbShopCategoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
PageRequest.of(0, 10, Sort.by("sort"));
|
||||
PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort"));
|
||||
Page<TbShopCategory> page = tbShopCategoryRepository.findAllBy(criteria.getShopId(), pageable);
|
||||
tbShopCategoryRepository.findAllBy(criteria.getShopId(),pageable);
|
||||
|
||||
@@ -112,14 +112,16 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
|
||||
TbShopCategoryDto dto = tbShopCategoryMapper.toDto(tbShopCategoryRepository.save(resources));
|
||||
|
||||
if (resources.getName() != null){
|
||||
throw new BadRequestException("分类名称重复");
|
||||
}
|
||||
if (resources.getPid() == null || "".equals(resources.getPid())){
|
||||
resources.setTree(resources.getId());
|
||||
}else {
|
||||
resources.setTree(Integer.valueOf(resources.getPid().trim()));
|
||||
}
|
||||
|
||||
ValidationUtil.isNull( dto.getId(),"TbShopCategory","id",resources.getId());
|
||||
ValidationUtil.isNull(dto.getId(),"TbShopCategory","id",resources.getId());
|
||||
tbShopCategoryRepository.save(resources);
|
||||
return tbShopCategoryRepository.save(resources);
|
||||
}
|
||||
@@ -132,9 +134,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||
throw new BadRequestException("必要参数为空");
|
||||
}
|
||||
TbShopCategory byName = tbShopCategoryRepository.findByName(resources.getName(), resources.getShopId());
|
||||
if (byName != null){
|
||||
throw new BadRequestException("分类名称重复");
|
||||
}
|
||||
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
ValidationUtil.isNull( tbShopCategory.getId(),"TbShopCategory","id",resources.getId());
|
||||
tbShopCategory.copy(resources);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.pojo.product.TbShopCategory;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||
import cn.ysk.cashier.pojo.shop.TbPlussShopStaff;
|
||||
import cn.ysk.cashier.repository.shop.TbMerchantAccountRepository;
|
||||
@@ -36,6 +37,8 @@ import cn.ysk.cashier.dto.shop.TbShopInfoDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopInfoQueryCriteria;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopInfoMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -73,11 +76,10 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
private final TbPlussShopStaffRepository shopStaffRepository;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria, Pageable pageable){
|
||||
// if (!"admin".equals(criteria.getAccount())){
|
||||
// throw new BadRequestException("登录账号有误");
|
||||
// }
|
||||
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
public Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria){
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageables = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
Page<TbShopInfo> page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageables);
|
||||
List<TbShopInfo> content = page.getContent();
|
||||
for (TbShopInfo data: content){
|
||||
if (data.getProfiles() == null){
|
||||
@@ -87,10 +89,10 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
return PageUtil.toPage(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria){
|
||||
return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
// @Override
|
||||
// public List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria){
|
||||
// return tbShopInfoMapper.toDto(tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -178,6 +180,7 @@ public class TbShopInfoServiceImpl implements TbShopInfoService {
|
||||
tbPlussShopStaff.setStatus(1);
|
||||
tbPlussShopStaff.setCreatedAt(Instant.now().toEpochMilli());
|
||||
tbPlussShopStaff.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
tbPlussShopStaff.setCode(save.getPhone());
|
||||
shopStaffRepository.save(tbPlussShopStaff);
|
||||
|
||||
if (resources.getRegisterCode() != null){
|
||||
|
||||
@@ -106,6 +106,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
resources.setQrcode("");
|
||||
resources.setStatus("closed");
|
||||
return tbShopTableRepository.save(resources);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,17 +36,16 @@ public interface TbProductService {
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbProductQueryCriteria criteria, Pageable pageable);
|
||||
Map<String,Object> queryAll(TbProductQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbProductDto>
|
||||
*/
|
||||
List<TbProductDto> queryAll(TbProductQueryCriteria criteria);
|
||||
List<TbProductDto> queryAlls(TbProductQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
|
||||
@@ -35,17 +35,16 @@ public interface TbShopInfoService {
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria, Pageable pageable);
|
||||
Map<String,Object> queryAll(TbShopInfoQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopInfoDto>
|
||||
*/
|
||||
List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria);
|
||||
// List<TbShopInfoDto> queryAll(TbShopInfoQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TbProductVo {
|
||||
private String shareImg;
|
||||
|
||||
|
||||
private String images;
|
||||
private List<String> images;
|
||||
|
||||
|
||||
private String video;
|
||||
|
||||
@@ -5,7 +5,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: @env@
|
||||
active: dev
|
||||
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
|
||||
Reference in New Issue
Block a user