字典接口,供应商相关,商品库存列表更改
This commit is contained in:
@@ -294,6 +294,18 @@ public class TbProduct implements Serializable {
|
||||
@Column(name = "`tax_config_id`")
|
||||
@ApiModelProperty(value = "税率")
|
||||
private String taxConfigId;
|
||||
|
||||
@Column(name = "spec_info")
|
||||
@ApiModelProperty(value = "specInfo")
|
||||
private String specInfo;
|
||||
|
||||
@Column(name = "select_spec")
|
||||
@ApiModelProperty(value = "selectSpec")
|
||||
private String selectSpec;
|
||||
|
||||
@Column(name = "spec_table_headers")
|
||||
@ApiModelProperty(value = "specTableHeaders")
|
||||
private String specTableHeaders;
|
||||
public void copy(TbProduct source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.zhengjie.modules.productInfo.product.domain;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import lombok.Data;
|
||||
import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku;
|
||||
|
||||
@@ -37,13 +38,13 @@ public class TbProductVo {
|
||||
private BigDecimal lowPrice;
|
||||
|
||||
|
||||
private String unitId;
|
||||
private Integer unitId;
|
||||
|
||||
|
||||
private String coverImg;
|
||||
|
||||
|
||||
private String categoryId;
|
||||
private Integer categoryId;
|
||||
|
||||
|
||||
private Integer specId;
|
||||
@@ -174,7 +175,7 @@ public class TbProductVo {
|
||||
private Integer isCombo;
|
||||
|
||||
|
||||
private String groupSnap;
|
||||
private JSONArray groupSnap;
|
||||
|
||||
|
||||
private Integer isShowCash;
|
||||
@@ -196,17 +197,17 @@ public class TbProductVo {
|
||||
|
||||
private Integer enableLabel;
|
||||
|
||||
|
||||
|
||||
private String taxConfigId;
|
||||
|
||||
|
||||
|
||||
private String unitName;
|
||||
|
||||
private List<TbProductSku> skuList;
|
||||
|
||||
private HashMap<String,String> specsInfo;
|
||||
|
||||
private String specInfo;
|
||||
|
||||
private String selectSpec;
|
||||
|
||||
private String specTableHeaders;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package me.zhengjie.modules.productInfo.product.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProduct;
|
||||
import me.zhengjie.modules.productInfo.product.domain.TbProductVo;
|
||||
@@ -153,6 +154,20 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
Threads.call(tbShopUnits,tbProductSkus,tbProductSpec);
|
||||
//组装
|
||||
TbProductVo tbProductVo = new TbProductVo();
|
||||
tbProductVo.setCategoryId(Integer.valueOf(tbProduct.getCategoryId()));
|
||||
//单位
|
||||
if (tbProduct.getUnitId() == null){
|
||||
tbProductVo.setUnitId(null);
|
||||
tbProductVo.setUnitName(null);
|
||||
}else {
|
||||
tbProductVo.setUnitName(tbShopUnits.get().getName());
|
||||
}
|
||||
//套餐
|
||||
if (tbProduct.getGroupSnap() == null){
|
||||
tbProductVo.setGroupSnap(new JSONArray());
|
||||
}else {
|
||||
tbProductVo.setGroupSnap(ListUtil.stringChangeList(tbProduct.getGroupSnap()));
|
||||
}
|
||||
BeanUtils.copyProperties(tbProduct, tbProductVo);
|
||||
|
||||
|
||||
@@ -164,12 +179,6 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
map.put(tbProductSpec.get().getName(),tbProductSpec.get().getSpecList());
|
||||
tbProductVo.setSpecsInfo(map);
|
||||
}
|
||||
//单位
|
||||
if (tbShopUnits.get() == null){
|
||||
tbProductVo.setUnitName(null);
|
||||
}else {
|
||||
tbProductVo.setUnitName(tbShopUnits.get().getName());
|
||||
}
|
||||
//sku
|
||||
if (tbProductSkus.get() == null){
|
||||
tbProductVo.setSkuList(new ArrayList<>());
|
||||
@@ -209,12 +218,24 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
TbProduct product = new TbProduct();
|
||||
//组装
|
||||
BeanUtils.copyProperties(resources, product);
|
||||
product.setCategoryId(String.valueOf(resources.getCategoryId()));
|
||||
product.setIsDel(0);
|
||||
product.setIsDelete(0);
|
||||
product.setIsFreeFreight(1);
|
||||
product.setStatus(1);
|
||||
product.setCreatedAt(Instant.now().toEpochMilli());
|
||||
product.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
if (!resources.getGroupSnap().isEmpty()){
|
||||
ListUtil.JSONArrayChangeString(resources.getGroupSnap());
|
||||
}
|
||||
if (resources.getUnitId() != null){
|
||||
product.setUnitId(String.valueOf(resources.getUnitId()));
|
||||
}
|
||||
//套餐内容
|
||||
if (!resources.getGroupSnap().isEmpty()){
|
||||
product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap()));
|
||||
}
|
||||
|
||||
TbProduct save = tbProductRepository.save(product);
|
||||
|
||||
if (save.getId() == null){
|
||||
@@ -252,6 +273,10 @@ public class TbProductServiceImpl implements TbProductService {
|
||||
product.setIsFreeFreight(1);
|
||||
product.setStatus(1);
|
||||
product.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
|
||||
if (!resources.getGroupSnap().isEmpty()){
|
||||
ListUtil.JSONArrayChangeString(resources.getGroupSnap());
|
||||
}
|
||||
TbProduct save = tbProductRepository.save(product);
|
||||
|
||||
//sku
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package me.zhengjie.modules.productInfo.productSku.domain;
|
||||
|
||||
import cn.hutool.json.JSON;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -125,7 +127,6 @@ public class TbProductSku implements Serializable {
|
||||
@Column(name = "`updated_at`")
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
public void copy(TbProductSku source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
@@ -16,8 +16,13 @@
|
||||
package me.zhengjie.modules.productInfo.productStock.repository;
|
||||
|
||||
import me.zhengjie.modules.productInfo.productStock.domain.TbProductStockDetail;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.w3c.dom.stylesheets.LinkStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
@@ -25,4 +30,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
* @date 2024-01-19
|
||||
**/
|
||||
public interface TbProductStockDetailRepository extends JpaRepository<TbProductStockDetail, Long>, JpaSpecificationExecutor<TbProductStockDetail> {
|
||||
|
||||
|
||||
}
|
||||
@@ -59,6 +59,15 @@ public class TbProductStockDetailController {
|
||||
return new ResponseEntity<>(tbProductStockDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/stock")
|
||||
@Log("查询/product/Stock")
|
||||
@ApiOperation("查询/product/Stock")
|
||||
@PreAuthorize("@el.check('tbProductStockDetail:list')")
|
||||
public ResponseEntity<Object> queryPage(@RequestBody TbProductStockDetailQueryCriteria criteria){
|
||||
return new ResponseEntity<>(tbProductStockDetailService.queryPage(criteria),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/product/Stock")
|
||||
@ApiOperation("新增/product/Stock")
|
||||
|
||||
@@ -40,6 +40,8 @@ public interface TbProductStockDetailService {
|
||||
*/
|
||||
Map<String,Object> queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
Map<String,Object> queryPage(TbProductStockDetailQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
|
||||
@@ -41,4 +41,14 @@ public class TbProductStockDetailQueryCriteria{
|
||||
/** BETWEEN */
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<Long> createdAt;
|
||||
@Query
|
||||
private Long createTime;
|
||||
@Query
|
||||
private Long endTime;
|
||||
|
||||
private Integer page;
|
||||
|
||||
private Integer size;
|
||||
|
||||
private String sort = "id,desc";
|
||||
}
|
||||
@@ -24,6 +24,9 @@ import me.zhengjie.modules.productInfo.productStock.service.TbProductStockDetail
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailDto;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.dto.TbProductStockDetailQueryCriteria;
|
||||
import me.zhengjie.modules.productInfo.productStock.service.mapstruct.TbProductStockDetailMapper;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -33,6 +36,7 @@ import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.persistence.criteria.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -56,6 +60,19 @@ public class TbProductStockDetailServiceImpl implements TbProductStockDetailServ
|
||||
return PageUtil.toPage(page.map(tbProductStockDetailMapper::toDto));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryPage(TbProductStockDetailQueryCriteria criteria){
|
||||
Sort sort = Sort.by(Sort.Direction.DESC, "id");
|
||||
Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort);
|
||||
|
||||
Page<TbProductStockDetail> page = tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder)
|
||||
-> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
|
||||
return PageUtil.toPage(page.map(tbProductStockDetailMapper::toDto));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<TbProductStockDetailDto> queryAll(TbProductStockDetailQueryCriteria criteria){
|
||||
return tbProductStockDetailMapper.toDto(tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="tb_shop_purveyor")
|
||||
public class TbShopPurveyor implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "自增id")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "`shop_id`",nullable = false)
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String shopId;
|
||||
|
||||
@Column(name = "`sort`")
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Column(name = "`name`")
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
@Column(name = "`purveyor_name`")
|
||||
@ApiModelProperty(value = "联系人名字")
|
||||
private String purveyorName;
|
||||
|
||||
@Column(name = "`purveyor_telephone`")
|
||||
@ApiModelProperty(value = "联系人电话")
|
||||
private String purveyorTelephone;
|
||||
|
||||
@Column(name = "`period`")
|
||||
@ApiModelProperty(value = "结算周期(日)")
|
||||
private Integer period;
|
||||
|
||||
@Column(name = "`address`")
|
||||
@ApiModelProperty(value = "供应商地址")
|
||||
private String address;
|
||||
|
||||
@Column(name = "`tip`")
|
||||
@ApiModelProperty(value = "标签")
|
||||
private String tip;
|
||||
|
||||
@Column(name = "`remark`")
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@Column(name = "`created_at`")
|
||||
@ApiModelProperty(value = "createdAt")
|
||||
private Long createdAt;
|
||||
|
||||
@Column(name = "`updated_at`")
|
||||
@ApiModelProperty(value = "updatedAt")
|
||||
private Long updatedAt;
|
||||
|
||||
@Column(name = "`last_transact_at`")
|
||||
@ApiModelProperty(value = "最后一次交易时间(主要做排序)")
|
||||
private Long lastTransactAt;
|
||||
|
||||
public void copy(TbShopPurveyor source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.repository;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.domain.TbShopPurveyor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
public interface TbShopPurveyorRepository extends JpaRepository<TbShopPurveyor, Integer>, JpaSpecificationExecutor<TbShopPurveyor> {
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.rest;
|
||||
|
||||
import me.zhengjie.annotation.Log;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.domain.TbShopPurveyor;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.TbShopPurveyorService;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.dto.TbShopPurveyorQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "/shop/purveyor管理")
|
||||
@RequestMapping("/api/tbShopPurveyor")
|
||||
public class TbShopPurveyorController {
|
||||
|
||||
private final TbShopPurveyorService tbShopPurveyorService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('tbShopPurveyor:list')")
|
||||
public void exportTbShopPurveyor(HttpServletResponse response, TbShopPurveyorQueryCriteria criteria) throws IOException {
|
||||
tbShopPurveyorService.download(tbShopPurveyorService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询/shop/purveyor")
|
||||
@ApiOperation("查询/shop/purveyor")
|
||||
@PreAuthorize("@el.check('tbShopPurveyor:list')")
|
||||
public ResponseEntity<Object> queryTbShopPurveyor(TbShopPurveyorQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(tbShopPurveyorService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增/shop/purveyor")
|
||||
@ApiOperation("新增/shop/purveyor")
|
||||
@PreAuthorize("@el.check('tbShopPurveyor:add')")
|
||||
public ResponseEntity<Object> createTbShopPurveyor(@Validated @RequestBody TbShopPurveyor resources){
|
||||
return new ResponseEntity<>(tbShopPurveyorService.create(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改/shop/purveyor")
|
||||
@ApiOperation("修改/shop/purveyor")
|
||||
@PreAuthorize("@el.check('tbShopPurveyor:edit')")
|
||||
public ResponseEntity<Object> updateTbShopPurveyor(@Validated @RequestBody TbShopPurveyor resources){
|
||||
tbShopPurveyorService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除/shop/purveyor")
|
||||
@ApiOperation("删除/shop/purveyor")
|
||||
@PreAuthorize("@el.check('tbShopPurveyor:del')")
|
||||
public ResponseEntity<Object> deleteTbShopPurveyor(@RequestBody Integer[] ids) {
|
||||
tbShopPurveyorService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.service;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.domain.TbShopPurveyor;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.dto.TbShopPurveyorDto;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.dto.TbShopPurveyorQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务接口
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
public interface TbShopPurveyorService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(TbShopPurveyorQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<TbShopPurveyorDto>
|
||||
*/
|
||||
List<TbShopPurveyorDto> queryAll(TbShopPurveyorQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id ID
|
||||
* @return TbShopPurveyorDto
|
||||
*/
|
||||
TbShopPurveyorDto findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
* @return TbShopPurveyorDto
|
||||
*/
|
||||
TbShopPurveyorDto create(TbShopPurveyor resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(TbShopPurveyor resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<TbShopPurveyorDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description /
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
@Data
|
||||
public class TbShopPurveyorDto implements Serializable {
|
||||
|
||||
/** 自增id */
|
||||
private Integer id;
|
||||
|
||||
/** 店铺Id */
|
||||
private String shopId;
|
||||
|
||||
/** 排序 */
|
||||
private Integer sort;
|
||||
|
||||
/** 名称 */
|
||||
private String name;
|
||||
|
||||
/** 联系人名字 */
|
||||
private String purveyorName;
|
||||
|
||||
/** 联系人电话 */
|
||||
private String purveyorTelephone;
|
||||
|
||||
/** 结算周期(日) */
|
||||
private Integer period;
|
||||
|
||||
/** 供应商地址 */
|
||||
private String address;
|
||||
|
||||
/** 标签 */
|
||||
private String tip;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
/** 最后一次交易时间(主要做排序) */
|
||||
private Long lastTransactAt;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import me.zhengjie.annotation.Query;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
@Data
|
||||
public class TbShopPurveyorQueryCriteria{
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String shopId;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String name;
|
||||
|
||||
/** 精确 */
|
||||
@Query
|
||||
private String address;
|
||||
/** BETWEEN */
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<Long> createdAt;
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.service.impl;
|
||||
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.domain.TbShopPurveyor;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.repository.TbShopPurveyorRepository;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.TbShopPurveyorService;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.dto.TbShopPurveyorDto;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.dto.TbShopPurveyorQueryCriteria;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.mapstruct.TbShopPurveyorMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import me.zhengjie.utils.PageUtil;
|
||||
import me.zhengjie.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @description 服务实现
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopPurveyorServiceImpl implements TbShopPurveyorService {
|
||||
|
||||
private final TbShopPurveyorRepository tbShopPurveyorRepository;
|
||||
private final TbShopPurveyorMapper tbShopPurveyorMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopPurveyorQueryCriteria criteria, Pageable pageable){
|
||||
Page<TbShopPurveyor> page = tbShopPurveyorRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(tbShopPurveyorMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbShopPurveyorDto> queryAll(TbShopPurveyorQueryCriteria criteria){
|
||||
return tbShopPurveyorMapper.toDto(tbShopPurveyorRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public TbShopPurveyorDto findById(Integer id) {
|
||||
TbShopPurveyor tbShopPurveyor = tbShopPurveyorRepository.findById(id).orElseGet(TbShopPurveyor::new);
|
||||
ValidationUtil.isNull(tbShopPurveyor.getId(),"TbShopPurveyor","id",id);
|
||||
return tbShopPurveyorMapper.toDto(tbShopPurveyor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TbShopPurveyorDto create(TbShopPurveyor resources) {
|
||||
return tbShopPurveyorMapper.toDto(tbShopPurveyorRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(TbShopPurveyor resources) {
|
||||
TbShopPurveyor tbShopPurveyor = tbShopPurveyorRepository.findById(resources.getId()).orElseGet(TbShopPurveyor::new);
|
||||
ValidationUtil.isNull( tbShopPurveyor.getId(),"TbShopPurveyor","id",resources.getId());
|
||||
tbShopPurveyor.copy(resources);
|
||||
tbShopPurveyorRepository.save(tbShopPurveyor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Integer[] ids) {
|
||||
for (Integer id : ids) {
|
||||
tbShopPurveyorRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<TbShopPurveyorDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (TbShopPurveyorDto tbShopPurveyor : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("店铺Id", tbShopPurveyor.getShopId());
|
||||
map.put("排序", tbShopPurveyor.getSort());
|
||||
map.put("名称", tbShopPurveyor.getName());
|
||||
map.put("联系人名字", tbShopPurveyor.getPurveyorName());
|
||||
map.put("联系人电话", tbShopPurveyor.getPurveyorTelephone());
|
||||
map.put("结算周期(日)", tbShopPurveyor.getPeriod());
|
||||
map.put("供应商地址", tbShopPurveyor.getAddress());
|
||||
map.put("标签", tbShopPurveyor.getTip());
|
||||
map.put("备注", tbShopPurveyor.getRemark());
|
||||
map.put(" createdAt", tbShopPurveyor.getCreatedAt());
|
||||
map.put(" updatedAt", tbShopPurveyor.getUpdatedAt());
|
||||
map.put("最后一次交易时间(主要做排序)", tbShopPurveyor.getLastTransactAt());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package me.zhengjie.modules.shopInfo.shopPurveyor.service.mapstruct;
|
||||
|
||||
import me.zhengjie.base.BaseMapper;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.domain.TbShopPurveyor;
|
||||
import me.zhengjie.modules.shopInfo.shopPurveyor.service.dto.TbShopPurveyorDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
* @author lyf
|
||||
* @date 2024-01-22
|
||||
**/
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TbShopPurveyorMapper extends BaseMapper<TbShopPurveyorDto, TbShopPurveyor> {
|
||||
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package me.zhengjie.modules.system.repository;
|
||||
import me.zhengjie.modules.system.domain.DictDetail;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,4 +34,6 @@ public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, J
|
||||
* @return /
|
||||
*/
|
||||
List<DictDetail> findByDictName(String name);
|
||||
|
||||
|
||||
}
|
||||
@@ -18,6 +18,8 @@ package me.zhengjie.modules.system.repository;
|
||||
import me.zhengjie.modules.system.domain.Dict;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -40,4 +42,7 @@ public interface DictRepository extends JpaRepository<Dict, Long>, JpaSpecificat
|
||||
* @return /
|
||||
*/
|
||||
List<Dict> findByIdIn(Set<Long> ids);
|
||||
|
||||
@Query("select dict from Dict dict where dict.name =:name")
|
||||
Dict findByName(@Param("name") String name);
|
||||
}
|
||||
@@ -67,6 +67,7 @@ public class DictController {
|
||||
return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@Log("新增字典")
|
||||
@ApiOperation("新增字典")
|
||||
@PostMapping
|
||||
|
||||
@@ -56,6 +56,11 @@ public class DictDetailController {
|
||||
return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("通过dict查询字典详情")
|
||||
@GetMapping("/{name}")
|
||||
public ResponseEntity<Object> queryDictById(@PathVariable String name){
|
||||
return new ResponseEntity<>(dictDetailService.queryName(name),HttpStatus.OK);
|
||||
}
|
||||
@ApiOperation("查询多个字典详情")
|
||||
@GetMapping(value = "/map")
|
||||
public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName){
|
||||
|
||||
@@ -46,6 +46,8 @@ public interface DictDetailService {
|
||||
*/
|
||||
void delete(Long id);
|
||||
|
||||
List<DictDetail> queryName(String name);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param criteria 条件
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package me.zhengjie.modules.system.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.system.domain.Dict;
|
||||
import me.zhengjie.modules.system.domain.DictDetail;
|
||||
import me.zhengjie.modules.system.repository.DictRepository;
|
||||
@@ -31,6 +32,8 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -88,6 +91,15 @@ public class DictDetailServiceImpl implements DictDetailService {
|
||||
dictDetailRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictDetail> queryName(String name) {
|
||||
Dict byName = dictRepository.findByName(name);
|
||||
if (byName.getId() == null){
|
||||
throw new BadRequestException("字典值有误");
|
||||
}
|
||||
return byName.getDictDetails();
|
||||
}
|
||||
|
||||
public void delCaches(DictDetail dictDetail){
|
||||
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
|
||||
redisUtils.del(CacheKey.DICT_NAME + dict.getName());
|
||||
|
||||
Reference in New Issue
Block a user