Explorar o código

增加餐厅列表接口

houweiyu %!s(int64=4) %!d(string=hai) anos
pai
achega
9aec36f590

+ 8 - 0
dinner-application/pom.xml

@@ -12,6 +12,14 @@
     <artifactId>dinner-application</artifactId>
     <packaging>war</packaging>
 
+    <dependencies>
+        <dependency>
+            <groupId>com.4dage</groupId>
+            <artifactId>dinner-core</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
     <build>
         <finalName>fdage-dinner-reservation</finalName>
         <resources>

+ 1 - 1
dinner-application/src/main/resources/application-dev.properties

@@ -1,5 +1,5 @@
 
-server.port=8285
+server.port=8385
 
 spring.datasource.url=jdbc:mysql://120.25.146.52:3306/dinner-reservation?serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
 spring.datasource.username=root

+ 1 - 1
dinner-application/src/main/resources/application-prod.properties

@@ -1,5 +1,5 @@
 
-server.port=8285
+server.port=8385
 
 spring.datasource.url=jdbc:mysql://120.25.146.52:3306/dinner-reservation?serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
 spring.datasource.username=root

+ 1 - 1
dinner-application/src/main/resources/application-test.properties

@@ -1,5 +1,5 @@
 
-server.port=8285
+server.port=8385
 
 spring.datasource.url=jdbc:mysql://120.25.146.52:3306/dinner-reservation?serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
 spring.datasource.username=root

+ 1 - 1
dinner-application/src/main/resources/application-uat.properties

@@ -1,5 +1,5 @@
 
-server.port=8285
+server.port=8385
 
 spring.datasource.url=jdbc:mysql://120.25.146.52:3306/dinner-reservation?serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
 spring.datasource.username=root

+ 1 - 0
dinner-core/pom.xml

@@ -10,6 +10,7 @@
 
     <modelVersion>4.0.0</modelVersion>
     <artifactId>dinner-core</artifactId>
+    <version>1.0-SNAPSHOT</version>
 
     <packaging>jar</packaging>
 

+ 111 - 0
dinner-core/src/main/java/com/fdage/base/dto/CanteenAppRspDto.java

@@ -0,0 +1,111 @@
+package com.fdage.base.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2021/2/18 15:54
+ * 4
+ */
+@Data
+@ApiModel(value="CanteenAppRspDto小程序返回对象", description="CanteenAppRspDto小程序返回对象")
+public class CanteenAppRspDto implements Serializable {
+    private static final long serialVersionUID=1L;
+
+    @ApiModelProperty(value = "主键id")
+    private String id;
+
+    @ApiModelProperty(value = "餐厅名称")
+    private String name;
+
+    @ApiModelProperty(value = "评分")
+    private Double score;
+
+    @ApiModelProperty(value = "简介")
+    private String desc;
+
+    @ApiModelProperty(value = "排序")
+    private Integer sort;
+
+    @ApiModelProperty(value = "是否是新店:0->否;1->是")
+    private Integer isNew;
+
+    @ApiModelProperty(value = "是否展示: 0->不展示;1->展示")
+    private Integer isShow;
+
+    @ApiModelProperty(value = "类型")
+    private Integer type;
+
+    @ApiModelProperty(value = "场景码")
+    private String sceneNum;
+
+    @ApiModelProperty(value = "vr链接")
+    private String vrLink;
+
+    @ApiModelProperty(value = "微信小程序分享二维码链接")
+    private String wxShareQrCodeLink;
+
+    @ApiModelProperty(value = "餐厅详细地址")
+    private String address;
+
+    @ApiModelProperty(value = "照片集")
+    private String picList;
+
+    @ApiModelProperty(value = "封面照片链接")
+    private String coverPicLink;
+
+    @ApiModelProperty(value = "是否删除: 0->不删除; 1->删除")
+    private Integer isDelete;
+
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private LocalDateTime createTime;
+
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "最后更新时间")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty(value = "创建者ID")
+    private String createrId;
+
+    @ApiModelProperty(value = "创建者所在部门ID")
+    private String createrDeptId;
+
+    @ApiModelProperty(value = "前台接待员ID")
+    private String receptionistId;
+
+    @ApiModelProperty(value = "接待员名称")
+    private String receptionistName;
+
+    @ApiModelProperty(value = "接待员电话")
+    private String receptionistPhone;
+
+    @ApiModelProperty(value = "接待员头衔")
+    private String receptionistTitle;
+
+    @ApiModelProperty(value = "接待员头像")
+    private String receptionistAvatar;
+
+    @ApiModelProperty(value = "经度")
+    private Double longitude;
+
+    @ApiModelProperty(value = "纬度")
+    private Double latitude;
+
+    @ApiModelProperty(value = "距离-单位是米")
+    private Double distance;
+}

