李雨欣 9.5测试接口 21:23
parent
4c93f77533
commit
4ab924148e
|
@ -0,0 +1,82 @@
|
|||
package com.muyu.market.admain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "订单表",autoResultMap = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Orders extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 订单的唯一标识
|
||||
*/
|
||||
@TableId(value = "order_id",type = IdType.AUTO)
|
||||
private Long orderId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Schema(description = "用户名",type = "Long")
|
||||
private Long userId;
|
||||
/**
|
||||
* 商品Id
|
||||
*/
|
||||
@Schema(description = "商品Id",type = "Long")
|
||||
private Long apiId;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号",type = "String")
|
||||
private String orderNo;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(description = "订单状态",type = "String")
|
||||
private String orderStatus;
|
||||
/**
|
||||
* 订单总金额
|
||||
*/
|
||||
@Schema(description = "订单总金额",type = "BigDecimal")
|
||||
private BigDecimal totalAmount;
|
||||
/**
|
||||
* 订单创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单创建时间",type = "Date")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 订单更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单更新时间",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
@Schema(description = "订单备注",type = "String")
|
||||
private String note;
|
||||
|
||||
|
||||
private String createBy;
|
||||
private String updateBy;
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -52,8 +51,6 @@ public class TopLog extends BaseEntity {
|
|||
@Schema(description = "充值时间",type = "String")
|
||||
private Date time;
|
||||
|
||||
|
||||
|
||||
private String createBy;
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package com.muyu.market.admain.request;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@Tag(name = "订单展示", description = "订单展示")
|
||||
public class OrdersListReq {
|
||||
|
||||
|
||||
/**
|
||||
* 订单的唯一标识
|
||||
*/
|
||||
@TableId(value = "order_id",type = IdType.AUTO)
|
||||
private Long orderId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Schema(description = "用户名",type ="Long")
|
||||
private Long userId;
|
||||
/**
|
||||
* 商品Id
|
||||
*/
|
||||
@Schema(description = "商品Id",type ="Long")
|
||||
private Long apiId;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号",type ="String")
|
||||
private String orderNo;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(description = "订单状态",type ="String")
|
||||
private String orderStatus;
|
||||
/**
|
||||
* 订单总金额
|
||||
*/
|
||||
@Schema(description = "订单总金额",type ="BigDecimal")
|
||||
private BigDecimal totalAmount;
|
||||
/**
|
||||
* 订单创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单创建时间",type = "Date")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 订单更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单创建时间",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
@Schema(description = "订单备注",type ="String")
|
||||
private String note;
|
||||
|
||||
|
||||
private String createBy;
|
||||
private String updateBy;
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -72,6 +72,13 @@ public class MyapiListResp {
|
|||
private String type;
|
||||
|
||||
|
||||
private String createBy;
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
private Date updateTime;
|
||||
private String remark;
|
||||
|
||||
|
||||
|
||||
public static MyapiListResp selProductList(Myapi myapi){
|
||||
|
||||
|
@ -89,9 +96,5 @@ public class MyapiListResp {
|
|||
.type( myapi.getType())
|
||||
.build();
|
||||
}
|
||||
private String createBy;
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
private Date updateTime;
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
package com.muyu.market.admain.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.market.admain.Myapi;
|
||||
import com.muyu.market.admain.Orders;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@Tag(name = "订单展示", description = "订单展示")
|
||||
public class OrdersListResp {
|
||||
|
||||
|
||||
/**
|
||||
* 订单的唯一标识
|
||||
*/
|
||||
@TableId(value = "order_id",type = IdType.AUTO)
|
||||
private Long orderId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Schema(description = "用户名",type ="Long")
|
||||
private Long userId;
|
||||
/**
|
||||
* 商品Id
|
||||
*/
|
||||
@Schema(description = "商品Id",type ="Long")
|
||||
private Long apiId;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Schema(description = "订单号",type ="String")
|
||||
private String orderNo;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(description = "订单状态",type ="String")
|
||||
private String orderStatus;
|
||||
/**
|
||||
* 订单总金额
|
||||
*/
|
||||
@Schema(description = "订单总金额",type ="BigDecimal")
|
||||
private BigDecimal totalAmount;
|
||||
/**
|
||||
* 订单创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单创建时间",type = "Date")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 订单更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "订单创建时间",type = "Date")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 订单备注
|
||||
*/
|
||||
@Schema(description = "订单备注",type ="String")
|
||||
private String note;
|
||||
|
||||
|
||||
private String createBy;
|
||||
private String updateBy;
|
||||
private String remark;
|
||||
|
||||
|
||||
public static OrdersListResp selOrdersList(Orders orders){
|
||||
|
||||
return OrdersListResp
|
||||
.builder()
|
||||
.orderId(orders.getOrderId())
|
||||
.userId(orders.getUserId())
|
||||
.apiId(orders.getApiId())
|
||||
.orderNo(orders.getOrderNo())
|
||||
.orderStatus(orders.getOrderStatus())
|
||||
.totalAmount(orders.getTotalAmount())
|
||||
.createTime(orders.getCreateTime())
|
||||
.updateTime(orders.getUpdateTime())
|
||||
.note(orders.getNote())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.market.server.controller;
|
||||
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.market.admain.Myapi;
|
||||
import com.muyu.market.server.service.OrdersService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/orders")
|
||||
@Tag(name = "订单控制层",description = "订单查询")
|
||||
public class OrdersController {
|
||||
|
||||
@Autowired
|
||||
private OrdersService ordersService;
|
||||
|
||||
@PostMapping("/Saveorders")
|
||||
@Operation(summary = "订单添加",description = "订单的添加")
|
||||
public Result<String> createOrders(@RequestBody Myapi myapi){
|
||||
|
||||
ordersService.saveOrders(myapi);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.muyu.market.server.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.market.admain.Orders;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface OrdersMapper extends BaseMapper<Orders> {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.muyu.market.server.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.market.admain.Myapi;
|
||||
import com.muyu.market.admain.Orders;
|
||||
import com.muyu.market.server.mapper.OrdersMapper;
|
||||
import com.muyu.market.server.service.OrdersService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {
|
||||
|
||||
@Autowired
|
||||
private OrdersMapper ordersMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void saveOrders(Myapi myapi) {
|
||||
|
||||
Orders orders = new Orders();
|
||||
//获取用户ID
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
orders.setUserId(userId);
|
||||
//获取商品ID
|
||||
orders.setApiId(myapi.getApiId());
|
||||
//获取金额
|
||||
orders.setTotalAmount(myapi.getPrice());
|
||||
//创建时间为当前时间
|
||||
orders.setCreateTime(new Date());
|
||||
//修改时间为当前时间
|
||||
orders.setUpdateTime(new Date());
|
||||
|
||||
try {
|
||||
ordersMapper.insert(orders);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.muyu.market.server.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.market.admain.Myapi;
|
||||
import com.muyu.market.admain.Orders;
|
||||
|
||||
public interface OrdersService extends IService<Orders> {
|
||||
void saveOrders(Myapi myapi);
|
||||
}
|
Loading…
Reference in New Issue