Browse Source

fix:地址管理

wrj 1 year ago
parent
commit
743e6ba7c2

+ 97 - 0
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/TAddressController.java

@@ -0,0 +1,97 @@
+package com.ylx.web.controller.massage;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ylx.common.core.controller.BaseController;
+import com.ylx.common.core.domain.R;
+import com.ylx.massage.domain.TAddress;
+import com.ylx.massage.service.TAddressService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 轮播图(TAddress)表控制层
+ *
+ * @author makejava
+ * @since 2024-04-11 17:18:52
+ */
+@RestController
+@Api(tags = {"地址管理"})
+@RequestMapping("tAddress")
+public class TAddressController extends BaseController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private TAddressService tAddressService;
+
+    /**
+     * 分页查询所有数据
+     *
+     * @param page     分页对象
+     * @param tAddress 查询实体
+     * @return 所有数据
+     */
+    @GetMapping
+    public R selectAll(Page<TAddress> page, TAddress tAddress) {
+        return R.ok(this.tAddressService.page(page, new QueryWrapper<>(tAddress)));
+    }
+
+    /**
+     * 通过主键查询单条数据
+     *
+     * @param id 主键
+     * @return 单条数据
+     */
+    @ApiOperation("根据OpenId查询用户地址")
+    @GetMapping("getByOpenId")
+    public R selectOne(@RequestParam String openId) {
+
+        LambdaQueryWrapper<TAddress> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        objectLambdaQueryWrapper.eq(TAddress::getOpenid, openId);
+        return R.ok(this.tAddressService.list(objectLambdaQueryWrapper));
+    }
+
+    /**
+     * 新增数据
+     *
+     * @param tAddress 实体对象
+     * @return 新增结果
+     */
+    @PostMapping("save")
+    @ApiOperation("新增地址")
+    public R insert(@RequestBody TAddress tAddress) {
+        return R.ok(this.tAddressService.save(tAddress));
+    }
+
+    /**
+     * 修改数据
+     *
+     * @param tAddress 实体对象
+     * @return 修改结果
+     */
+    @PostMapping("/update")
+    @ApiOperation("修改地址")
+    public R update(@RequestBody TAddress tAddress) {
+        return R.ok(this.tAddressService.updateById(tAddress));
+    }
+
+    /**
+     * 删除数据
+     *
+     * @param idList 主键结合
+     * @return 删除结果
+     */
+    @DeleteMapping("/delete")
+    @ApiOperation("删除地址")
+    public R delete(@RequestParam("idList") List<Long> idList) {
+        return R.ok(this.tAddressService.removeByIds(idList));
+    }
+}
+

+ 0 - 1
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/TJsController.java

@@ -13,7 +13,6 @@ import com.ylx.massage.domain.Location;
 import com.ylx.massage.domain.TJs;
 import com.ylx.massage.domain.vo.TJsVo;
 import com.ylx.massage.service.TJsService;
-import com.ylx.massage.service.TXiangmuService;
 import com.ylx.massage.utils.LocationUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;

+ 16 - 14
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/WxController.java

@@ -245,11 +245,6 @@ public class WxController extends BaseController {
                 user.setcIcon(avatarUrl);
                 user.setcPhone(phoneNumber);
                 wxUserService.save(user);
-            } else {
-                user.setcNickName(nickName);
-                user.setcIcon(avatarUrl);
-                user.setcPhone(phoneNumber);
-                wxUserService.updateById(user);
             }
 
             WxLoginUser wxUser = new WxLoginUser();
