From 29b794507aa5eb6c61025bf8f8807e5f65cef612 Mon Sep 17 00:00:00 2001 From: liuyingfang <1357764963@qq.com> Date: Tue, 23 Jan 2024 10:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E7=9B=B8=E5=85=B3=EF=BC=8C=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=BA=93=E5=AD=98=E5=88=97=E8=A1=A8=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/zhengjie/utils/ListUtil.java | 9 +- .../productInfo/product/domain/TbProduct.java | 12 ++ .../product/domain/TbProductVo.java | 15 +-- .../service/impl/TbProductServiceImpl.java | 37 +++++- .../productSku/domain/TbProductSku.java | 3 +- .../TbProductStockDetailRepository.java | 7 ++ .../rest/TbProductStockDetailController.java | 9 ++ .../service/TbProductStockDetailService.java | 2 + .../TbProductStockDetailQueryCriteria.java | 10 ++ .../impl/TbProductStockDetailServiceImpl.java | 17 +++ .../shopPurveyor/domain/TbShopPurveyor.java | 95 +++++++++++++++ .../repository/TbShopPurveyorRepository.java | 28 +++++ .../rest/TbShopPurveyorController.java | 87 +++++++++++++ .../service/TbShopPurveyorService.java | 83 +++++++++++++ .../service/dto/TbShopPurveyorDto.java | 66 ++++++++++ .../dto/TbShopPurveyorQueryCriteria.java | 44 +++++++ .../impl/TbShopPurveyorServiceImpl.java | 115 ++++++++++++++++++ .../mapstruct/TbShopPurveyorMapper.java | 32 +++++ .../repository/DictDetailRepository.java | 3 + .../system/repository/DictRepository.java | 5 + .../modules/system/rest/DictController.java | 1 + .../system/rest/DictDetailController.java | 5 + .../system/service/DictDetailService.java | 2 + .../service/impl/DictDetailServiceImpl.java | 12 ++ 24 files changed, 682 insertions(+), 17 deletions(-) create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/domain/TbShopPurveyor.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/repository/TbShopPurveyorRepository.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/TbShopPurveyorService.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorDto.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorQueryCriteria.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/impl/TbShopPurveyorServiceImpl.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/mapstruct/TbShopPurveyorMapper.java diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ListUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/ListUtil.java index e1d0663b..bca970ee 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/ListUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/ListUtil.java @@ -26,6 +26,11 @@ public class ListUtil { } + + public static String JSONArrayChangeString(JSONArray jsonArray){ + return jsonArray.toString(); + } + public static List stringChangeStringList(String listString){ // 使用Fastjson将JSON字符串转换为JSONArray对象 @@ -45,8 +50,6 @@ public class ListUtil { } System.out.println(integerList); return integerList; -// return listString.stream() -// .map(Integer::valueOf) -// .collect(Collectors.toList()); } + } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProduct.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProduct.java index 0a8b1641..c4e78fad 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProduct.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProduct.java @@ -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)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java index aba2a2a8..7c6b530a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java @@ -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 skuList; private HashMap specsInfo; + private String specInfo; + private String selectSpec; + + private String specTableHeaders; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java index 956230d1..5341058a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java @@ -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 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/domain/TbProductSku.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/domain/TbProductSku.java index 177ee296..215e9cd2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/domain/TbProductSku.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/domain/TbProductSku.java @@ -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)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/repository/TbProductStockDetailRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/repository/TbProductStockDetailRepository.java index 721a89d3..baacc2e9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/repository/TbProductStockDetailRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/repository/TbProductStockDetailRepository.java @@ -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, JpaSpecificationExecutor { + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/rest/TbProductStockDetailController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/rest/TbProductStockDetailController.java index 935a9b24..a4170018 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/rest/TbProductStockDetailController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/rest/TbProductStockDetailController.java @@ -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 queryPage(@RequestBody TbProductStockDetailQueryCriteria criteria){ + return new ResponseEntity<>(tbProductStockDetailService.queryPage(criteria),HttpStatus.OK); + } + + @PostMapping @Log("新增/product/Stock") @ApiOperation("新增/product/Stock") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/TbProductStockDetailService.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/TbProductStockDetailService.java index 0d8729c0..f27c8213 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/TbProductStockDetailService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/TbProductStockDetailService.java @@ -40,6 +40,8 @@ public interface TbProductStockDetailService { */ Map queryAll(TbProductStockDetailQueryCriteria criteria, Pageable pageable); + Map queryPage(TbProductStockDetailQueryCriteria criteria); + /** * 查询所有数据不分页 * @param criteria 条件参数 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/dto/TbProductStockDetailQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/dto/TbProductStockDetailQueryCriteria.java index e9f3aab9..61e6096b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/dto/TbProductStockDetailQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/dto/TbProductStockDetailQueryCriteria.java @@ -41,4 +41,14 @@ public class TbProductStockDetailQueryCriteria{ /** BETWEEN */ @Query(type = Query.Type.BETWEEN) private List createdAt; + @Query + private Long createTime; + @Query + private Long endTime; + + private Integer page; + + private Integer size; + + private String sort = "id,desc"; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/impl/TbProductStockDetailServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/impl/TbProductStockDetailServiceImpl.java index d55d9bff..12dc7f81 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/impl/TbProductStockDetailServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStock/service/impl/TbProductStockDetailServiceImpl.java @@ -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 queryPage(TbProductStockDetailQueryCriteria criteria){ + Sort sort = Sort.by(Sort.Direction.DESC, "id"); + Pageable pageable = PageRequest.of(criteria.getPage(), criteria.getSize(), sort); + + Page page = tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) + -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + + return PageUtil.toPage(page.map(tbProductStockDetailMapper::toDto)); + } + + @Override public List queryAll(TbProductStockDetailQueryCriteria criteria){ return tbProductStockDetailMapper.toDto(tbProductStockDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/domain/TbShopPurveyor.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/domain/TbShopPurveyor.java new file mode 100644 index 00000000..035d4b3b --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/domain/TbShopPurveyor.java @@ -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)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/repository/TbShopPurveyorRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/repository/TbShopPurveyorRepository.java new file mode 100644 index 00000000..826bc45a --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/repository/TbShopPurveyorRepository.java @@ -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, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java new file mode 100644 index 00000000..6838d8cc --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/rest/TbShopPurveyorController.java @@ -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 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 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 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 deleteTbShopPurveyor(@RequestBody Integer[] ids) { + tbShopPurveyorService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/TbShopPurveyorService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/TbShopPurveyorService.java new file mode 100644 index 00000000..878823fa --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/TbShopPurveyorService.java @@ -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 + */ + Map queryAll(TbShopPurveyorQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List 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 all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorDto.java new file mode 100644 index 00000000..5baa6246 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorDto.java @@ -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; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorQueryCriteria.java new file mode 100644 index 00000000..ec19948c --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/dto/TbShopPurveyorQueryCriteria.java @@ -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 createdAt; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/impl/TbShopPurveyorServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/impl/TbShopPurveyorServiceImpl.java new file mode 100644 index 00000000..7f3e845d --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/impl/TbShopPurveyorServiceImpl.java @@ -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 queryAll(TbShopPurveyorQueryCriteria criteria, Pageable pageable){ + Page page = tbShopPurveyorRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbShopPurveyorMapper::toDto)); + } + + @Override + public List 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 all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbShopPurveyorDto tbShopPurveyor : all) { + Map 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); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/mapstruct/TbShopPurveyorMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/mapstruct/TbShopPurveyorMapper.java new file mode 100644 index 00000000..736e5ca9 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopPurveyor/service/mapstruct/TbShopPurveyorMapper.java @@ -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 { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java index d80b9702..d28159cb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java @@ -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, J * @return / */ List findByDictName(String name); + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java index f09b6d1b..48e2a258 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java @@ -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, JpaSpecificat * @return / */ List findByIdIn(Set ids); + + @Query("select dict from Dict dict where dict.name =:name") + Dict findByName(@Param("name") String name); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java index 70705781..5156e308 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java @@ -67,6 +67,7 @@ public class DictController { return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK); } + @Log("新增字典") @ApiOperation("新增字典") @PostMapping diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java index 8ddbfe4b..7170110c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java @@ -56,6 +56,11 @@ public class DictDetailController { return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK); } + @ApiOperation("通过dict查询字典详情") + @GetMapping("/{name}") + public ResponseEntity queryDictById(@PathVariable String name){ + return new ResponseEntity<>(dictDetailService.queryName(name),HttpStatus.OK); + } @ApiOperation("查询多个字典详情") @GetMapping(value = "/map") public ResponseEntity getDictDetailMaps(@RequestParam String dictName){ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java index 3912a475..2291ed6c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java @@ -46,6 +46,8 @@ public interface DictDetailService { */ void delete(Long id); + List queryName(String name); + /** * 分页查询 * @param criteria 条件 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java index 3f5fc742..3c2898c1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java @@ -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 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());