+ 16 - 0
dinner-core/src/main/java/com/fdage/base/dto/ContextTokenBean.java

@@ -0,0 +1,16 @@
+package com.fdage.base.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2021/2/18 16:26
+ * 4
+ */
+@Data
+public class ContextTokenBean implements Serializable {
+
+
+}

+ 20 - 2
dinner-core/src/main/java/com/fdage/base/entity/TmCanteen.java

@@ -1,7 +1,13 @@
 package com.fdage.base.entity;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.io.Serializable;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -28,13 +34,13 @@ public class TmCanteen implements Serializable {
     private String id;
 
     @ApiModelProperty(value = "餐厅名称")
-    private String name;
+    private String canteenName;
 
     @ApiModelProperty(value = "评分")
     private Double score;
 
     @ApiModelProperty(value = "简介")
-    private String desc;
+    private String simpleDesc;
 
     @ApiModelProperty(value = "排序")
     private Integer sort;
@@ -69,9 +75,15 @@ public class TmCanteen implements Serializable {
     @ApiModelProperty(value = "是否删除: 0->不删除; 1->删除")
     private Integer isDelete;
 
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建时间")
     private LocalDateTime createTime;
 
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "最后更新时间")
     private LocalDateTime updateTime;
 
@@ -96,5 +108,11 @@ public class TmCanteen implements Serializable {
     @ApiModelProperty(value = "接待员头像")
     private String receptionistAvatar;
 
+    @ApiModelProperty(value = "经度")
+    private Double longitude;
+
+    @ApiModelProperty(value = "纬度")
+    private Double latitude;
+
 
 }

+ 14 - 2
dinner-core/src/main/java/com/fdage/base/entity/TmDesk.java

@@ -2,6 +2,11 @@ package com.fdage.base.entity;
 
 import java.time.LocalDateTime;
 import java.io.Serializable;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -28,13 +33,13 @@ public class TmDesk implements Serializable {
     private String id;
 
     @ApiModelProperty(value = "桌子名称")
-    private String name;
+    private String deskName;
 
     @ApiModelProperty(value = "所属餐厅的id")
     private String canteenId;
 
     @ApiModelProperty(value = "桌子简介")
-    private String desc;
+    private String simpleDesc;
 
     @ApiModelProperty(value = "类型: 1->包厢;2->大厅")
     private Integer type;
@@ -42,9 +47,16 @@ public class TmDesk implements Serializable {
     @ApiModelProperty(value = "最新预定时间")
     private LocalDateTime latestOrderTime;
 
+
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建时间")
     private LocalDateTime createTime;
 
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "最新更新时间")
     private LocalDateTime updateTime;
 

+ 13 - 0
dinner-core/src/main/java/com/fdage/base/entity/TmOrder.java

@@ -3,6 +3,11 @@ package com.fdage.base.entity;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.io.Serializable;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -37,9 +42,15 @@ public class TmOrder implements Serializable {
     @ApiModelProperty(value = "订单状态: 0->待支付;1->预定成功;2->取消成功;3->取消退款成功;-1->预定失败")
     private Integer status;
 
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建时间")
     private LocalDateTime createTime;
 
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "最新更新时间")
     private LocalDateTime updateTime;
 
@@ -64,6 +75,8 @@ public class TmOrder implements Serializable {
     @ApiModelProperty(value = "付款者名称")
     private String payName;
 
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "支付时间")
     private LocalDateTime payTime;
 

+ 12 - 1
dinner-core/src/main/java/com/fdage/base/entity/TmUser.java

@@ -2,6 +2,11 @@ package com.fdage.base.entity;
 
 import java.time.LocalDateTime;
 import java.io.Serializable;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -28,7 +33,7 @@ public class TmUser implements Serializable {
     private String id;
 
     @ApiModelProperty(value = "用户名称")
-    private String name;
+    private String userName;
 
     @ApiModelProperty(value = "用户头像")
     private String avatar;
@@ -48,9 +53,15 @@ public class TmUser implements Serializable {
     @ApiModelProperty(value = "手机号")
     private String phone;
 
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建时间")
     private LocalDateTime createTime;
 
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "最新更新时间")
     private LocalDateTime updateTime;
 

+ 34 - 0
dinner-core/src/main/java/com/fdage/base/enums/IdPreEnum.java

@@ -0,0 +1,34 @@
+package com.fdage.base.enums;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2021/2/18 15:17
+ * 4
+ */
+public enum IdPreEnum {
+
+    CANTEEN_PRE("CAT00001" , "餐厅ID前缀"),
+    DESK_PRE("DSK00001" , "餐桌ID前缀"),
+    ORDER_PRE("ORD00001" , "订单ID前缀"),
+    USER_PRE("USER0001" , "用户ID前缀"),
+    ;
+
+    private String pre;
+
+    private String desc;
+
+    ;
+
+    IdPreEnum(String pre, String desc) {
+        this.pre = pre;
+        this.desc = desc;
+    }
+
+    public String getPre() {
+        return pre;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 77 - 0
dinner-core/src/main/java/com/fdage/base/service/impl/TmCanteenServiceImpl.java

@@ -1,11 +1,27 @@
 package com.fdage.base.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdage.base.dto.CanteenAppRspDto;
 import com.fdage.base.entity.TmCanteen;
 import com.fdage.base.dao.TmCanteenDao;
+import com.fdage.base.enums.IdPreEnum;
 import com.fdage.base.service.ITmCanteenService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdage.base.utils.LocationUtils;
+import fdage.back.sdk.base.uuid.SnowFlakeUUidUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 /**
  * <p>
  * 餐厅信息表 服务实现类
@@ -17,4 +33,65 @@ import org.springframework.stereotype.Service;
 @Service
 public class TmCanteenServiceImpl extends ServiceImpl<TmCanteenDao, TmCanteen> implements ITmCanteenService {
 
+    public int addNew(TmCanteen tmCanteen){
+        if(null == tmCanteen){
+            return -1;
+        }
+        tmCanteen.setId(SnowFlakeUUidUtils.generaUUid(null , null , IdPreEnum.CANTEEN_PRE.getPre()));
+        tmCanteen.setCreateTime(LocalDateTime.now());
+        tmCanteen.setUpdateTime(LocalDateTime.now());
+        tmCanteen.setIsDelete(0);
+         return getBaseMapper().insert(tmCanteen);
+    }
+
+    public IPage<TmCanteen> getCanteenList(long pageNum , long pageSize , String name){
+        IPage<TmCanteen> page = new Page<TmCanteen>(pageNum , pageSize);
+        LambdaQueryWrapper<TmCanteen> lambdaQueryWrapper  = new LambdaQueryWrapper<>();
+        if(StringUtils.isNotBlank(name)){
+            lambdaQueryWrapper.like(TmCanteen::getCanteenName , name);
+        }
+        lambdaQueryWrapper.eq(TmCanteen::getIsDelete , 0);
+        return getBaseMapper().selectPage(page , lambdaQueryWrapper);
+    }
+
+    public IPage<CanteenAppRspDto> getCanteenListWithLocation(long pageNum , long pageSize ,
+                                                       String name , Double longitude ,
+                                                       Double latitude){
+        IPage<TmCanteen> page = new Page<TmCanteen>(pageNum , pageSize);
+        LambdaQueryWrapper<TmCanteen> lambdaQueryWrapper  = new LambdaQueryWrapper<>();
+        if(StringUtils.isNotBlank(name)){
+            lambdaQueryWrapper.like(TmCanteen::getCanteenName , name);
+        }
+        lambdaQueryWrapper.eq(TmCanteen::getIsDelete , 0);
+        IPage<TmCanteen> tmpResultPage =  getBaseMapper().selectPage(page , lambdaQueryWrapper);
+        if(null == tmpResultPage){
+            return new Page<CanteenAppRspDto>(pageNum , pageSize);
+        }
+        IPage<CanteenAppRspDto> totalResultPage = new Page<>();
+        BeanUtils.copyProperties(tmpResultPage , totalResultPage);
+        if(!CollectionUtils.isEmpty(tmpResultPage.getRecords())){
+            List<CanteenAppRspDto> list = new ArrayList<>();
+            tmpResultPage.getRecords().stream().forEach(rec ->
+              {
+                  CanteenAppRspDto dto = new CanteenAppRspDto();
+                  BeanUtils.copyProperties(rec , dto);
+                  //根据上送的经纬度,计算当前店铺和用户的距离
+                  if(null != latitude && null != longitude
+                    && null != rec.getLatitude() && null != rec.getLongitude()){
+                      double distance = LocationUtils.getDistance(latitude , longitude , rec.getLatitude() , rec.getLongitude());
+                      dto.setDistance(distance);
+                  }else{
+                      dto.setDistance(0.0);
+                  }
+                  list.add(dto);
+              });
+              if(!CollectionUtils.isEmpty(list)){
+                  totalResultPage.setRecords(list);
+              }
+        }
+        return totalResultPage;
+    }
+
+
+
 }

+ 262 - 0
dinner-core/src/main/java/com/fdage/base/utils/DataUtils.java

@@ -0,0 +1,262 @@
+package com.fdage.base.utils;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.common.BitMatrix;
+import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
+import fdage.back.sdk.utils.FileUtils;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.*;
+
+import static com.google.zxing.client.j2se.MatrixToImageConfig.BLACK;
+import static com.google.zxing.client.j2se.MatrixToImageConfig.WHITE;
+
+/**
+ * @author abnerhou
+ * @date 2020/4/23 17:35
+ * @desciption
+ */
+@Component
+@Log4j2
+public class DataUtils {
+
+    public static BigDecimal getBigDecimalObj(Object data) {
+
+        if (null == data) {
+            return null;
+        } else if (data instanceof String) {
+            String dataStr = (String) data;
+            if (!StringUtils.isEmpty(dataStr.trim())) {
+                return new BigDecimal(dataStr.trim());
+            }
+        } else if (data instanceof Long) {
+            Long dataLong = (Long) data;
+            return BigDecimal.valueOf(dataLong);
+        } else if (data instanceof Integer) {
+            Integer dataInt = (Integer) data;
+            return BigDecimal.valueOf(dataInt);
+
+        } else if (data instanceof Double) {
+            Double dataDouble = (Double) data;
+            return BigDecimal.valueOf(dataDouble);
+        }
+
+        return null;
+
+    }
+
+    public static Integer getInteger(Object object) {
+        if (null == object) {
+            return new Integer(0);
+        }
+        if (object instanceof String) {
+            String ojStr = (String) object;
+            if (StringUtils.isEmpty(ojStr)) {
+                //TODO:在斟酌这里的处理方式
+                return new Integer(0);
+            } else {
+                return new Integer(Integer.parseInt(ojStr.trim()));
+            }
+        } else if (object instanceof Integer) {
+            return (Integer) object;
+        } else if (object instanceof Long) {
+            return (Integer) object;
+        } else if (object instanceof Double) {
+            return (Integer) object;
+        } else {
+            return new Integer(0);
+        }
+    }
+
+    public static Integer getIntegerWithDefault(Object object, boolean withDefault) {
+        if (null == object) {
+
+            return withDefault ? new Integer(0) : null;
+        }
+        if (object instanceof String) {
+            String ojStr = (String) object;
+            if (StringUtils.isEmpty(ojStr)) {
+
+                return withDefault ? new Integer(0) : null;
+            } else {
+                return new Integer(Integer.parseInt(ojStr.trim()));
+            }
+        } else if (object instanceof Integer) {
+            return (Integer) object;
+        } else if (object instanceof Long) {
+            return (Integer) object;
+        } else if (object instanceof Double) {
+            return (Integer) object;
+        } else {
+            return withDefault ? new Integer(0) : null;
+        }
+    }
+
+    public static Map<String, Object> assembleResult(long totalNum, long totalPageNum, long currPageNum, Object list) {
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("totalNum", totalNum);
+        resultMap.put("totalPageNum", totalPageNum);
+        resultMap.put("curPage", currPageNum);
+        resultMap.put("list", list);
+        return resultMap;
+    }
+
+    public static <T> void assembleTimeQueryWrapper(Map<String, Object> constantQuery, String dynamicQuery,
+                                                    QueryWrapper<T> queryWrapper, String idQuery,
+                                                    String secondQuery, String thirdQuery) {
+        assembleConstantQuery(queryWrapper, constantQuery);
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(dynamicQuery)) {
+            queryWrapper.and(wrapper -> wrapper
+                    .or().like(org.apache.commons.lang3.StringUtils.isNotBlank(secondQuery), secondQuery, dynamicQuery)
+                    .or().like(org.apache.commons.lang3.StringUtils.isNotBlank(thirdQuery), thirdQuery, dynamicQuery)
+                    .or().like(dynamicQuery.length() <= 32 && org.apache.commons.lang3.StringUtils.isNotBlank(idQuery), idQuery, dynamicQuery));
+        }
+
+    }
+
+    public static <T> void assembleConstantQuery(QueryWrapper<T> queryWrapper, Map<String, Object> constantQuery) {
+        if (null != queryWrapper && !CollectionUtils.isEmpty(constantQuery)) {
+            for (Map.Entry<String, Object> entry : constantQuery.entrySet()) {
+                queryWrapper.eq(entry.getKey(), entry.getValue());
+            }
+        }
+    }
+
+    /**
+     *  根据map的key进行字典升序排序
+     * @param map
+     * @return map
+     */
+    public static Map<String, Object> sortMapByKey(Map<String, Object>map) {
+        Map<String, Object> treemap = new TreeMap<String, Object>(map);
+        List<Map.Entry<String, Object>> list = new ArrayList<Map.Entry<String, Object>>(treemap.entrySet());
+        Collections.sort(list, new Comparator<Map.Entry<String, Object>>() {
+            @Override
+            public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
+                return org.apache.commons.lang3.StringUtils.compare(o1.getKey() , o2.getKey());
+            }
+        });
+        return treemap;
+    }
+
+    /**
+     *
+     * 生成MD5 32位小写字符的密码串
+     * */
+    public static String md5Encryption(String jsonStr) {
+        String re_md5 = new String();
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            md.update(jsonStr.getBytes());
+            byte b[] = md.digest();
+            StringBuffer buf = new StringBuffer("");
+            int i;
+            for (int offset = 0; offset < b.length; offset++) {
+                i = b[offset];
+                if (i < 0){
+                    i += 256;
+                }
+                if (i < 16){
+                    buf.append("0");
+                }
+                buf.append(Integer.toHexString(i));
+            }
+            re_md5 = buf.toString();
+        } catch (NoSuchAlgorithmException e) {
+            log.info("生成MD5密文出错了:{}" , e);
+            e.printStackTrace();
+        }
+        return re_md5.toLowerCase();
+    }
+
+    /**
+    *
+     * 根据上传的照片生成二维码
+    * **/
+    public static boolean createQRCode(String url, String outPath, File logoPathFile) throws Exception {
+        // 生成二维码
+
+        int width = 300; // 二维码图片宽度 300
+        int height = 300; // 二维码图片高度300
+
+        String format = "jpg";// 二维码的图片格式 gif
+
+        Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
+        // 指定纠错等级,纠错级别(L 7%、M 15%、Q 25%、H 30%)
+        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
+        // 内容所使用字符集编码
+        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
+//      hints.put(EncodeHintType.MAX_SIZE, 350);//设置图片的最大值
+//      hints.put(EncodeHintType.MIN_SIZE, 100);//设置图片的最小值
+        hints.put(EncodeHintType.MARGIN, 1);//设置二维码边的空度,非负数
+
+        BitMatrix bitMatrix = new MultiFormatWriter().encode(url,
+                //编码类型,目前zxing支持:Aztec 2D,CODABAR 1D format,Code 39 1D,Code 93 1D ,Code 128 1D,
+                //Data Matrix 2D , EAN-8 1D,EAN-13 1D,ITF (Interleaved Two of Five) 1D,
+                //MaxiCode 2D barcode,PDF417,QR Code 2D,RSS 14,RSS EXPANDED,UPC-A 1D,UPC-E 1D,UPC/EAN extension,UPC_EAN_EXTENSION
+                BarcodeFormat.QR_CODE,
+                width, //条形码的宽度
+                height, //条形码的高度
+                hints);//生成条形码时的一些配置,此项可选
+
+        //File outputFile = new File("d:" + File.separator + "new-1.gif");//指定输出路径
+        File outputFile = new File(outPath);//指定输出路径
+        FileUtils.deleteFile(outPath);
+        return writeToFile(bitMatrix, format, outputFile, logoPathFile);
+    }
+
+    public static BufferedImage toBufferedImage(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        for (int x = 0; x < width; x++) {
+            for (int y = 0; y < height; y++) {
+                image.setRGB(x, y, (matrix.get(x, y) ? BLACK : WHITE));
+//              image.setRGB(x, y,  (matrix.get(x, y) ? Color.YELLOW.getRGB() : Color.CYAN.getRGB()));
+            }
+        }
+        return image;
+    }
+
+    public static boolean writeToFile(BitMatrix matrix, String format, File file, File logoPathFile) throws IOException {
+        BufferedImage image = toBufferedImage(matrix);
+        //设置logo图标
+        LogoConfig logoConfig = new LogoConfig();
+        image = logoConfig.LogoMatrix(image, logoPathFile);
+
+        if(null == image){
+            return false;
+        }
+        File parFile = new File(file.getParent() + File.separator);
+        if (!parFile.exists()){
+            parFile.mkdirs();
+        }
+
+        if (!ImageIO.write(image, format, file)) {
+            //throw new IOException("Could not write an image of format " + format + " to " + file);
+            log.info("Could not write an image of format " + format + " to " + file);
+            return false;
+        } else {
+            log.info("二维码生成成功!");
+            return true;
+        }
+    }
+
+   /* public static void main(String[] args) throws Exception{
+        createQRCode("https://www.4dkankan.com/spc.html?m=t-pnj0IJX", "C:/Users/4dage/Desktop/logo-file/t-pnj0IJX1.png", null);
+    }*/
+
+}

+ 47 - 0
dinner-core/src/main/java/com/fdage/base/utils/LocationUtils.java

@@ -0,0 +1,47 @@
+package com.fdage.base.utils;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2021/2/18 15:59
+ * 4
+ */
+public class LocationUtils {
+
+    private static double EARTH_RADIUS = 6378.137;
+
+    private static double rad(double d) {
+        return d * Math.PI / 180.0;
+    }
+
+    /**
+     * 通过经纬度获取距离(单位:米)
+     *
+     * @param lat1
+     * @param lng1
+     * @param lat2
+     * @param lng2
+     * @return 距离
+     */
+    public static double getDistance(double lat1, double lng1, double lat2,
+                                     double lng2) {
+        double radLat1 = rad(lat1);
+        double radLat2 = rad(lat2);
+        double a = radLat1 - radLat2;
+        double b = rad(lng1) - rad(lng2);
+        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
+                + Math.cos(radLat1) * Math.cos(radLat2)
+                * Math.pow(Math.sin(b / 2), 2)));
+        s = s * EARTH_RADIUS;
+        s = Math.round(s * 10000d) / 10000d;
+        s = s * 1000;
+        return s;
+    }
+
+  /*  public static void main(String[] args) {
+        double distance = getDistance(34.2675560000, 108.9534750000,
+                34.2464320000, 108.9534750000);
+        System.out.println("距离" + distance / 1000 + "公里");
+    }*/
+
+
+}