@@ -272,15 +267,22 @@ public class WxController extends BaseController {
      * 更新用户信息接口
      */
     @PostMapping("/update")
-    public String updateUserInfo(@RequestBody TWxUser user) {
-        if (user == null || user.getcOpenid() == null) {
-            return "用户信息不能为空";
-        }
-
-        if (wxUserService.saveOrUpdate(user)) {
-            return "更新用户信息成功";
-        } else {
-            return "更新用户信息失败";
+    public R updateUserInfo(@RequestBody TWxUser user) {
+        try {
+            // 前端校验后,再次进行后端的基础校验
+            if (user == null || user.getcOpenid() == null || user.getcOpenid().isEmpty()) {
+                return R.fail("用户信息不能为空");
+            }
+            // 保存或更新用户信息
+            if (wxUserService.saveOrUpdate(user)) {
+                return R.ok("用户信息更新成功");
+            } else {
+                return R.fail("更新用户信息失败");
+            }
+        } catch (Exception e) {
+            // 异常处理,记录日志并返回友好的错误信息
+             log.error("更新用户信息异常", e);
+            return R.fail("更新用户信息异常,请稍后尝试");
         }
     }
 

+ 6 - 6
nightFragrance-admin/src/main/java/com/ylx/web/core/config/SwaggerConfig.java

@@ -16,14 +16,14 @@ import springfox.documentation.service.*;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spi.service.contexts.SecurityContext;
 import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
 
 /**
  * Swagger2的接口配置
  *
  * @author ylx
  */
-@EnableSwagger2
+@EnableSwagger2WebMvc
 @Configuration
 public class SwaggerConfig {
     //** 系统基础配置 *//*
@@ -59,8 +59,8 @@ public class SwaggerConfig {
                 .build()
                 // 设置安全模式,swagger可以设置访问token *//*
                 .securitySchemes(securitySchemes())
-                .securityContexts(securityContexts())
-                .pathMapping(pathMapping);
+                .securityContexts(securityContexts());
+//                .pathMapping(pathMapping);
     }
 
 
@@ -100,9 +100,9 @@ public class SwaggerConfig {
         // 用ApiInfoBuilder进行定制
         return new ApiInfoBuilder()
                 // 设置标题
-                .title("标题:若依管理系统_接口文档")
+                .title("夜来香系统_接口文档")
                 // 描述
-                .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
+                .description("描述:体包括XXX,XXX模块...")
                 // 作者信息
                 .contact(new Contact(ruoyiConfig.getName(), null, null))
                 // 版本

+ 5 - 0
nightFragrance-common/pom.xml

@@ -154,6 +154,11 @@
             <version>4.1.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-openapi2-spring-boot-starter</artifactId>
+            <version>4.4.0</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 167 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/TAddress.java

@@ -0,0 +1,167 @@
+package com.ylx.massage.domain;
+
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 轮播图(TAddress)表实体类
+ *
+ * @author makejava
+ * @since 2024-04-11 17:18:53
+ */
+@SuppressWarnings("serial")
+@ApiModel(value = "TAddress", description = "地址管理")
+public class TAddress extends Model<TAddress> {
+    //主键
+    @ApiModelProperty("主键")
+    private String id;
+    //用户openId
+    @ApiModelProperty("用户openId")
+    private String openid;
+    //电话
+    @ApiModelProperty("电话")
+    private String phone;
+    //姓名
+    @ApiModelProperty("姓名")
+    private String userName;
+    //地图展示地址
+    @ApiModelProperty("地图展示地址")
+    private String atlasAdd;
+    //经度
+    @ApiModelProperty("经度")
+    private Double longitude;
+    //纬度
+    @ApiModelProperty("纬度")
+    private Double latitude;
+    //地址类型1:默认地址
+    @ApiModelProperty("地址类型1:默认地址")
+    private Integer type;
+    //详细地址
+    @ApiModelProperty("详细地址")
+    private String address;
+    //创建时间
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+    //修改时间
+    @ApiModelProperty("修改时间")
+    private Date updateTime;
+    //是否删除0否1是
+    @ApiModelProperty("是否删除0否1是")
+    @TableLogic
+    private Integer isDelete;
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getOpenid() {
+        return openid;
+    }
+
+    public void setOpenid(String openid) {
+        this.openid = openid;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getAtlasAdd() {
+        return atlasAdd;
+    }
+
+    public void setAtlasAdd(String atlasAdd) {
+        this.atlasAdd = atlasAdd;
+    }
+
+    public Double getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(Double longitude) {
+        this.longitude = longitude;
+    }
+
+    public Double getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
+    /**
+     * 获取主键值
+     *
+     * @return 主键值
+     */
+    @Override
+    public  Serializable pkVal() {
+        return this.id;
+    }
+}
+

+ 1 - 1
nightFragrance-massage/src/main/java/com/ylx/massage/domain/TJs.java

@@ -204,7 +204,7 @@ public class TJs implements Serializable {
 
     @TableField(exist = false)
     @ApiModelProperty("技师距离")
-    private BigDecimal distance ;
+    private BigDecimal distance = BigDecimal.valueOf(10000L);
 
     @TableField(exist = false)
     @ApiModelProperty("技师项目")

+ 35 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/mapper/TAddressMapper.java

@@ -0,0 +1,35 @@
+package com.ylx.massage.mapper;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ylx.massage.domain.TAddress;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 轮播图(TAddress)表数据库访问层
+ *
+ * @author makejava
+ * @since 2024-04-11 17:18:53
+ */
+public interface TAddressMapper extends BaseMapper<TAddress> {
+
+    /**
+     * 批量新增数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<TAddress> 实例对象列表
+     * @return 影响行数
+     */
+    int insertBatch(@Param("entities") List<TAddress> entities);
+
+    /**
+     * 批量新增或按主键更新数据(MyBatis原生foreach方法)
+     *
+     * @param entities List<TAddress> 实例对象列表
+     * @return 影响行数
+     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
+     */
+    int insertOrUpdateBatch(@Param("entities") List<TAddress> entities);
+
+}
+

+ 15 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/TAddressService.java

@@ -0,0 +1,15 @@
+package com.ylx.massage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ylx.massage.domain.TAddress;
+
+/**
+ * 轮播图(TAddress)表服务接口
+ *
+ * @author makejava
+ * @since 2024-04-11 17:18:53
+ */
+public interface TAddressService extends IService<TAddress> {
+
+}
+

+ 19 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/TAddressServiceImpl.java

@@ -0,0 +1,19 @@
+package com.ylx.massage.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ylx.massage.mapper.TAddressMapper;
+import com.ylx.massage.domain.TAddress;
+import com.ylx.massage.service.TAddressService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 轮播图(TAddress)表服务实现类
+ *
+ * @author makejava
+ * @since 2024-04-11 17:18:53
+ */
+@Service("tAddressService")
+public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> implements TAddressService {
+
+}
+

+ 42 - 0
nightFragrance-massage/src/main/resources/mapper/massage/TAddressMapper.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ylx.massage.mapper.TAddressMapper">
+
+    <resultMap type="com.ylx.massage.domain.TAddress" id="TAddressMap">
+        <result property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="openid" column="openid" jdbcType="VARCHAR"/>
+        <result property="phone" column="phone" jdbcType="VARCHAR"/>
+        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
+        <result property="atlasAdd" column="atlas_add" jdbcType="VARCHAR"/>
+        <result property="longitude" column="longitude" jdbcType="NUMERIC"/>
+        <result property="latitude" column="latitude" jdbcType="NUMERIC"/>
+        <result property="type" column="type" jdbcType="INTEGER"/>
+        <result property="address" column="address" jdbcType="VARCHAR"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <!-- 批量插入 -->
+    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into ry-vue.t_address(openidphoneuser_nameaddlongitudelatitudetypeaddresscreate_timeupdate_timeis_delete)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.openid}#{entity.phone}#{entity.userName}#{entity.add}#{entity.longitude}#{entity.latitude}#{entity.type}#{entity.address}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
+        </foreach>
+    </insert>
+    <!-- 批量插入或按主键更新 -->
+    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
+        insert into ry-vue.t_address(openidphoneuser_nameaddlongitudelatitudetypeaddresscreate_timeupdate_timeis_delete)
+        values
+        <foreach collection="entities" item="entity" separator=",">
+            (#{entity.openid}#{entity.phone}#{entity.userName}#{entity.add}#{entity.longitude}#{entity.latitude}#{entity.type}#{entity.address}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
+        </foreach>
+        on duplicate key update
+        openid = values(openid) phone = values(phone) user_name = values(user_name) add = values(add) longitude =
+        values(longitude) latitude = values(latitude) type = values(type) address = values(address) create_time =
+        values(create_time) update_time = values(update_time) is_delete = values(is_delete)
+    </insert>
+
+</mapper>
+