台桌区域相关

This commit is contained in:
liuyingfang
2024-02-01 13:53:25 +08:00
parent 69721b6040
commit 80f9cc7ea6
13 changed files with 536 additions and 13 deletions

View File

@@ -62,10 +62,11 @@ public class TbProductStockOperateController {
return new ResponseEntity<>(tbProductStockOperateService.findById(id),HttpStatus.OK);
}
// @GetMapping("/nullify/{id}")
// public ResponseEntity<Object> nullify(@PathVariable Integer id){
// return new ResponseEntity<>(tbProductStockOperateService.,HttpStatus.OK);
// }
@GetMapping("/nullify/{id}")
public ResponseEntity<Object> nullify(@PathVariable Integer id){
tbProductStockOperateService.nullify(id);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@PostMapping

View File

@@ -51,7 +51,7 @@ public interface TbProductStockOperateService {
/**
* 作废
*/
void nullify();
void nullify(Integer id);
/**
* 根据ID查询

View File

@@ -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

View File

@@ -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));
}
}

View File

@@ -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<TbShopArea, Integer>, JpaSpecificationExecutor<TbShopArea> {
}

View File

@@ -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<Object> 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<Object> 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<Object> 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<Object> deleteTbShopArea(@RequestBody Integer[] ids) {
tbShopAreaService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -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<String,Object>
*/
Map<String,Object> queryAll(TbShopAreaQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TbShopAreaDto>
*/
List<TbShopAreaDto> 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<TbShopAreaDto> all, HttpServletResponse response) throws IOException;
}

View File

@@ -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;
}

View File

@@ -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{
}

View File

@@ -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<String,Object> queryAll(TbShopAreaQueryCriteria criteria, Pageable pageable){
Page<TbShopArea> page = tbShopAreaRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(tbShopAreaMapper::toDto));
}
@Override
public List<TbShopAreaDto> 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<TbShopAreaDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (TbShopAreaDto tbShopArea : all) {
Map<String,Object> 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);
}
}

View File

@@ -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<TbShopAreaDto, TbShopArea> {
}

View File

@@ -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计时类型")

View File

@@ -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<String,Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable){
if (Objects.equals(criteria.getAreaId(), "0")){
criteria.setAreaId(null);
}
Page<TbShopTable> 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));
}