+ 74 - 0
dinner-core/src/main/java/com/fdage/base/utils/LogoConfig.java

@@ -0,0 +1,74 @@
+package com.fdage.base.utils;
+
+import lombok.extern.log4j.Log4j2;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+@Log4j2
+public class LogoConfig {
+	/**
+     * 设置 logo  
+     * @param matrixImage 源二维码图片 
+     * @return 返回带有logo的二维码图片 
+     * @throws IOException 
+     * @author Administrator sangwenhao 
+     */  
+     public BufferedImage LogoMatrix(BufferedImage matrixImage, File localFile) throws IOException{
+         /** 
+          * 读取二维码图片,并构建绘图对象 
+          */  
+         Graphics2D g2 = matrixImage.createGraphics();  
+           
+         int matrixWidth = matrixImage.getWidth();  
+         int matrixHeigh = matrixImage.getHeight();
+         /**
+          * 读取Logo图片
+          */
+         if(localFile == null){
+             URL url = this.getClass().getResource("logo.jpg");
+             if(null != url){
+                 localFile = new File(url.getPath());
+             }
+         }
+         if(!localFile.exists()){
+             log.info("{}文件不存在" , localFile.getAbsolutePath());
+             return null;
+         }
+         BufferedImage logo = null;
+         try {
+            logo = ImageIO.read(localFile);
+         }catch (Exception e){
+             log.info("读取二维码源文件出现异常:{}" , e);
+             return null;
+         }
+         if(null == logo){
+             log.info("获取二维码源码照片失败");
+             return null;
+         }
+         //开始绘制图片  
+         g2.drawImage(logo,matrixWidth/5*2,matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5, null);//绘制       
+         BasicStroke stroke = new BasicStroke(5,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);   
+         g2.setStroke(stroke);// 设置笔画对象  
+         //指定弧度的圆角矩形  
+         RoundRectangle2D.Float round = new RoundRectangle2D.Float(matrixWidth/5*2, matrixHeigh/5*2, matrixWidth/5, matrixHeigh/5,20,20);  
+         g2.setColor(Color.white);  
+         g2.draw(round);// 绘制圆弧矩形  
+           
+         //设置logo 有一道灰色边框  
+         BasicStroke stroke2 = new BasicStroke(1,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);   
+         g2.setStroke(stroke2);// 设置笔画对象  
+         RoundRectangle2D.Float round2 = new RoundRectangle2D.Float(matrixWidth/5*2+2, matrixHeigh/5*2+2, matrixWidth/5-4, matrixHeigh/5-4,20,20);  
+         g2.setColor(new Color(128,128,128));  
+         g2.draw(round2);// 绘制圆弧矩形  
+           
+         g2.dispose();  
+         matrixImage.flush() ;  
+         return matrixImage ;  
+     }  
+}

+ 45 - 0
dinner-core/src/main/java/com/fdage/controller/BaseController.java

@@ -0,0 +1,45 @@
+package com.fdage.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fdage.base.dto.ContextTokenBean;
+import fdage.back.sdk.base.enums.ResultCodeEnum;
+import fdage.back.sdk.base.exception.CommonBaseException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2021/1/25 10:19
+ * 4
+ */
+public class BaseController {
+
+    public static final String TOKEN = "token";
+
+    @Autowired
+    protected HttpServletRequest request;
+
+    @Autowired
+    protected RedisTemplate redisTemplate;
+
+    protected String getToken(){
+        return request.getHeader(TOKEN);
+    }
+
+    protected ContextTokenBean getContextUserInfo(){
+        String token = request.getHeader(TOKEN);
+        JSONObject tokenJsonObj = (JSONObject) redisTemplate.opsForValue().get(token);
+        if(null == tokenJsonObj){
+            throw new CommonBaseException(3004 , "token失效");
+        }
+        ContextTokenBean contextTokenBean = JSON.parseObject(tokenJsonObj.toJSONString() , ContextTokenBean.class);
+        if(null == contextTokenBean){
+            throw new CommonBaseException(ResultCodeEnum.D101 , "解析token失败");
+        }
+        return contextTokenBean;
+    }
+
+}

