diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/NewBadRequestException.java b/eladmin-common/src/main/java/me/zhengjie/exception/NewBadRequestException.java new file mode 100644 index 00000000..85f822df --- /dev/null +++ b/eladmin-common/src/main/java/me/zhengjie/exception/NewBadRequestException.java @@ -0,0 +1,24 @@ +package me.zhengjie.exception; + +import lombok.Getter; +import org.springframework.http.HttpStatus; + +import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.OK; + +/** + * @author lyf + */ +@Getter +public class NewBadRequestException extends RuntimeException{ + private Integer status = OK.value(); + + public NewBadRequestException(String msg){ + super(msg); + } + + public NewBadRequestException(HttpStatus status, String msg){ + super(msg); + this.status = status.value(); + } +} diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/Threads.java b/eladmin-common/src/main/java/me/zhengjie/utils/Threads.java new file mode 100644 index 00000000..aab0b03c --- /dev/null +++ b/eladmin-common/src/main/java/me/zhengjie/utils/Threads.java @@ -0,0 +1,16 @@ +package me.zhengjie.utils; + +import java.util.concurrent.CompletableFuture; + +/** + * 线程相关 + */ +public class Threads { + /** + * 并行执行 + * @param cfs + */ + public static void call(CompletableFuture... cfs){ + CompletableFuture.allOf(cfs); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java index 74dfd1c6..9bfa9b68 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/rest/TbProductController.java @@ -17,6 +17,7 @@ package me.zhengjie.modules.productInfo.product.rest; import me.zhengjie.annotation.Log; import me.zhengjie.modules.productInfo.product.domain.TbProduct; +import me.zhengjie.modules.productInfo.product.domain.TbProductVo; import me.zhengjie.modules.productInfo.product.service.TbProductService; import me.zhengjie.modules.productInfo.product.service.dto.TbProductQueryCriteria; import org.springframework.data.domain.Pageable; @@ -59,6 +60,16 @@ public class TbProductController { return new ResponseEntity<>(tbProductService.queryAll(criteria,pageable),HttpStatus.OK); } + @GetMapping("/{product}") + @Log("查询/product") + @ApiOperation("查询/product") + @PreAuthorize("@el.check('tbProduct:list')") + public Object queryTbProductInfo(@PathVariable("product") Integer product)throws Exception{ + return tbProductService.findByProductId(product); + } + + + @PostMapping @Log("新增/product") @ApiOperation("新增/product") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/TbProductService.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/TbProductService.java index c98905df..9ea81549 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/TbProductService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/TbProductService.java @@ -16,6 +16,7 @@ package me.zhengjie.modules.productInfo.product.service; import me.zhengjie.modules.productInfo.product.domain.TbProduct; +import me.zhengjie.modules.productInfo.product.domain.TbProductVo; import me.zhengjie.modules.productInfo.product.service.dto.TbProductDto; import me.zhengjie.modules.productInfo.product.service.dto.TbProductQueryCriteria; import org.springframework.data.domain.Pageable; @@ -54,6 +55,8 @@ public interface TbProductService { */ TbProductDto findById(Integer id); + TbProductVo findByProductId(Integer id)throws Exception; + /** * 创建 * @param resources / 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 d73d8fc4..2945e600 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 @@ -26,21 +26,19 @@ import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec; import me.zhengjie.modules.productInfo.productSpec.repository.TbProductSpecRepository; import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku; import me.zhengjie.modules.productInfo.productSku.repository.TbProductSkuRepository; -import me.zhengjie.modules.shopUnit.domain.TbShopUnit; -import me.zhengjie.modules.shopUnit.repository.TbShopUnitRepository; -import me.zhengjie.utils.ValidationUtil; -import me.zhengjie.utils.FileUtil; +import me.zhengjie.modules.shopInfo.shopUnit.domain.TbShopUnit; +import me.zhengjie.modules.shopInfo.shopUnit.repository.TbShopUnitRepository; +import me.zhengjie.utils.*; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; 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.*; import java.io.IOException; +import java.util.concurrent.CompletableFuture; import javax.servlet.http.HttpServletResponse; /** @@ -131,6 +129,34 @@ public class TbProductServiceImpl implements TbProductService { return PageUtil.toPage(tbProductVoList,tbProductVoList.size()); } + @Override + public TbProductVo findByProductId(Integer id) throws Exception{ + TbProduct tbProduct = tbProductRepository.findById(id).orElseGet(TbProduct::new); + + //单位 + CompletableFuture tbShopUnits = CompletableFuture.supplyAsync(() -> + tbShopUnitRepository.searchUnit(Integer.valueOf(tbProduct.getUnitId()))); + //sku + CompletableFuture> tbProductSkus = CompletableFuture.supplyAsync(() -> + tbProductSkuRepository.searchSku(tbProduct.getId().toString())); + //商品规格 + CompletableFuture tbProductSpec = CompletableFuture.supplyAsync(() -> + tbProductSpecRepository.searchSpec(tbProduct.getSpecId())); + + Threads.call(tbShopUnits,tbProductSkus,tbProductSpec); + //组装 + TbProductVo tbProductVo = new TbProductVo(); + BeanUtils.copyProperties(tbProduct, tbProductVo); + + + HashMap map = new HashMap<>(); + map.put(tbProductSpec.get().getName(),tbProductSpec.get().getSpecList()); + tbProductVo.setUnitName(tbShopUnits.get().getName()); + tbProductVo.setSkuList(tbProductSkus.get()); + tbProductVo.setSpecsInfo(map); + return tbProductVo; + } + @Override public List queryAll(TbProductQueryCriteria criteria){ return tbProductMapper.toDto(tbProductRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); @@ -144,6 +170,7 @@ public class TbProductServiceImpl implements TbProductService { return tbProductMapper.toDto(tbProduct); } + @Override @Transactional(rollbackFor = Exception.class) public TbProductDto create(TbProduct resources) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/domain/TbShopCategory.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/domain/TbShopCategory.java new file mode 100644 index 00000000..ec5fabef --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/domain/TbShopCategory.java @@ -0,0 +1,105 @@ +/* +* 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.productInfo.productCategory.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-08 +**/ +@Entity +@Data +@Table(name="tb_shop_category") +public class TbShopCategory implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "自增id") + private Integer id; + + @Column(name = "`name`",nullable = false) + @NotBlank + @ApiModelProperty(value = "分类名称") + private String name; + + @Column(name = "`short_name`") + @ApiModelProperty(value = "简称") + private String shortName; + + @Column(name = "`tree`") + @ApiModelProperty(value = "分类层级") + private String tree; + + @Column(name = "`pid`") + @ApiModelProperty(value = "上级分类id-为0则表示是顶级") + private String pid; + + @Column(name = "`pic`") + @ApiModelProperty(value = "图标") + private String pic; + + @Column(name = "`merchant_id`") + @ApiModelProperty(value = "商户Id") + private String merchantId; + + @Column(name = "`shop_id`",nullable = false) + @NotBlank + @ApiModelProperty(value = "店铺Id") + private String shopId; + + @Column(name = "`style`") + @ApiModelProperty(value = "颜色格式标识") + private String style; + + @Column(name = "`is_show`",nullable = false) + @NotNull + @ApiModelProperty(value = "是否显示:1显示 0不显示") + private Integer isShow; + + @Column(name = "`detail`") + @ApiModelProperty(value = "分类描述") + private String detail; + + @Column(name = "`sort`") + @ApiModelProperty(value = "排序") + private Integer sort; + + @Column(name = "`key_word`") + @ApiModelProperty(value = "关键词") + private String keyWord; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "createdAt") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + public void copy(TbShopCategory source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/repository/TbShopCategoryRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/repository/TbShopCategoryRepository.java new file mode 100644 index 00000000..2d38d352 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/repository/TbShopCategoryRepository.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.productInfo.productCategory.repository; + +import me.zhengjie.modules.productInfo.productCategory.domain.TbShopCategory; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-08 +**/ +public interface TbShopCategoryRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/rest/TbShopCategoryController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/rest/TbShopCategoryController.java new file mode 100644 index 00000000..62deabc6 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/rest/TbShopCategoryController.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.productInfo.productCategory.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.productInfo.productCategory.domain.TbShopCategory; +import me.zhengjie.modules.productInfo.productCategory.service.TbShopCategoryService; +import me.zhengjie.modules.productInfo.productCategory.service.dto.TbShopCategoryQueryCriteria; +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-08 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "product/category管理") +@RequestMapping("/api/tbShopCategory") +public class TbShopCategoryController { + + private final TbShopCategoryService tbShopCategoryService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('tbShopCategory:list')") + public void exportTbShopCategory(HttpServletResponse response, TbShopCategoryQueryCriteria criteria) throws IOException { + tbShopCategoryService.download(tbShopCategoryService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询product/category") + @ApiOperation("查询product/category") + @PreAuthorize("@el.check('tbShopCategory:list')") + public ResponseEntity queryTbShopCategory(TbShopCategoryQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(tbShopCategoryService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增product/category") + @ApiOperation("新增product/category") + @PreAuthorize("@el.check('tbShopCategory:add')") + public ResponseEntity createTbShopCategory(@Validated @RequestBody TbShopCategory resources){ + return new ResponseEntity<>(tbShopCategoryService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改product/category") + @ApiOperation("修改product/category") + @PreAuthorize("@el.check('tbShopCategory:edit')") + public ResponseEntity updateTbShopCategory(@Validated @RequestBody TbShopCategory resources){ + tbShopCategoryService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除product/category") + @ApiOperation("删除product/category") + @PreAuthorize("@el.check('tbShopCategory:del')") + public ResponseEntity deleteTbShopCategory(@RequestBody Integer[] ids) { + tbShopCategoryService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/TbShopCategoryService.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/TbShopCategoryService.java new file mode 100644 index 00000000..c6d18c69 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/TbShopCategoryService.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.productInfo.productCategory.service; + +import me.zhengjie.modules.productInfo.productCategory.domain.TbShopCategory; +import me.zhengjie.modules.productInfo.productCategory.service.dto.TbShopCategoryDto; +import me.zhengjie.modules.productInfo.productCategory.service.dto.TbShopCategoryQueryCriteria; +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-08 +**/ +public interface TbShopCategoryService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(TbShopCategoryQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(TbShopCategoryQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbShopCategoryDto + */ + TbShopCategoryDto findById(Integer id); + + /** + * 创建 + * @param resources / + * @return TbShopCategoryDto + */ + TbShopCategoryDto create(TbShopCategory resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbShopCategory 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/productInfo/productCategory/service/dto/TbShopCategoryDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/dto/TbShopCategoryDto.java new file mode 100644 index 00000000..b143a5fe --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/dto/TbShopCategoryDto.java @@ -0,0 +1,72 @@ +/* +* 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.productInfo.productCategory.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-01-08 +**/ +@Data +public class TbShopCategoryDto implements Serializable { + + /** 自增id */ + private Integer id; + + /** 分类名称 */ + private String name; + + /** 简称 */ + private String shortName; + + /** 分类层级 */ + private String tree; + + /** 上级分类id-为0则表示是顶级 */ + private String pid; + + /** 图标 */ + private String pic; + + /** 商户Id */ + private String merchantId; + + /** 店铺Id */ + private String shopId; + + /** 颜色格式标识 */ + private String style; + + /** 是否显示:1显示 0不显示 */ + private Integer isShow; + + /** 分类描述 */ + private String detail; + + /** 排序 */ + private Integer sort; + + /** 关键词 */ + private String keyWord; + + private Long createdAt; + + private Long updatedAt; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/dto/TbShopCategoryQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/dto/TbShopCategoryQueryCriteria.java new file mode 100644 index 00000000..398fd8a2 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/dto/TbShopCategoryQueryCriteria.java @@ -0,0 +1,41 @@ +/* +* 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.productInfo.productCategory.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-08 +**/ +@Data +public class TbShopCategoryQueryCriteria{ + + /** 精确 */ + @Query + private Integer id; + + /** 精确 */ + @Query + private String shortName; + + /** 精确 */ + @Query + private String shopId; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/impl/TbShopCategoryServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/impl/TbShopCategoryServiceImpl.java new file mode 100644 index 00000000..d6bb4b6d --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/impl/TbShopCategoryServiceImpl.java @@ -0,0 +1,117 @@ +/* +* 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.productInfo.productCategory.service.impl; + +import me.zhengjie.modules.productInfo.productCategory.domain.TbShopCategory; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.productInfo.productCategory.repository.TbShopCategoryRepository; +import me.zhengjie.modules.productInfo.productCategory.service.TbShopCategoryService; +import me.zhengjie.modules.productInfo.productCategory.service.dto.TbShopCategoryDto; +import me.zhengjie.modules.productInfo.productCategory.service.dto.TbShopCategoryQueryCriteria; +import me.zhengjie.modules.productInfo.productCategory.service.mapstruct.TbShopCategoryMapper; +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-08 +**/ +@Service +@RequiredArgsConstructor +public class TbShopCategoryServiceImpl implements TbShopCategoryService { + + private final TbShopCategoryRepository tbShopCategoryRepository; + private final TbShopCategoryMapper tbShopCategoryMapper; + + @Override + public Map queryAll(TbShopCategoryQueryCriteria criteria, Pageable pageable){ + Page page = tbShopCategoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbShopCategoryMapper::toDto)); + } + + @Override + public List queryAll(TbShopCategoryQueryCriteria criteria){ + return tbShopCategoryMapper.toDto(tbShopCategoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public TbShopCategoryDto findById(Integer id) { + TbShopCategory tbShopCategory = tbShopCategoryRepository.findById(id).orElseGet(TbShopCategory::new); + ValidationUtil.isNull(tbShopCategory.getId(),"TbShopCategory","id",id); + return tbShopCategoryMapper.toDto(tbShopCategory); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbShopCategoryDto create(TbShopCategory resources) { + return tbShopCategoryMapper.toDto(tbShopCategoryRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbShopCategory resources) { + TbShopCategory tbShopCategory = tbShopCategoryRepository.findById(resources.getId()).orElseGet(TbShopCategory::new); + ValidationUtil.isNull( tbShopCategory.getId(),"TbShopCategory","id",resources.getId()); + tbShopCategory.copy(resources); + tbShopCategoryRepository.save(tbShopCategory); + } + + @Override + public void deleteAll(Integer[] ids) { + for (Integer id : ids) { + tbShopCategoryRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbShopCategoryDto tbShopCategory : all) { + Map map = new LinkedHashMap<>(); + map.put("分类名称", tbShopCategory.getName()); + map.put("简称", tbShopCategory.getShortName()); + map.put("分类层级", tbShopCategory.getTree()); + map.put("上级分类id-为0则表示是顶级", tbShopCategory.getPid()); + map.put("图标", tbShopCategory.getPic()); + map.put("商户Id", tbShopCategory.getMerchantId()); + map.put("店铺Id", tbShopCategory.getShopId()); + map.put("颜色格式标识", tbShopCategory.getStyle()); + map.put("是否显示:1显示 0不显示", tbShopCategory.getIsShow()); + map.put("分类描述", tbShopCategory.getDetail()); + map.put("排序", tbShopCategory.getSort()); + map.put("关键词", tbShopCategory.getKeyWord()); + map.put(" createdAt", tbShopCategory.getCreatedAt()); + map.put(" updatedAt", tbShopCategory.getUpdatedAt()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/mapstruct/TbShopCategoryMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/mapstruct/TbShopCategoryMapper.java new file mode 100644 index 00000000..e2cae55d --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productCategory/service/mapstruct/TbShopCategoryMapper.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.productInfo.productCategory.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.productInfo.productCategory.domain.TbShopCategory; +import me.zhengjie.modules.productInfo.productCategory.service.dto.TbShopCategoryDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-08 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbShopCategoryMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/repository/TbProductSkuRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/repository/TbProductSkuRepository.java index 3accec3b..420f3081 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/repository/TbProductSkuRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSku/repository/TbProductSkuRepository.java @@ -33,4 +33,7 @@ public interface TbProductSkuRepository extends JpaRepository searchSku(@Param("productId")List productId); + @Query("SELECT sku FROM TbProductSku sku WHERE sku.productId = :productId") + List searchSku(@Param("productId")String productId); + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/repository/TbProductSpecRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/repository/TbProductSpecRepository.java index 504792d0..a388ecb8 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/repository/TbProductSpecRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSpec/repository/TbProductSpecRepository.java @@ -32,4 +32,7 @@ public interface TbProductSpecRepository extends JpaRepository searchSpec(@Param("ids")List ids); + + @Query("SELECT spec FROM TbProductSpec spec WHERE spec.id = :ids") + TbProductSpec searchSpec(@Param("ids")Integer ids); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java index 2488d21e..12ef47ce 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java @@ -34,8 +34,8 @@ import me.zhengjie.modules.security.security.TokenProvider; import me.zhengjie.modules.security.service.dto.AuthUserDto; import me.zhengjie.modules.security.service.dto.JwtUserDto; import me.zhengjie.modules.security.service.OnlineUserService; -import me.zhengjie.modules.shop.domain.TbShopInfo; -import me.zhengjie.modules.shop.repository.TbShopInfoRepository; +import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; +import me.zhengjie.modules.shopInfo.shop.repository.TbShopInfoRepository; import me.zhengjie.utils.RsaUtils; import me.zhengjie.utils.RedisUtils; import me.zhengjie.utils.SecurityUtils; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/domain/TbShopInfo.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/domain/TbShopInfo.java similarity index 99% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/domain/TbShopInfo.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/domain/TbShopInfo.java index b3057288..c14d9d96 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/domain/TbShopInfo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/domain/TbShopInfo.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.domain; +package me.zhengjie.modules.shopInfo.shop.domain; import lombok.Data; import cn.hutool.core.bean.BeanUtil; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/repository/TbShopInfoRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/repository/TbShopInfoRepository.java similarity index 90% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/repository/TbShopInfoRepository.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/repository/TbShopInfoRepository.java index 90196905..1f598e74 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/repository/TbShopInfoRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/repository/TbShopInfoRepository.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.repository; +package me.zhengjie.modules.shopInfo.shop.repository; -import me.zhengjie.modules.shop.domain.TbShopInfo; +import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/rest/TbShopInfoController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/rest/TbShopInfoController.java similarity index 92% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/rest/TbShopInfoController.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/rest/TbShopInfoController.java index 1a718225..fdf9fe62 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/rest/TbShopInfoController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/rest/TbShopInfoController.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.rest; +package me.zhengjie.modules.shopInfo.shop.rest; import me.zhengjie.annotation.Log; -import me.zhengjie.modules.shop.domain.TbShopInfo; -import me.zhengjie.modules.shop.service.TbShopInfoService; -import me.zhengjie.modules.shop.service.dto.TbShopInfoQueryCriteria; +import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; +import me.zhengjie.modules.shopInfo.shop.service.TbShopInfoService; +import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/TbShopInfoService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/TbShopInfoService.java similarity index 88% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/service/TbShopInfoService.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/TbShopInfoService.java index cc3acb37..8ca19b5b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/TbShopInfoService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/TbShopInfoService.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.service; +package me.zhengjie.modules.shopInfo.shop.service; -import me.zhengjie.modules.shop.domain.TbShopInfo; -import me.zhengjie.modules.shop.service.dto.TbShopInfoDto; -import me.zhengjie.modules.shop.service.dto.TbShopInfoQueryCriteria; +import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; +import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoDto; +import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/dto/TbShopInfoDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoDto.java similarity index 98% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/service/dto/TbShopInfoDto.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoDto.java index f02d0ace..76c3b0fc 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/dto/TbShopInfoDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.service.dto; +package me.zhengjie.modules.shopInfo.shop.service.dto; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/dto/TbShopInfoQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoQueryCriteria.java similarity index 96% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/service/dto/TbShopInfoQueryCriteria.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoQueryCriteria.java index e88a6378..180328c7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/dto/TbShopInfoQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/dto/TbShopInfoQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.service.dto; +package me.zhengjie.modules.shopInfo.shop.service.dto; import lombok.Data; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/impl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java similarity index 93% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/service/impl/TbShopInfoServiceImpl.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java index 7bd64b07..537965c2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/impl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.service.impl; +package me.zhengjie.modules.shopInfo.shop.service.impl; -import me.zhengjie.modules.shop.domain.TbShopInfo; +import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; -import me.zhengjie.modules.shop.repository.TbShopInfoRepository; -import me.zhengjie.modules.shop.service.TbShopInfoService; -import me.zhengjie.modules.shop.service.dto.TbShopInfoDto; -import me.zhengjie.modules.shop.service.dto.TbShopInfoQueryCriteria; -import me.zhengjie.modules.shop.service.mapstruct.TbShopInfoMapper; +import me.zhengjie.modules.shopInfo.shop.repository.TbShopInfoRepository; +import me.zhengjie.modules.shopInfo.shop.service.TbShopInfoService; +import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoDto; +import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoQueryCriteria; +import me.zhengjie.modules.shopInfo.shop.service.mapstruct.TbShopInfoMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/mapstruct/TbShopInfoMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/mapstruct/TbShopInfoMapper.java similarity index 83% rename from eladmin-system/src/main/java/me/zhengjie/modules/shop/service/mapstruct/TbShopInfoMapper.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/mapstruct/TbShopInfoMapper.java index b1257e0c..ffb97501 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shop/service/mapstruct/TbShopInfoMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/mapstruct/TbShopInfoMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shop.service.mapstruct; +package me.zhengjie.modules.shopInfo.shop.service.mapstruct; import me.zhengjie.base.BaseMapper; -import me.zhengjie.modules.shop.domain.TbShopInfo; -import me.zhengjie.modules.shop.service.dto.TbShopInfoDto; +import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; +import me.zhengjie.modules.shopInfo.shop.service.dto.TbShopInfoDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/domain/TbShopCurrency.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/domain/TbShopCurrency.java similarity index 97% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/domain/TbShopCurrency.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/domain/TbShopCurrency.java index 8055b24d..d0105a30 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/domain/TbShopCurrency.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/domain/TbShopCurrency.java @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.domain; +package me.zhengjie.modules.shopInfo.shopCurrency.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.math.BigDecimal; import java.io.Serializable; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/repository/TbShopCurrencyRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/repository/TbShopCurrencyRepository.java similarity index 89% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/repository/TbShopCurrencyRepository.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/repository/TbShopCurrencyRepository.java index f51e45ba..2038da45 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/repository/TbShopCurrencyRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/repository/TbShopCurrencyRepository.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.repository; +package me.zhengjie.modules.shopInfo.shopCurrency.repository; -import me.zhengjie.modules.shopCurrency.domain.TbShopCurrency; +import me.zhengjie.modules.shopInfo.shopCurrency.domain.TbShopCurrency; import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/rest/TbShopCurrencyController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/rest/TbShopCurrencyController.java similarity index 92% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/rest/TbShopCurrencyController.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/rest/TbShopCurrencyController.java index 05b03904..0e9c8f6b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/rest/TbShopCurrencyController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/rest/TbShopCurrencyController.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.rest; +package me.zhengjie.modules.shopInfo.shopCurrency.rest; import me.zhengjie.annotation.Log; -import me.zhengjie.modules.shopCurrency.domain.TbShopCurrency; -import me.zhengjie.modules.shopCurrency.service.TbShopCurrencyService; -import me.zhengjie.modules.shopCurrency.service.dto.TbShopCurrencyQueryCriteria; +import me.zhengjie.modules.shopInfo.shopCurrency.domain.TbShopCurrency; +import me.zhengjie.modules.shopInfo.shopCurrency.service.TbShopCurrencyService; +import me.zhengjie.modules.shopInfo.shopCurrency.service.dto.TbShopCurrencyQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/TbShopCurrencyService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/TbShopCurrencyService.java similarity index 87% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/TbShopCurrencyService.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/TbShopCurrencyService.java index 0d0932a3..69bcf6b9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/TbShopCurrencyService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/TbShopCurrencyService.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.service; +package me.zhengjie.modules.shopInfo.shopCurrency.service; -import me.zhengjie.modules.shopCurrency.domain.TbShopCurrency; -import me.zhengjie.modules.shopCurrency.service.dto.TbShopCurrencyDto; -import me.zhengjie.modules.shopCurrency.service.dto.TbShopCurrencyQueryCriteria; +import me.zhengjie.modules.shopInfo.shopCurrency.domain.TbShopCurrency; +import me.zhengjie.modules.shopInfo.shopCurrency.service.dto.TbShopCurrencyDto; +import me.zhengjie.modules.shopInfo.shopCurrency.service.dto.TbShopCurrencyQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/dto/TbShopCurrencyDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/dto/TbShopCurrencyDto.java similarity index 97% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/dto/TbShopCurrencyDto.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/dto/TbShopCurrencyDto.java index 26f66ec2..dd097c5b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/dto/TbShopCurrencyDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/dto/TbShopCurrencyDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.service.dto; +package me.zhengjie.modules.shopInfo.shopCurrency.service.dto; import lombok.Data; import java.math.BigDecimal; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/dto/TbShopCurrencyQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/dto/TbShopCurrencyQueryCriteria.java similarity index 92% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/dto/TbShopCurrencyQueryCriteria.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/dto/TbShopCurrencyQueryCriteria.java index 2b29e328..1ccfc901 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/dto/TbShopCurrencyQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/dto/TbShopCurrencyQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.service.dto; +package me.zhengjie.modules.shopInfo.shopCurrency.service.dto; import lombok.Data; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/impl/TbShopCurrencyServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/impl/TbShopCurrencyServiceImpl.java similarity index 90% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/impl/TbShopCurrencyServiceImpl.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/impl/TbShopCurrencyServiceImpl.java index 873e4274..cbc46712 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/impl/TbShopCurrencyServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/impl/TbShopCurrencyServiceImpl.java @@ -13,17 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.service.impl; +package me.zhengjie.modules.shopInfo.shopCurrency.service.impl; -import me.zhengjie.modules.shopCurrency.domain.TbShopCurrency; +import me.zhengjie.modules.shopInfo.shopCurrency.domain.TbShopCurrency; import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; -import me.zhengjie.modules.shopCurrency.repository.TbShopCurrencyRepository; -import me.zhengjie.modules.shopCurrency.service.TbShopCurrencyService; -import me.zhengjie.modules.shopCurrency.service.dto.TbShopCurrencyDto; -import me.zhengjie.modules.shopCurrency.service.dto.TbShopCurrencyQueryCriteria; -import me.zhengjie.modules.shopCurrency.service.mapstruct.TbShopCurrencyMapper; +import me.zhengjie.modules.shopInfo.shopCurrency.repository.TbShopCurrencyRepository; +import me.zhengjie.modules.shopInfo.shopCurrency.service.TbShopCurrencyService; +import me.zhengjie.modules.shopInfo.shopCurrency.service.dto.TbShopCurrencyDto; +import me.zhengjie.modules.shopInfo.shopCurrency.service.dto.TbShopCurrencyQueryCriteria; +import me.zhengjie.modules.shopInfo.shopCurrency.service.mapstruct.TbShopCurrencyMapper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.data.domain.Page; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/mapstruct/TbShopCurrencyMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/mapstruct/TbShopCurrencyMapper.java similarity index 80% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/mapstruct/TbShopCurrencyMapper.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/mapstruct/TbShopCurrencyMapper.java index f84e95cd..78dfc297 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopCurrency/service/mapstruct/TbShopCurrencyMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopCurrency/service/mapstruct/TbShopCurrencyMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopCurrency.service.mapstruct; +package me.zhengjie.modules.shopInfo.shopCurrency.service.mapstruct; import me.zhengjie.base.BaseMapper; -import me.zhengjie.modules.shopCurrency.domain.TbShopCurrency; -import me.zhengjie.modules.shopCurrency.service.dto.TbShopCurrencyDto; +import me.zhengjie.modules.shopInfo.shopCurrency.domain.TbShopCurrency; +import me.zhengjie.modules.shopInfo.shopCurrency.service.dto.TbShopCurrencyDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/domain/TbReceiptSales.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/domain/TbReceiptSales.java new file mode 100644 index 00000000..a01e39bf --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/domain/TbReceiptSales.java @@ -0,0 +1,120 @@ +/* +* 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.shopReceiptSales.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 java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-01-08 +**/ +@Entity +@Data +@Table(name="tb_receipt_sales") +public class TbReceiptSales implements Serializable { + + @Id + @Column(name = "`id`") + @ApiModelProperty(value = "shopId") + private Integer id; + + @Column(name = "`title`") + @ApiModelProperty(value = "标题") + private String title; + + @Column(name = "`logo`") + @ApiModelProperty(value = "是否显示公司Logo") + private String logo; + + @Column(name = "`show_contact_info`") + @ApiModelProperty(value = "打印联系电话等信息") + private Integer showContactInfo; + + @Column(name = "`show_member`") + @ApiModelProperty(value = "打印会员开关 0?1") + private Integer showMember; + + @Column(name = "`show_member_code`") + @ApiModelProperty(value = "打印会员编号开关") + private Integer showMemberCode; + + @Column(name = "`show_member_score`") + @ApiModelProperty(value = "打印会员积分") + private Integer showMemberScore; + + @Column(name = "`show_member_wallet`") + @ApiModelProperty(value = "打印会员余额开关 0?1") + private Integer showMemberWallet; + + @Column(name = "`footer_remark`") + @ApiModelProperty(value = "店铺Id") + private String footerRemark; + + @Column(name = "`show_cash_charge`") + @ApiModelProperty(value = "打印找零") + private Integer showCashCharge; + + @Column(name = "`show_serial_no`") + @ApiModelProperty(value = "流水号") + private Integer showSerialNo; + + @Column(name = "`big_serial_no`") + @ApiModelProperty(value = "用大号字打印流水号 在showSerialNo可用前提下") + private Integer bigSerialNo; + + @Column(name = "`header_text`") + @ApiModelProperty(value = "头部文字") + private String headerText; + + @Column(name = "`header_text_align`") + @ApiModelProperty(value = "文字 对齐方式") + private String headerTextAlign; + + @Column(name = "`footer_text`") + @ApiModelProperty(value = "尾部文字") + private String footerText; + + @Column(name = "`footer_text_align`") + @ApiModelProperty(value = "文字 对齐方式") + private String footerTextAlign; + + @Column(name = "`footer_image`") + @ApiModelProperty(value = "尾部图像") + private String footerImage; + + @Column(name = "`pre_print`") + @ApiModelProperty(value = "预打印,YES开启 NO不开启") + private String prePrint; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "createdAt") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + public void copy(TbReceiptSales source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/repository/TbReceiptSalesRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/repository/TbReceiptSalesRepository.java new file mode 100644 index 00000000..280b0025 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/repository/TbReceiptSalesRepository.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.shopReceiptSales.repository; + +import me.zhengjie.modules.shopInfo.shopReceiptSales.domain.TbReceiptSales; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-08 +**/ +public interface TbReceiptSalesRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/rest/TbReceiptSalesController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/rest/TbReceiptSalesController.java new file mode 100644 index 00000000..446a8908 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/rest/TbReceiptSalesController.java @@ -0,0 +1,96 @@ +/* +* 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.shopReceiptSales.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.shopInfo.shopReceiptSales.domain.TbReceiptSales; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.dto.TbReceiptSalesQueryCriteria; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.TbReceiptSalesService; +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-08 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "/shop/receiptSales管理") +@RequestMapping("/api/tbReceiptSales") +public class TbReceiptSalesController { + + private final TbReceiptSalesService tbReceiptSalesService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('tbReceiptSales:list')") + public void exportTbReceiptSales(HttpServletResponse response, TbReceiptSalesQueryCriteria criteria) throws IOException { + tbReceiptSalesService.download(tbReceiptSalesService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询/shop/receiptSales") + @ApiOperation("查询/shop/receiptSales") + @PreAuthorize("@el.check('tbReceiptSales:list')") + public ResponseEntity queryTbReceiptSales(TbReceiptSalesQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(tbReceiptSalesService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @GetMapping("/{shopId}") + @Log("查询/shop/receiptSales") + @ApiOperation("查询/shop/receiptSales") + @PreAuthorize("@el.check('tbReceiptSales:info')") + public Object queryTbReceiptSalesInfo(@PathVariable("shopId")Integer shopId){ + return tbReceiptSalesService.findById(shopId); + } + + + @PostMapping + @Log("新增/shop/receiptSales") + @ApiOperation("新增/shop/receiptSales") + @PreAuthorize("@el.check('tbReceiptSales:add')") + public ResponseEntity createTbReceiptSales(@Validated @RequestBody TbReceiptSales resources){ + return new ResponseEntity<>(tbReceiptSalesService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改/shop/receiptSales") + @ApiOperation("修改/shop/receiptSales") + @PreAuthorize("@el.check('tbReceiptSales:edit')") + public ResponseEntity updateTbReceiptSales(@Validated @RequestBody TbReceiptSales resources){ + tbReceiptSalesService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除/shop/receiptSales") + @ApiOperation("删除/shop/receiptSales") + @PreAuthorize("@el.check('tbReceiptSales:del')") + public ResponseEntity deleteTbReceiptSales(@RequestBody Integer[] ids) { + tbReceiptSalesService.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/shopReceiptSales/service/TbReceiptSalesService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/TbReceiptSalesService.java new file mode 100644 index 00000000..3f359517 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/TbReceiptSalesService.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.shopReceiptSales.service; + +import me.zhengjie.modules.shopInfo.shopReceiptSales.domain.TbReceiptSales; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.dto.TbReceiptSalesDto; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.dto.TbReceiptSalesQueryCriteria; +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-08 +**/ +public interface TbReceiptSalesService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(TbReceiptSalesQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(TbReceiptSalesQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbReceiptSalesDto + */ + TbReceiptSalesDto findById(Integer id); + + /** + * 创建 + * @param resources / + * @return TbReceiptSalesDto + */ + TbReceiptSalesDto create(TbReceiptSales resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbReceiptSales 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/shopReceiptSales/service/dto/TbReceiptSalesDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/dto/TbReceiptSalesDto.java new file mode 100644 index 00000000..ec4d1017 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/dto/TbReceiptSalesDto.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.shopReceiptSales.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-01-08 +**/ +@Data +public class TbReceiptSalesDto implements Serializable { + + /** shopId */ + private Integer id; + + /** 标题 */ + private String title; + + /** 是否显示公司Logo */ + private String logo; + + /** 打印联系电话等信息 */ + private Integer showContactInfo; + + /** 打印会员开关 0?1 */ + private Integer showMember; + + /** 打印会员编号开关 */ + private Integer showMemberCode; + + /** 打印会员积分 */ + private Integer showMemberScore; + + /** 打印会员余额开关 0?1 */ + private Integer showMemberWallet; + + /** 店铺Id */ + private String footerRemark; + + /** 打印找零 */ + private Integer showCashCharge; + + /** 流水号 */ + private Integer showSerialNo; + + /** 用大号字打印流水号 在showSerialNo可用前提下 */ + private Integer bigSerialNo; + + /** 头部文字 */ + private String headerText; + + /** 文字 对齐方式 */ + private String headerTextAlign; + + /** 尾部文字 */ + private String footerText; + + /** 文字 对齐方式 */ + private String footerTextAlign; + + /** 尾部图像 */ + private String footerImage; + + /** 预打印,YES开启 NO不开启 */ + private String prePrint; + + private Long createdAt; + + private Long updatedAt; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/dto/TbReceiptSalesQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/dto/TbReceiptSalesQueryCriteria.java new file mode 100644 index 00000000..49e8a39d --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/dto/TbReceiptSalesQueryCriteria.java @@ -0,0 +1,33 @@ +/* +* 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.shopReceiptSales.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-08 +**/ +@Data +public class TbReceiptSalesQueryCriteria{ + + /** 精确 */ + @Query + private Integer id; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/impl/TbReceiptSalesServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/impl/TbReceiptSalesServiceImpl.java new file mode 100644 index 00000000..042f0304 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/impl/TbReceiptSalesServiceImpl.java @@ -0,0 +1,122 @@ +/* +* 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.shopReceiptSales.service.impl; + +import me.zhengjie.modules.shopInfo.shopReceiptSales.domain.TbReceiptSales; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.mapstruct.TbReceiptSalesMapper; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.shopInfo.shopReceiptSales.repository.TbReceiptSalesRepository; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.TbReceiptSalesService; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.dto.TbReceiptSalesDto; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.dto.TbReceiptSalesQueryCriteria; +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-08 +**/ +@Service +@RequiredArgsConstructor +public class TbReceiptSalesServiceImpl implements TbReceiptSalesService { + + private final TbReceiptSalesRepository tbReceiptSalesRepository; + private final TbReceiptSalesMapper tbReceiptSalesMapper; + + @Override + public Map queryAll(TbReceiptSalesQueryCriteria criteria, Pageable pageable){ + Page page = tbReceiptSalesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbReceiptSalesMapper::toDto)); + } + + @Override + public List queryAll(TbReceiptSalesQueryCriteria criteria){ + return tbReceiptSalesMapper.toDto(tbReceiptSalesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public TbReceiptSalesDto findById(Integer id) { + TbReceiptSales tbReceiptSales = tbReceiptSalesRepository.findById(id).orElseGet(TbReceiptSales::new); + ValidationUtil.isNull(tbReceiptSales.getId(),"TbReceiptSales","id",id); + return tbReceiptSalesMapper.toDto(tbReceiptSales); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbReceiptSalesDto create(TbReceiptSales resources) { + return tbReceiptSalesMapper.toDto(tbReceiptSalesRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbReceiptSales resources) { + TbReceiptSales tbReceiptSales = tbReceiptSalesRepository.findById(resources.getId()).orElseGet(TbReceiptSales::new); + ValidationUtil.isNull( tbReceiptSales.getId(),"TbReceiptSales","id",resources.getId()); + tbReceiptSales.copy(resources); + tbReceiptSalesRepository.save(tbReceiptSales); + } + + @Override + public void deleteAll(Integer[] ids) { + for (Integer id : ids) { + tbReceiptSalesRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbReceiptSalesDto tbReceiptSales : all) { + Map map = new LinkedHashMap<>(); + map.put("标题", tbReceiptSales.getTitle()); + map.put("是否显示公司Logo", tbReceiptSales.getLogo()); + map.put("打印联系电话等信息", tbReceiptSales.getShowContactInfo()); + map.put("打印会员开关 0?1", tbReceiptSales.getShowMember()); + map.put("打印会员编号开关", tbReceiptSales.getShowMemberCode()); + map.put("打印会员积分", tbReceiptSales.getShowMemberScore()); + map.put("打印会员余额开关 0?1", tbReceiptSales.getShowMemberWallet()); + map.put("店铺Id", tbReceiptSales.getFooterRemark()); + map.put("打印找零", tbReceiptSales.getShowCashCharge()); + map.put("流水号", tbReceiptSales.getShowSerialNo()); + map.put("用大号字打印流水号 在showSerialNo可用前提下", tbReceiptSales.getBigSerialNo()); + map.put("头部文字", tbReceiptSales.getHeaderText()); + map.put("文字 对齐方式", tbReceiptSales.getHeaderTextAlign()); + map.put("尾部文字", tbReceiptSales.getFooterText()); + map.put("文字 对齐方式", tbReceiptSales.getFooterTextAlign()); + map.put("尾部图像", tbReceiptSales.getFooterImage()); + map.put("预打印,YES开启 NO不开启", tbReceiptSales.getPrePrint()); + map.put(" createdAt", tbReceiptSales.getCreatedAt()); + map.put(" updatedAt", tbReceiptSales.getUpdatedAt()); + 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/shopReceiptSales/service/mapstruct/TbReceiptSalesMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/mapstruct/TbReceiptSalesMapper.java new file mode 100644 index 00000000..c682e634 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopReceiptSales/service/mapstruct/TbReceiptSalesMapper.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.shopReceiptSales.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.shopInfo.shopReceiptSales.domain.TbReceiptSales; +import me.zhengjie.modules.shopInfo.shopReceiptSales.service.dto.TbReceiptSalesDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-08 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbReceiptSalesMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/domain/TbShopCashSpread.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/domain/TbShopCashSpread.java similarity index 95% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/domain/TbShopCashSpread.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/domain/TbShopCashSpread.java index 8365a653..7d072a60 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/domain/TbShopCashSpread.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/domain/TbShopCashSpread.java @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.domain; +package me.zhengjie.modules.shopInfo.shopSpread.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; /** diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/repository/TbShopCashSpreadRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/repository/TbShopCashSpreadRepository.java similarity index 67% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/repository/TbShopCashSpreadRepository.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/repository/TbShopCashSpreadRepository.java index e1cea35c..38a14197 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/repository/TbShopCashSpreadRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/repository/TbShopCashSpreadRepository.java @@ -13,14 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.repository; +package me.zhengjie.modules.shopInfo.shopSpread.repository; -import me.zhengjie.modules.shopSpread.domain.TbShopCashSpread; +import me.zhengjie.modules.shopInfo.shopSpread.domain.TbShopCashSpread; import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import javax.transaction.Transactional; + /** * @website https://eladmin.vip * @author lyf @@ -29,4 +32,12 @@ import org.springframework.data.jpa.repository.Query; public interface TbShopCashSpreadRepository extends JpaRepository, JpaSpecificationExecutor { @Query("select spread from TbShopCashSpread spread where spread.id = :shopId") TbShopCashSpread findByShopId(@Param("shopId")Integer shopId); + + @Modifying + @Transactional + @Query("update TbShopCashSpread spread set spread.screenConfig = :screenConfig, spread.updatedAt = :updatedTime where spread.id = :shopId") + Integer updateConfig(@Param("shopId")Integer shopId, @Param("screenConfig")String screenConfig, + @Param("updatedTime")Long updatedTime); + + } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/rest/TbShopCashSpreadController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/rest/TbShopCashSpreadController.java similarity index 87% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/rest/TbShopCashSpreadController.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/rest/TbShopCashSpreadController.java index fd6b65ed..b830cbf2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/rest/TbShopCashSpreadController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/rest/TbShopCashSpreadController.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.rest; +package me.zhengjie.modules.shopInfo.shopSpread.rest; import me.zhengjie.annotation.Log; -import me.zhengjie.modules.shopSpread.domain.TbShopCashSpread; -import me.zhengjie.modules.shopSpread.service.TbShopCashSpreadService; -import me.zhengjie.modules.shopSpread.service.dto.TbShopCashSpreadQueryCriteria; +import me.zhengjie.modules.shopInfo.shopSpread.domain.TbShopCashSpread; +import me.zhengjie.modules.shopInfo.shopSpread.service.TbShopCashSpreadService; +import me.zhengjie.modules.shopInfo.shopSpread.service.dto.TbShopCashSpreadQueryCriteria; import me.zhengjie.utils.StringUtils; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; @@ -29,7 +29,6 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; import java.io.IOException; -import java.util.HashMap; import javax.servlet.http.HttpServletResponse; /** @@ -82,8 +81,13 @@ public class TbShopCashSpreadController { @ApiOperation("修改/shop/spread") @PreAuthorize("@el.check('tbShopCashSpread:edit')") public ResponseEntity updateTbShopCashSpread(@Validated @RequestBody TbShopCashSpread resources){ - tbShopCashSpreadService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + Integer update = tbShopCashSpreadService.update(resources); + if (update>0){ + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + + } + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } @DeleteMapping diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/TbShopCashSpreadService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/TbShopCashSpreadService.java similarity index 85% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/TbShopCashSpreadService.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/TbShopCashSpreadService.java index bb1c6929..e5626d51 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/TbShopCashSpreadService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/TbShopCashSpreadService.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.service; +package me.zhengjie.modules.shopInfo.shopSpread.service; -import me.zhengjie.modules.shopSpread.domain.TbShopCashSpread; -import me.zhengjie.modules.shopSpread.service.dto.TbShopCashSpreadDto; -import me.zhengjie.modules.shopSpread.service.dto.TbShopCashSpreadQueryCriteria; +import me.zhengjie.modules.shopInfo.shopSpread.domain.TbShopCashSpread; +import me.zhengjie.modules.shopInfo.shopSpread.service.dto.TbShopCashSpreadDto; +import me.zhengjie.modules.shopInfo.shopSpread.service.dto.TbShopCashSpreadQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; @@ -66,7 +66,7 @@ public interface TbShopCashSpreadService { * 编辑 * @param resources / */ - void update(TbShopCashSpread resources); + Integer update(TbShopCashSpread resources); /** * 多选删除 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/TbShopCashVo/TbShopCashVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/TbShopCashVo/TbShopCashVo.java similarity index 62% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/TbShopCashVo/TbShopCashVo.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/TbShopCashVo/TbShopCashVo.java index 828fca74..daf61eb0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/TbShopCashVo/TbShopCashVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/TbShopCashVo/TbShopCashVo.java @@ -1,4 +1,4 @@ -package me.zhengjie.modules.shopSpread.service.TbShopCashVo; +package me.zhengjie.modules.shopInfo.shopSpread.service.TbShopCashVo; import java.util.Map; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/dto/TbShopCashSpreadDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/dto/TbShopCashSpreadDto.java similarity index 94% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/dto/TbShopCashSpreadDto.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/dto/TbShopCashSpreadDto.java index 198ad622..4ff524df 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/dto/TbShopCashSpreadDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/dto/TbShopCashSpreadDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.service.dto; +package me.zhengjie.modules.shopInfo.shopSpread.service.dto; import lombok.Data; import java.io.Serializable; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/dto/TbShopCashSpreadQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/dto/TbShopCashSpreadQueryCriteria.java similarity index 93% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/dto/TbShopCashSpreadQueryCriteria.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/dto/TbShopCashSpreadQueryCriteria.java index 15baa7da..699fbe42 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/dto/TbShopCashSpreadQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/dto/TbShopCashSpreadQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.service.dto; +package me.zhengjie.modules.shopInfo.shopSpread.service.dto; import lombok.Data; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/impl/TbShopCashSpreadServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/impl/TbShopCashSpreadServiceImpl.java similarity index 81% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/impl/TbShopCashSpreadServiceImpl.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/impl/TbShopCashSpreadServiceImpl.java index d21cffb9..60d00921 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/impl/TbShopCashSpreadServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/impl/TbShopCashSpreadServiceImpl.java @@ -13,24 +13,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.service.impl; +package me.zhengjie.modules.shopInfo.shopSpread.service.impl; -import me.zhengjie.modules.shopSpread.domain.TbShopCashSpread; +import me.zhengjie.modules.shopInfo.shopSpread.domain.TbShopCashSpread; +import me.zhengjie.modules.shopInfo.shopSpread.service.TbShopCashSpreadService; +import me.zhengjie.modules.shopInfo.shopSpread.service.dto.TbShopCashSpreadDto; +import me.zhengjie.modules.shopInfo.shopSpread.service.mapstruct.TbShopCashSpreadMapper; import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; -import me.zhengjie.modules.shopSpread.repository.TbShopCashSpreadRepository; -import me.zhengjie.modules.shopSpread.service.TbShopCashSpreadService; -import me.zhengjie.modules.shopSpread.service.dto.TbShopCashSpreadDto; -import me.zhengjie.modules.shopSpread.service.dto.TbShopCashSpreadQueryCriteria; -import me.zhengjie.modules.shopSpread.service.mapstruct.TbShopCashSpreadMapper; +import me.zhengjie.modules.shopInfo.shopSpread.repository.TbShopCashSpreadRepository; +import me.zhengjie.modules.shopInfo.shopSpread.service.dto.TbShopCashSpreadQueryCriteria; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import cn.hutool.core.util.IdUtil; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import me.zhengjie.utils.PageUtil; import me.zhengjie.utils.QueryHelp; + +import java.time.Instant; import java.util.List; import java.util.Map; import java.io.IOException; @@ -84,11 +85,8 @@ public class TbShopCashSpreadServiceImpl implements TbShopCashSpreadService { @Override @Transactional(rollbackFor = Exception.class) - public void update(TbShopCashSpread resources) { -// TbShopCashSpread tbShopCashSpread = tbShopCashSpreadRepository.findById(resources.getId()).orElseGet(TbShopCashSpread::new); -// ValidationUtil.isNull( tbShopCashSpread.getId(),"TbShopCashSpread","id",resources.getId()); -// tbShopCashSpread.copy(resources); -// tbShopCashSpreadRepository.save(tbShopCashSpread); + public Integer update(TbShopCashSpread resources) { + return tbShopCashSpreadRepository.updateConfig(resources.getId(), resources.getScreenConfig().trim(), Instant.now().toEpochMilli()); } @Override diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/mapstruct/TbShopCashSpreadMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/mapstruct/TbShopCashSpreadMapper.java similarity index 81% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/mapstruct/TbShopCashSpreadMapper.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/mapstruct/TbShopCashSpreadMapper.java index 5b891d68..d24db0f7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopSpread/service/mapstruct/TbShopCashSpreadMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopSpread/service/mapstruct/TbShopCashSpreadMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopSpread.service.mapstruct; +package me.zhengjie.modules.shopInfo.shopSpread.service.mapstruct; import me.zhengjie.base.BaseMapper; -import me.zhengjie.modules.shopSpread.domain.TbShopCashSpread; -import me.zhengjie.modules.shopSpread.service.dto.TbShopCashSpreadDto; +import me.zhengjie.modules.shopInfo.shopSpread.domain.TbShopCashSpread; +import me.zhengjie.modules.shopInfo.shopSpread.service.dto.TbShopCashSpreadDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/domain/TbShopUnit.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/domain/TbShopUnit.java similarity index 97% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/domain/TbShopUnit.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/domain/TbShopUnit.java index 051e88ed..55ec5eb0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/domain/TbShopUnit.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/domain/TbShopUnit.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.domain; +package me.zhengjie.modules.shopInfo.shopUnit.domain; import lombok.Data; import cn.hutool.core.bean.BeanUtil; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/repository/TbShopUnitRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/repository/TbShopUnitRepository.java similarity index 73% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/repository/TbShopUnitRepository.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/repository/TbShopUnitRepository.java index 9a2b7490..a93060b2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/repository/TbShopUnitRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/repository/TbShopUnitRepository.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.repository; +package me.zhengjie.modules.shopInfo.shopUnit.repository; -import me.zhengjie.modules.shopUnit.domain.TbShopUnit; +import me.zhengjie.modules.shopInfo.shopUnit.domain.TbShopUnit; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; @@ -31,4 +31,10 @@ import java.util.List; public interface TbShopUnitRepository extends JpaRepository, JpaSpecificationExecutor { @Query("SELECT unit FROM TbShopUnit unit WHERE unit.id IN :ids") List searchUnit(@Param("ids")List ids); + + @Query("SELECT unit FROM TbShopUnit unit WHERE unit.id = :ids") + TbShopUnit searchUnit(@Param("ids")Integer ids); + + @Query("SELECT unit from TbShopUnit unit where unit.name = :name and unit.shopId = :shopId") + TbShopUnit findName(@Param("name")String name,@Param("shopId")String shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/rest/TbShopUnitController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/rest/TbShopUnitController.java similarity index 88% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/rest/TbShopUnitController.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/rest/TbShopUnitController.java index 38120fe1..807911fa 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/rest/TbShopUnitController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/rest/TbShopUnitController.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.rest; +package me.zhengjie.modules.shopInfo.shopUnit.rest; import me.zhengjie.annotation.Log; -import me.zhengjie.modules.shopUnit.domain.TbShopUnit; -import me.zhengjie.modules.shopUnit.service.TbShopUnitService; -import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitQueryCriteria; +import me.zhengjie.modules.shopInfo.shopUnit.domain.TbShopUnit; +import me.zhengjie.modules.shopInfo.shopUnit.service.TbShopUnitService; +import me.zhengjie.modules.shopInfo.shopUnit.service.dto.TbShopUnitQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -63,7 +63,7 @@ public class TbShopUnitController { @Log("新增/shop/unit") @ApiOperation("新增/shop/unit") @PreAuthorize("@el.check('tbShopUnit:add')") - public ResponseEntity createTbShopUnit(@Validated @RequestBody TbShopUnit resources){ + public ResponseEntity createTbShopUnit(@Validated @RequestBody TbShopUnit resources)throws Exception{ return new ResponseEntity<>(tbShopUnitService.create(resources),HttpStatus.CREATED); } @@ -71,7 +71,7 @@ public class TbShopUnitController { @Log("修改/shop/unit") @ApiOperation("修改/shop/unit") @PreAuthorize("@el.check('tbShopUnit:edit')") - public ResponseEntity updateTbShopUnit(@Validated @RequestBody TbShopUnit resources){ + public ResponseEntity updateTbShopUnit(@Validated @RequestBody TbShopUnit resources)throws Exception{ tbShopUnitService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/TbShopUnitService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/TbShopUnitService.java similarity index 82% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/TbShopUnitService.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/TbShopUnitService.java index db60b6b6..a306b732 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/TbShopUnitService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/TbShopUnitService.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.service; +package me.zhengjie.modules.shopInfo.shopUnit.service; -import me.zhengjie.modules.shopUnit.domain.TbShopUnit; -import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitDto; -import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitQueryCriteria; +import me.zhengjie.modules.shopInfo.shopUnit.domain.TbShopUnit; +import me.zhengjie.modules.shopInfo.shopUnit.service.dto.TbShopUnitDto; +import me.zhengjie.modules.shopInfo.shopUnit.service.dto.TbShopUnitQueryCriteria; import org.springframework.data.domain.Pageable; import java.util.Map; import java.util.List; @@ -59,13 +59,13 @@ public interface TbShopUnitService { * @param resources / * @return TbShopUnitDto */ - TbShopUnitDto create(TbShopUnit resources); + TbShopUnitDto create(TbShopUnit resources)throws Exception; /** * 编辑 * @param resources / */ - void update(TbShopUnit resources); + void update(TbShopUnit resources)throws Exception; /** * 多选删除 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/dto/TbShopUnitDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/dto/TbShopUnitDto.java similarity index 95% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/dto/TbShopUnitDto.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/dto/TbShopUnitDto.java index 0600d9f8..2970e3df 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/dto/TbShopUnitDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/dto/TbShopUnitDto.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.service.dto; +package me.zhengjie.modules.shopInfo.shopUnit.service.dto; import lombok.Data; import java.io.Serializable; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/dto/TbShopUnitQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/dto/TbShopUnitQueryCriteria.java similarity index 93% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/dto/TbShopUnitQueryCriteria.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/dto/TbShopUnitQueryCriteria.java index fb851d47..44698d46 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/dto/TbShopUnitQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/dto/TbShopUnitQueryCriteria.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.service.dto; +package me.zhengjie.modules.shopInfo.shopUnit.service.dto; import lombok.Data; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/impl/TbShopUnitServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/impl/TbShopUnitServiceImpl.java similarity index 73% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/impl/TbShopUnitServiceImpl.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/impl/TbShopUnitServiceImpl.java index 13c78457..ace6f837 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/impl/TbShopUnitServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/impl/TbShopUnitServiceImpl.java @@ -13,23 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.service.impl; +package me.zhengjie.modules.shopInfo.shopUnit.service.impl; -import me.zhengjie.modules.shopUnit.domain.TbShopUnit; +import me.zhengjie.exception.BadRequestException; +import me.zhengjie.exception.NewBadRequestException; +import me.zhengjie.modules.shopInfo.shopUnit.domain.TbShopUnit; import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.FileUtil; import lombok.RequiredArgsConstructor; -import me.zhengjie.modules.shopUnit.repository.TbShopUnitRepository; -import me.zhengjie.modules.shopUnit.service.TbShopUnitService; -import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitDto; -import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitQueryCriteria; -import me.zhengjie.modules.shopUnit.service.mapstruct.TbShopUnitMapper; +import me.zhengjie.modules.shopInfo.shopUnit.repository.TbShopUnitRepository; +import me.zhengjie.modules.shopInfo.shopUnit.service.TbShopUnitService; +import me.zhengjie.modules.shopInfo.shopUnit.service.dto.TbShopUnitDto; +import me.zhengjie.modules.shopInfo.shopUnit.service.dto.TbShopUnitQueryCriteria; +import me.zhengjie.modules.shopInfo.shopUnit.service.mapstruct.TbShopUnitMapper; +import org.springframework.http.HttpStatus; 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.time.Instant; import java.util.List; import java.util.Map; import java.io.IOException; @@ -71,14 +76,29 @@ public class TbShopUnitServiceImpl implements TbShopUnitService { @Override @Transactional(rollbackFor = Exception.class) - public TbShopUnitDto create(TbShopUnit resources) { + public TbShopUnitDto create(TbShopUnit resources)throws Exception{ + + TbShopUnit name = tbShopUnitRepository.findName(resources.getName(), resources.getShopId()); + if (name != null){ + throw new NewBadRequestException(HttpStatus.OK,"单位名称重复"); + } + resources.setDecimalsDigits(0); + resources.setUnitType("number"); + resources.setIsSystem(0); + resources.setStatus(1); + resources.setCreatedAt(Instant.now().toEpochMilli()); + resources.setUpdatedAt(Instant.now().toEpochMilli()); return tbShopUnitMapper.toDto(tbShopUnitRepository.save(resources)); } @Override @Transactional(rollbackFor = Exception.class) - public void update(TbShopUnit resources) { + public void update(TbShopUnit resources) throws Exception{ TbShopUnit tbShopUnit = tbShopUnitRepository.findById(resources.getId()).orElseGet(TbShopUnit::new); + TbShopUnit name = tbShopUnitRepository.findName(resources.getName(), resources.getShopId()); + if (name != null){ + throw new NewBadRequestException(HttpStatus.OK,"单位名称重复"); + } ValidationUtil.isNull( tbShopUnit.getId(),"TbShopUnit","id",resources.getId()); tbShopUnit.copy(resources); tbShopUnitRepository.save(tbShopUnit); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/mapstruct/TbShopUnitMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/mapstruct/TbShopUnitMapper.java similarity index 82% rename from eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/mapstruct/TbShopUnitMapper.java rename to eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/mapstruct/TbShopUnitMapper.java index afa3d3dd..c62a1668 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopUnit/service/mapstruct/TbShopUnitMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopUnit/service/mapstruct/TbShopUnitMapper.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package me.zhengjie.modules.shopUnit.service.mapstruct; +package me.zhengjie.modules.shopInfo.shopUnit.service.mapstruct; import me.zhengjie.base.BaseMapper; -import me.zhengjie.modules.shopUnit.domain.TbShopUnit; -import me.zhengjie.modules.shopUnit.service.dto.TbShopUnitDto; +import me.zhengjie.modules.shopInfo.shopUnit.domain.TbShopUnit; +import me.zhengjie.modules.shopInfo.shopUnit.service.dto.TbShopUnitDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index 55e71f09..f59bbee6 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -24,6 +24,7 @@ spring: properties: hibernate: dialect: org.hibernate.dialect.MySQL5InnoDBDialect + show_sql: true redis: #数据库索引