Forráskód Böngészése

后台 添加用户表和用户地址表,以及用户地址查询接口

limingming 1 éve
szülő
commit
d0027619f4

+ 54 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/UserInfoController.java

@@ -0,0 +1,54 @@
+package com.ruoyi.web.controller.platform;
+
+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.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.system.domain.BaseParam;
+import com.ruoyi.system.domain.UserAddress;
+import com.ruoyi.system.domain.UserInfo;
+import com.ruoyi.system.service.UserAddressService;
+import com.ruoyi.system.service.UserInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 用户信息Controller
+ * 
+ * @author liming
+ * @date 2023-08-01
+ */
+@RestController
+@RequestMapping("/platform/v1/userInfo")
+public class UserInfoController extends BaseController {
+    @Autowired
+    private UserInfoService userInfoService;
+
+    @Autowired
+    private UserAddressService userAddressService;
+
+    /**
+     * 查询用户信息列表
+     */
+//    @PreAuthorize("@ss.hasPermi('system:info:list')")
+    @PostMapping("/list")
+    public R<IPage<UserInfo>> list(@RequestBody  BaseParam param) {
+        IPage<UserInfo> userInfoIPage = userInfoService.page(new Page<UserInfo>().setCurrent(param.getCurrent()).setSize(param.getSize()),
+                new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getDelFlag,0));
+        return R.ok(userInfoIPage);
+    }
+
+
+    /**
+     * 获取用户d地址详情信息
+     */
+//    @PreAuthorize("@ss.hasPermi('system:info:query')")
+    @PostMapping(value = "/userAddress")
+    public R<UserAddress> getInfo(@RequestBody BaseParam param) {
+        UserAddress userAddress = userAddressService.getAddress(param.getId());
+        return R.ok(userAddress);
+    }
+
+
+}

+ 46 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/UserAddress.java

@@ -0,0 +1,46 @@
+package com.ruoyi.system.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 用户地址信息对象 t_user_address
+ * 
+ * @author ruoyi
+ * @date 2023-08-01
+ */
+@Data
+@TableName("t_user_address")
+public class UserAddress implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private Long id;
+
+    /** 关联用户id */
+    @Excel(name = "关联用户id")
+    private Long userId;
+
+    /** 用户地址信息 */
+    @Excel(name = "用户地址信息")
+    private String address;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    private String delFlag;
+
+    /** 创建者 */
+    private String createBy;
+
+    /** 创建时间 */
+    private Date createTime;
+
+    /** 更新者 */
+    private String updateBy;
+
+    /** 更新时间 */
+    private Date updateTime;
+}

+ 42 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/UserInfo.java

@@ -0,0 +1,42 @@
+package com.ruoyi.system.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 用户信息对象 t_user_info
+ * 
+ * @author ruoyi
+ * @date 2023-08-01
+ */
+@Data
+@TableName("t_user_info")
+public class UserInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private Long id;
+
+    /** 用户手机号 */
+    @Excel(name = "用户手机号")
+    private String userPhone;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    private String delFlag;
+
+    /** 创建者 */
+    private String createBy;
+
+    /** 创建时间 */
+    private Date createTime;
+
+    /** 更新者 */
+    private String updateBy;
+
+    /** 更新时间 */
+    private Date updateTime;
+}

+ 16 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserAddressMapper.java

@@ -0,0 +1,16 @@
+package com.ruoyi.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.system.domain.UserAddress;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 用户地址信息Mapper接口
+ * 
+ * @author liming
+ * @date 2023-08-01
+ */
+public interface UserAddressMapper extends BaseMapper<UserAddress> {
+
+    UserAddress getAddress(@Param("userId") Long userId);
+}

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserInfoMapper.java

@@ -0,0 +1,14 @@
+package com.ruoyi.system.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.system.domain.UserInfo;
+
+/**
+ * 用户信息Mapper接口
+ * 
+ * @author liming
+ * @date 2023-08-01
+ */
+public interface UserInfoMapper extends BaseMapper<UserInfo> {
+
+}

+ 19 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/UserAddressService.java

@@ -0,0 +1,19 @@
+package com.ruoyi.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.system.domain.UserAddress;
+
+/**
+ * 用户地址信息Service接口
+ * 
+ * @author liming
+ * @date 2023-08-01
+ */
+public interface UserAddressService extends IService<UserAddress> {
+    /**
+     * 根据用户id查询最新一条用户的地址信息
+     * @param id
+     * @return
+     */
+    UserAddress getAddress(Long userId);
+}

+ 14 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/UserInfoService.java

@@ -0,0 +1,14 @@
+package com.ruoyi.system.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.system.domain.UserInfo;
+
+/**
+ * 用户信息Service接口
+ * 
+ * @author liming
+ * @date 2023-08-01
+ */
+public interface UserInfoService  extends IService<UserInfo> {
+
+}

+ 25 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserAddressServiceImpl.java

@@ -0,0 +1,25 @@
+package com.ruoyi.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.system.domain.UserAddress;
+import com.ruoyi.system.mapper.UserAddressMapper;
+import com.ruoyi.system.service.UserAddressService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 用户地址信息Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2023-08-01
+ */
+@Service
+public class UserAddressServiceImpl  extends ServiceImpl<UserAddressMapper, UserAddress> implements UserAddressService {
+    @Autowired
+    private UserAddressMapper userAddressMapper;
+
+    @Override
+    public UserAddress getAddress(Long userId) {
+        return userAddressMapper.getAddress(userId);
+    }
+}

+ 18 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/UserInfoServiceImpl.java

@@ -0,0 +1,18 @@
+package com.ruoyi.system.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.system.domain.UserInfo;
+import com.ruoyi.system.mapper.UserInfoMapper;
+import com.ruoyi.system.service.UserInfoService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 用户信息Service业务层处理
+ * 
+ * @author liming
+ * @date 2023-08-01
+ */
+@Service
+public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {
+
+}

+ 32 - 0
ruoyi-system/src/main/resources/mapper/system/platform/UserAddressMapper.xml

@@ -0,0 +1,32 @@
+<?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.ruoyi.system.mapper.UserAddressMapper">
+    
+    <resultMap type="UserAddress" id="UserAddressResult">
+        <result property="id"    column="id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="address"    column="address"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectTUserAddressVo">
+        select id, user_id, address, del_flag, create_by, create_time, update_by, update_time from t_user_address
+    </sql>
+
+    <select id="getAddress" resultType="com.ruoyi.system.domain.UserAddress">
+        SELECT address,create_time
+        FROM t_user_address
+        WHERE
+            del_flag = 0 AND user_id = #{userId}
+        ORDER BY create_time DESC
+            LIMIT 1
+    </select>
+
+
+</mapper>

+ 22 - 0
ruoyi-system/src/main/resources/mapper/system/platform/UserInfoMapper.xml

@@ -0,0 +1,22 @@
+<?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.ruoyi.system.mapper.UserInfoMapper">
+    
+    <resultMap type="UserInfo" id="UserInfoResult">
+        <result property="id"    column="id"    />
+        <result property="userPhone"    column="user_phone"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectTUserInfoVo">
+        select id, user_phone, del_flag, create_by, create_time, update_by, update_time from t_user_info
+    </sql>
+
+
+</mapper>