+ 80 - 0
dinner-core/src/main/java/com/fdage/controller/app/AppCanteenController.java

@@ -0,0 +1,80 @@
+package com.fdage.controller.app;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.fdage.base.dto.CanteenAppRspDto;
+import com.fdage.base.entity.TmCanteen;
+import com.fdage.base.service.impl.TmCanteenServiceImpl;
+import com.fdage.base.utils.DataUtils;
+import fdage.back.sdk.base.entity.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2021/2/18 15:12
+ * 4
+ */
+@Api(tags = "餐厅相关接口")
+@RestController
+@RequestMapping("/app/canteen")
+@Log4j2
+public class AppCanteenController {
+
+    @Autowired
+    private TmCanteenServiceImpl tmCanteenService;
+
+    @GetMapping("/queryOrSearchList")
+    @ApiOperation(value = "根据条件拉取所有餐厅")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "longitude", value = "经度", paramType = "query", required = true, dataType = "Double"),
+            @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "query", required = true, dataType = "Double"),
+            @ApiImplicitParam(name = "name", value = "餐厅名称", paramType = "query", required = false, dataType = "String"),
+            @ApiImplicitParam(name = "pageNum", value = "当前页码", paramType = "query", required = true, dataType = "Long"),
+            @ApiImplicitParam(name = "pageSize", value = "每页大小", paramType = "query", required = true, dataType = "Long")
+    })
+    public Result<Object> getCanteenList(String name,
+                                           @RequestParam(name = "longitude") Double longitude ,
+                                           @RequestParam(name = "latitude") Double latitude ,
+                                           @RequestParam(name = "pageNum")Long pageNum,
+                                           @RequestParam(name = "pageSize")Long pageSize){
+       if(null == longitude || null == latitude){
+           return Result.failure("缺失经纬度");
+       }
+       if(null == pageNum || null == pageSize){
+            return Result.failure("缺失分页参数");
+       }
+        IPage<CanteenAppRspDto> resultPage = tmCanteenService.getCanteenListWithLocation(pageNum , pageSize
+                , name , longitude , latitude);
+
+        return  Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
+                resultPage.getCurrent(), resultPage.getRecords()));
+    }
+
+    @GetMapping("/getOne")
+    @ApiOperation(value = "获取餐厅详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "canteenId", value = "餐厅ID", paramType = "query", required = true, dataType = "String"),
+    })
+    public Result<TmCanteen> getCanteen(@RequestParam(name = "canteenId") String canteenId){
+
+        if(StringUtils.isBlank(canteenId)){
+            return Result.failure("缺失餐厅Id");
+        }
+        TmCanteen tmCanteen = tmCanteenService.getById(canteenId);
+        if(null == tmCanteen){
+            return Result.failure("餐厅不存在");
+        }
+        return Result.success(tmCanteen);
+    }
+
+
+}

+ 14 - 0
dinner-core/src/test/java/CodeAutoGenerator.java

@@ -0,0 +1,14 @@
+import fdage.back.sdk.base.mybatis.MysqlAutoGenerator;
+
+/**
+ * 2 * @Author: Abner
+ * 3 * @Date: 2021/2/9 10:46
+ * 4
+ */
+public class CodeAutoGenerator {
+
+    public static void main(String[] args) {
+        MysqlAutoGenerator.doAutoGenerator("base" , "com.fdage"
+                ,"abner" , "");
+    }
+}