From 80f9cc7ea63318cde12c0cf5e2a849a81d2a9e89 Mon Sep 17 00:00:00 2001 From: liuyingfang <1357764963@qq.com> Date: Thu, 1 Feb 2024 13:53:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B0=E6=A1=8C=E5=8C=BA=E5=9F=9F=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rest/TbProductStockOperateController.java | 9 +- .../service/TbProductStockOperateService.java | 2 +- .../TbProductStockOperateServiceImpl.java | 12 +- .../shopInfo/shopArea/domain/TbShopArea.java | 80 ++++++++++++ .../repository/TbShopAreaRepository.java | 28 +++++ .../shopArea/rest/TbShopAreaController.java | 87 +++++++++++++ .../shopArea/service/TbShopAreaService.java | 83 +++++++++++++ .../shopArea/service/dto/TbShopAreaDto.java | 54 ++++++++ .../service/dto/TbShopAreaQueryCriteria.java | 29 +++++ .../service/impl/TbShopAreaServiceImpl.java | 117 ++++++++++++++++++ .../service/mapstruct/TbShopAreaMapper.java | 32 +++++ .../shopInfo/table/domain/TbShopTable.java | 4 +- .../service/impl/TbShopTableServiceImpl.java | 12 +- 13 files changed, 536 insertions(+), 13 deletions(-) create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/domain/TbShopArea.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/repository/TbShopAreaRepository.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/TbShopAreaService.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/dto/TbShopAreaDto.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/dto/TbShopAreaQueryCriteria.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/impl/TbShopAreaServiceImpl.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/mapstruct/TbShopAreaMapper.java diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/rest/TbProductStockOperateController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/rest/TbProductStockOperateController.java index 1472c2b4..bbcb3087 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/rest/TbProductStockOperateController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/rest/TbProductStockOperateController.java @@ -62,10 +62,11 @@ public class TbProductStockOperateController { return new ResponseEntity<>(tbProductStockOperateService.findById(id),HttpStatus.OK); } -// @GetMapping("/nullify/{id}") -// public ResponseEntity nullify(@PathVariable Integer id){ -// return new ResponseEntity<>(tbProductStockOperateService.,HttpStatus.OK); -// } + @GetMapping("/nullify/{id}") + public ResponseEntity nullify(@PathVariable Integer id){ + tbProductStockOperateService.nullify(id); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } @PostMapping diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/TbProductStockOperateService.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/TbProductStockOperateService.java index 6e8a16e7..76a012a1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/TbProductStockOperateService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/TbProductStockOperateService.java @@ -51,7 +51,7 @@ public interface TbProductStockOperateService { /** * 作废 */ - void nullify(); + void nullify(Integer id); /** * 根据ID查询 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/impl/TbProductStockOperateServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/impl/TbProductStockOperateServiceImpl.java index a2c7f901..d5885975 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/impl/TbProductStockOperateServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productStockOperate/service/impl/TbProductStockOperateServiceImpl.java @@ -106,8 +106,16 @@ public class TbProductStockOperateServiceImpl implements TbProductStockOperateSe } @Override - public void nullify() { - + public void nullify(Integer id) { +// TbProductStockOperate tbProductStockOperate = tbProductStockOperateRepository.findById(id).orElseGet(TbProductStockOperate::new); +// tbProductStockOperate.setStatus("nullify"); +// //作废之后恢复数量 +// tbProductStockOperate.get +// +// +// ValidationUtil.isNull( tbProductStockOperate.getId(),"TbProductStockOperate","id",id); +// tbProductStockOperate.copy(resources); +// tbProductStockOperateRepository.save(tbProductStockOperate); } @Override diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/domain/TbShopArea.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/domain/TbShopArea.java new file mode 100644 index 00000000..976705d4 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/domain/TbShopArea.java @@ -0,0 +1,80 @@ +/* +* 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.shopArea.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-31 +**/ +@Entity +@Data +@Table(name="tb_shop_area") +public class TbShopArea implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "id") + private Integer id; + + @Column(name = "`shop_id`",nullable = false) + @NotNull + @ApiModelProperty(value = "店铺Id") + private Integer shopId; + + @Column(name = "`sort`") + @ApiModelProperty(value = "排序") + private Integer sort; + + @Column(name = "`name`",nullable = false) + @NotBlank + @ApiModelProperty(value = "区域名称") + private String name; + + @Column(name = "`price`") + @ApiModelProperty(value = "区域价格") + private Integer price; + + @Column(name = "`view`") + @ApiModelProperty(value = "图片") + private String view; + + @Column(name = "`capacity_range`") + @ApiModelProperty(value = "建议人数 5-10") + private String capacityRange; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "createdAt") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + public void copy(TbShopArea source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/repository/TbShopAreaRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/repository/TbShopAreaRepository.java new file mode 100644 index 00000000..dc8eb7b8 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/repository/TbShopAreaRepository.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.shopArea.repository; + +import me.zhengjie.modules.shopInfo.shopArea.domain.TbShopArea; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-31 +**/ +public interface TbShopAreaRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.java new file mode 100644 index 00000000..e77c7917 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/rest/TbShopAreaController.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.shopArea.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.shopInfo.shopArea.domain.TbShopArea; +import me.zhengjie.modules.shopInfo.shopArea.service.TbShopAreaService; +import me.zhengjie.modules.shopInfo.shopArea.service.dto.TbShopAreaQueryCriteria; +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-31 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "/shop/area管理") +@RequestMapping("/api/tbShopArea") +public class TbShopAreaController { + + private final TbShopAreaService tbShopAreaService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('tbShopArea:list')") + public void exportTbShopArea(HttpServletResponse response, TbShopAreaQueryCriteria criteria) throws IOException { + tbShopAreaService.download(tbShopAreaService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询/shop/area") + @ApiOperation("查询/shop/area") + @PreAuthorize("@el.check('tbShopArea:list')") + public ResponseEntity queryTbShopArea(TbShopAreaQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(tbShopAreaService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增/shop/area") + @ApiOperation("新增/shop/area") + @PreAuthorize("@el.check('tbShopArea:add')") + public ResponseEntity createTbShopArea(@Validated @RequestBody TbShopArea resources){ + return new ResponseEntity<>(tbShopAreaService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改/shop/area") + @ApiOperation("修改/shop/area") + @PreAuthorize("@el.check('tbShopArea:edit')") + public ResponseEntity updateTbShopArea(@Validated @RequestBody TbShopArea resources){ + tbShopAreaService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除/shop/area") + @ApiOperation("删除/shop/area") + @PreAuthorize("@el.check('tbShopArea:del')") + public ResponseEntity deleteTbShopArea(@RequestBody Integer[] ids) { + tbShopAreaService.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/shopArea/service/TbShopAreaService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/TbShopAreaService.java new file mode 100644 index 00000000..85aa2dad --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/TbShopAreaService.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.shopArea.service; + +import me.zhengjie.modules.shopInfo.shopArea.domain.TbShopArea; +import me.zhengjie.modules.shopInfo.shopArea.service.dto.TbShopAreaDto; +import me.zhengjie.modules.shopInfo.shopArea.service.dto.TbShopAreaQueryCriteria; +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-31 +**/ +public interface TbShopAreaService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(TbShopAreaQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(TbShopAreaQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbShopAreaDto + */ + TbShopAreaDto findById(Integer id); + + /** + * 创建 + * @param resources / + * @return TbShopAreaDto + */ + TbShopAreaDto create(TbShopArea resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbShopArea 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/shopArea/service/dto/TbShopAreaDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/dto/TbShopAreaDto.java new file mode 100644 index 00000000..db0abe1c --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/dto/TbShopAreaDto.java @@ -0,0 +1,54 @@ +/* +* 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.shopArea.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-01-31 +**/ +@Data +public class TbShopAreaDto implements Serializable { + + /** id */ + private Integer id; + + /** 店铺Id */ + private Integer shopId; + + /** 排序 */ + private Integer sort; + + /** 区域名称 */ + private String name; + + /** 区域价格 */ + private Integer price; + + /** 图片 */ + private String view; + + /** 建议人数 5-10 */ + private String capacityRange; + + private Long createdAt; + + private Long updatedAt; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/dto/TbShopAreaQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/dto/TbShopAreaQueryCriteria.java new file mode 100644 index 00000000..10acbaa2 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/dto/TbShopAreaQueryCriteria.java @@ -0,0 +1,29 @@ +/* +* 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.shopArea.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-31 +**/ +@Data +public class TbShopAreaQueryCriteria{ +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/impl/TbShopAreaServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/impl/TbShopAreaServiceImpl.java new file mode 100644 index 00000000..cb7993e0 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/impl/TbShopAreaServiceImpl.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.shopInfo.shopArea.service.impl; + +import me.zhengjie.modules.shopInfo.shopArea.domain.TbShopArea; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.shopInfo.shopArea.repository.TbShopAreaRepository; +import me.zhengjie.modules.shopInfo.shopArea.service.TbShopAreaService; +import me.zhengjie.modules.shopInfo.shopArea.service.dto.TbShopAreaDto; +import me.zhengjie.modules.shopInfo.shopArea.service.dto.TbShopAreaQueryCriteria; +import me.zhengjie.modules.shopInfo.shopArea.service.mapstruct.TbShopAreaMapper; +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; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://eladmin.vip +* @description 服务实现 +* @author lyf +* @date 2024-01-31 +**/ +@Service +@RequiredArgsConstructor +public class TbShopAreaServiceImpl implements TbShopAreaService { + + private final TbShopAreaRepository tbShopAreaRepository; + private final TbShopAreaMapper tbShopAreaMapper; + + @Override + public Map queryAll(TbShopAreaQueryCriteria criteria, Pageable pageable){ + Page page = tbShopAreaRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbShopAreaMapper::toDto)); + } + + @Override + public List queryAll(TbShopAreaQueryCriteria criteria){ + return tbShopAreaMapper.toDto(tbShopAreaRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public TbShopAreaDto findById(Integer id) { + TbShopArea tbShopArea = tbShopAreaRepository.findById(id).orElseGet(TbShopArea::new); + ValidationUtil.isNull(tbShopArea.getId(),"TbShopArea","id",id); + return tbShopAreaMapper.toDto(tbShopArea); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbShopAreaDto create(TbShopArea resources) { + resources.setCreatedAt(Instant.now().toEpochMilli()); + resources.setUpdatedAt(Instant.now().toEpochMilli()); + resources.setSort(0); + return tbShopAreaMapper.toDto(tbShopAreaRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbShopArea resources) { + TbShopArea tbShopArea = tbShopAreaRepository.findById(resources.getId()).orElseGet(TbShopArea::new); + tbShopArea.setUpdatedAt(Instant.now().toEpochMilli()); + ValidationUtil.isNull( tbShopArea.getId(),"TbShopArea","id",resources.getId()); + tbShopArea.copy(resources); + tbShopAreaRepository.save(tbShopArea); + } + + @Override + public void deleteAll(Integer[] ids) { + for (Integer id : ids) { + tbShopAreaRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbShopAreaDto tbShopArea : all) { + Map map = new LinkedHashMap<>(); + map.put("店铺Id", tbShopArea.getShopId()); + map.put("排序", tbShopArea.getSort()); + map.put("区域名称", tbShopArea.getName()); + map.put("区域价格", tbShopArea.getPrice()); + map.put("图片", tbShopArea.getView()); + map.put("建议人数 5-10", tbShopArea.getCapacityRange()); + map.put(" createdAt", tbShopArea.getCreatedAt()); + map.put(" updatedAt", tbShopArea.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/shopArea/service/mapstruct/TbShopAreaMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/mapstruct/TbShopAreaMapper.java new file mode 100644 index 00000000..62b93cd0 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopArea/service/mapstruct/TbShopAreaMapper.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.shopArea.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.shopInfo.shopArea.domain.TbShopArea; +import me.zhengjie.modules.shopInfo.shopArea.service.dto.TbShopAreaDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-01-31 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbShopAreaMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java index 91ea90ef..08ca9327 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java @@ -69,12 +69,12 @@ public class TbShopTable implements Serializable { @Column(name = "`predate_amount`") @ApiModelProperty(value = "网络预定台桌支付金额") - private BigDecimal predateAmount; + private BigDecimal predateAmount = new BigDecimal("0.00"); @Column(name = "`status`",nullable = false) @NotBlank @ApiModelProperty(value = "subscribe预定,closed--关台, opening 开台中,cleaning 台桌清理中") - private String status; + private String status = "opening"; @Column(name = "`type`") @ApiModelProperty(value = "台桌计算价格类型,0-低消类型,amount 2计时类型") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java index 91e50b10..b903775c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java @@ -30,12 +30,11 @@ 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.time.Instant; +import java.util.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.LinkedHashMap; /** * @website https://eladmin.vip @@ -52,6 +51,9 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public Map queryAll(TbShopTableQueryCriteria criteria, Pageable pageable){ + if (Objects.equals(criteria.getAreaId(), "0")){ + criteria.setAreaId(null); + } Page page = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); return PageUtil.toPage(page.map(tbShopTableMapper::toDto)); } @@ -72,6 +74,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override @Transactional(rollbackFor = Exception.class) public TbShopTableDto create(TbShopTable resources) { + resources.setCreatedAt(Instant.now().toEpochMilli()); + resources.setUpdatedAt(Instant.now().toEpochMilli()); return tbShopTableMapper.toDto(tbShopTableRepository.save(resources)); }