✨ feat(新增): 创建订单表相关-开始数据分片
This commit is contained in:
parent
f744d564b4
commit
75f38e36e9
|
@ -0,0 +1,41 @@
|
|||
package cn.bunny.entity.order;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author order
|
||||
* @since 2024-07-29
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_order")
|
||||
@ApiModel(value = "Order对象", description = "")
|
||||
public class Order implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private BigDecimal amount;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package cn.bunny.service.controller;
|
||||
|
||||
import cn.bunny.entity.order.Order;
|
||||
import cn.bunny.pojo.result.Result;
|
||||
import cn.bunny.service.service.OrderService;
|
||||
import cn.bunny.vo.page.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author order
|
||||
* @since 2024-07-29
|
||||
*/
|
||||
@Tag(name = "订单表")
|
||||
@RestController
|
||||
@RequestMapping("/api/order")
|
||||
public class OrderController {
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Operation(summary = "分页查询订单", description = "分页查询订单")
|
||||
@GetMapping("queryPage/{page}/{limit}")
|
||||
public Result<PageResult<Order>> queryPage(@PathVariable Integer limit, @PathVariable Integer page) {
|
||||
Page<Order> pageParams = new Page<>(page, limit);
|
||||
PageResult<Order> vo = orderService.queryPage(pageParams);
|
||||
return Result.success(vo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package cn.bunny.service.mapper;
|
||||
|
||||
import cn.bunny.entity.order.Order;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author order
|
||||
* @since 2024-07-29
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderMapper extends BaseMapper<Order> {
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package cn.bunny.service.service;
|
||||
|
||||
import cn.bunny.entity.order.Order;
|
||||
import cn.bunny.vo.page.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author order
|
||||
* @since 2024-07-29
|
||||
*/
|
||||
public interface OrderService extends IService<Order> {
|
||||
|
||||
/**
|
||||
* * 分页查询订单
|
||||
*
|
||||
* @param pageParams 分页参数
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
PageResult<Order> queryPage(Page<Order> pageParams);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.bunny.service.service.impl;
|
||||
|
||||
import cn.bunny.entity.order.Order;
|
||||
import cn.bunny.service.mapper.OrderMapper;
|
||||
import cn.bunny.service.service.OrderService;
|
||||
import cn.bunny.vo.page.PageResult;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author order
|
||||
* @since 2024-07-29
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
|
||||
|
||||
/**
|
||||
* * 分页查询订单
|
||||
*
|
||||
* @param pageParams 分页参数
|
||||
* @return 返回分页结果
|
||||
*/
|
||||
@Override
|
||||
public PageResult<Order> queryPage(Page<Order> pageParams) {
|
||||
Page<Order> page = page(pageParams);
|
||||
|
||||
return PageResult.<Order>builder()
|
||||
.pageNo((int) page.getCurrent())
|
||||
.pageSize((int) page.getSize())
|
||||
.total(page.getTotal())
|
||||
.list(page.getRecords())
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?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="cn.bunny.service.mapper.OrderMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.bunny.entity.order.Order">
|
||||
<id column="id" property="id"/>
|
||||
<result column="order_no" property="orderNo"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="amount" property="amount"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, order_no, user_id, amount
|
||||
</sql>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue