|
@@ -1,9 +1,14 @@
|
|
|
package com.fuint.common.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fuint.common.dto.AccountInfo;
|
|
|
import com.fuint.common.enums.StatusEnum;
|
|
|
+import com.fuint.common.param.PageParam;
|
|
|
import com.fuint.common.service.TableInfoService;
|
|
|
import com.fuint.common.util.AuthUserUtil;
|
|
|
import com.fuint.common.util.I18nUtil;
|
|
@@ -11,21 +16,26 @@ import com.fuint.framework.annoation.OperationServiceLog;
|
|
|
import com.fuint.framework.exception.BusinessCheckException;
|
|
|
import com.fuint.framework.pagination.PaginationRequest;
|
|
|
import com.fuint.framework.pagination.PaginationResponse;
|
|
|
+import com.fuint.framework.web.PageResult;
|
|
|
+import com.fuint.repository.bean.TableInfoBean;
|
|
|
+import com.fuint.repository.mapper.MtStoreMapper;
|
|
|
import com.fuint.repository.mapper.MtTableCategoryMapper;
|
|
|
import com.fuint.repository.mapper.MtTableInfoMapper;
|
|
|
+import com.fuint.repository.model.MtStore;
|
|
|
import com.fuint.repository.model.MtTableCategory;
|
|
|
import com.fuint.repository.model.MtTableInfo;
|
|
|
-import com.github.pagehelper.Page;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 餐桌信息服务接口
|
|
@@ -43,33 +53,15 @@ public class TableInfoServiceImpl extends ServiceImpl<MtTableInfoMapper, MtTable
|
|
|
|
|
|
private MtTableCategoryMapper tableCategoryMapper;
|
|
|
|
|
|
+ private MtStoreMapper storeMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 分页查询数据列表
|
|
|
*
|
|
|
* @param paginationRequest
|
|
|
* @return
|
|
|
*/
|
|
|
- @Override
|
|
|
- public PaginationResponse<MtTableInfo> queryTableInfoListByPagination(PaginationRequest paginationRequest) {
|
|
|
- //构建分页条件
|
|
|
- Page<MtTableInfo> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
|
|
|
- //构建查询条件
|
|
|
- LambdaQueryWrapper<MtTableInfo> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
|
|
- //排除已经删除数据
|
|
|
- lambdaQueryWrapper.ne(MtTableInfo::getDeleteFlag, 1);
|
|
|
|
|
|
- lambdaQueryWrapper.orderByAsc(MtTableInfo::getId);
|
|
|
- List<MtTableInfo> dataList = mtTableInfoMapper.selectList(lambdaQueryWrapper);
|
|
|
-
|
|
|
- PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
|
|
|
- PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
|
|
|
- PaginationResponse<MtTableInfo> paginationResponse = new PaginationResponse(pageImpl, MtTableInfo.class);
|
|
|
- paginationResponse.setTotalPages(pageHelper.getPages());
|
|
|
- paginationResponse.setTotalElements(pageHelper.getTotal());
|
|
|
- paginationResponse.setContent(dataList);
|
|
|
-
|
|
|
- return paginationResponse;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 添加餐桌信息
|
|
@@ -195,7 +187,6 @@ public class TableInfoServiceImpl extends ServiceImpl<MtTableInfoMapper, MtTable
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean saveTable(MtTableInfo entity) throws BusinessCheckException {
|
|
|
// 校验桌号唯一性
|
|
|
-
|
|
|
Long storeId = AuthUserUtil.get().getStoreId();
|
|
|
if (storeId==null || storeId<0){
|
|
|
throw new BusinessCheckException("平台号无权限修改");
|
|
@@ -227,4 +218,30 @@ public class TableInfoServiceImpl extends ServiceImpl<MtTableInfoMapper, MtTable
|
|
|
return updateById(entity);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public PageResult<TableInfoBean> selectTableList(String tableName, PageParam param) throws BusinessCheckException {
|
|
|
+ AccountInfo accountInfo = AuthUserUtil.get();
|
|
|
+ //检查是否登入
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new BusinessCheckException(I18nUtil.getMessage("notAuthenticated"));
|
|
|
+ }
|
|
|
+ //分页查询
|
|
|
+ IPage<MtTableInfo> mtTableInfoIPage = this.baseMapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), new LambdaQueryWrapper<MtTableInfo>()
|
|
|
+ .eq((accountInfo.getStoreId()!=null && accountInfo.getStoreId()>0),MtTableInfo::getStoreId,accountInfo.getStoreId())
|
|
|
+ .likeRight(StringUtils.isNotEmpty(tableName), MtTableInfo::getTableNumber, tableName));
|
|
|
+ //补全字段
|
|
|
+ List<TableInfoBean> beanList = mtTableInfoIPage.getRecords().stream().map(mtTableInfo -> {
|
|
|
+ TableInfoBean tableInfoBean = new TableInfoBean();
|
|
|
+ Long storeId = mtTableInfo.getStoreId();
|
|
|
+ //mtTableInfo copy到TableInfoBean
|
|
|
+ BeanUtils.copyProperties(mtTableInfo, tableInfoBean);
|
|
|
+ //获取店铺信息
|
|
|
+ MtStore mtStore = storeMapper.selectById(storeId);
|
|
|
+ tableInfoBean.setStoreName(mtStore.getName());
|
|
|
+ return tableInfoBean;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //返回
|
|
|
+ return PageResult.<TableInfoBean>builder().data(beanList).total(Math.toIntExact(mtTableInfoIPage.getTotal())).build();
|
|
|
+ }
|
|
|
+
|
|
|
}
|