添加订单表
This commit is contained in:
parent
a47d73cafb
commit
49405d420c
@ -0,0 +1,87 @@
|
|||||||
|
package io.modules.sys.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import io.common.constant.Constant;
|
||||||
|
import io.common.page.PageData;
|
||||||
|
import io.common.utils.Result;
|
||||||
|
import io.common.validator.AssertUtils;
|
||||||
|
import io.common.validator.ValidatorUtils;
|
||||||
|
import io.common.validator.group.AddGroup;
|
||||||
|
import io.common.validator.group.DefaultGroup;
|
||||||
|
import io.common.validator.group.UpdateGroup;
|
||||||
|
import io.modules.item.dto.OrderDTO;
|
||||||
|
import io.modules.item.service.OrderService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表
|
||||||
|
*
|
||||||
|
* @author Mark #
|
||||||
|
* @since 1.0.0 2025-02-14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("sys/order")
|
||||||
|
@Tag(name="订单表")
|
||||||
|
public class OrderController {
|
||||||
|
@Autowired
|
||||||
|
private OrderService orderService;
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@Operation(summary = "分页")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref="int") ,
|
||||||
|
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY,required = true, ref="int") ,
|
||||||
|
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
||||||
|
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
||||||
|
})
|
||||||
|
public Result<PageData<OrderDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
|
||||||
|
PageData<OrderDTO> page = orderService.page(params);
|
||||||
|
|
||||||
|
return new Result<PageData<OrderDTO>>().ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@Operation(summary = "信息")
|
||||||
|
public Result<OrderDTO> get(@PathVariable("id") Long id){
|
||||||
|
OrderDTO data = orderService.get(id);
|
||||||
|
|
||||||
|
return new Result<OrderDTO>().ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary = "保存")
|
||||||
|
public Result save(@RequestBody OrderDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
orderService.save(dto);
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
public Result update(@RequestBody OrderDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
|
orderService.update(dto);
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
public Result delete(@RequestBody Long[] ids){
|
||||||
|
//效验数据
|
||||||
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
|
orderService.delete(ids);
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package io.modules.item.dao;
|
||||||
|
|
||||||
|
|
||||||
|
import io.common.dao.BaseDao;
|
||||||
|
import io.modules.item.entity.OrderEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表
|
||||||
|
*
|
||||||
|
* @author Mark #
|
||||||
|
* @since 1.0.0 2025-02-14
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface OrderDao extends BaseDao<OrderEntity> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package io.modules.item.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.media.SchemaProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表
|
||||||
|
*
|
||||||
|
* @author Mark #
|
||||||
|
* @since 1.0.0 2025-02-14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(name = "订单表")
|
||||||
|
public class OrderDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "订单编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "用户编号")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "商品编号")
|
||||||
|
private Long itemId;
|
||||||
|
|
||||||
|
@SchemaProperty(name = " 收货地址ID,关联到收货地址表")
|
||||||
|
private Long addressId;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "状态")
|
||||||
|
private Integer orderStatus;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "购买数量")
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "订单总金额")
|
||||||
|
private BigDecimal totalAmount;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "支付状态")
|
||||||
|
private Integer paymentStatus;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "支付时间")
|
||||||
|
private Date paymentDate;
|
||||||
|
|
||||||
|
@SchemaProperty(name = "订单创建时间")
|
||||||
|
private Date createdTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package io.modules.item.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表
|
||||||
|
*
|
||||||
|
* @author Mark #
|
||||||
|
* @since 1.0.0 2025-02-14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("tb_order")
|
||||||
|
public class OrderEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单编号
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户编号
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 商品编号
|
||||||
|
*/
|
||||||
|
private Long itemId;
|
||||||
|
/**
|
||||||
|
* 收货地址ID,关联到收货地址表
|
||||||
|
*/
|
||||||
|
private Long addressId;
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer orderStatus;
|
||||||
|
/**
|
||||||
|
* 购买数量
|
||||||
|
*/
|
||||||
|
private Integer quantity;
|
||||||
|
/**
|
||||||
|
* 订单总金额
|
||||||
|
*/
|
||||||
|
private BigDecimal totalAmount;
|
||||||
|
/**
|
||||||
|
* 支付状态
|
||||||
|
*/
|
||||||
|
private Integer paymentStatus;
|
||||||
|
/**
|
||||||
|
* 订单评价分数
|
||||||
|
*/
|
||||||
|
private Integer score;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评价内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付时间
|
||||||
|
*/
|
||||||
|
private Date paymentDate;
|
||||||
|
/**
|
||||||
|
* 订单创建时间
|
||||||
|
*/
|
||||||
|
private Date createdTime;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package io.modules.item.service;
|
||||||
|
|
||||||
|
|
||||||
|
import io.common.service.CrudService;
|
||||||
|
import io.modules.item.dto.OrderDTO;
|
||||||
|
import io.modules.item.entity.OrderEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表
|
||||||
|
*
|
||||||
|
* @author Mark #
|
||||||
|
* @since 1.0.0 2025-02-14
|
||||||
|
*/
|
||||||
|
public interface OrderService extends CrudService<OrderEntity, OrderDTO> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package io.modules.item.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import io.common.service.impl.CrudServiceImpl;
|
||||||
|
import io.modules.item.dao.OrderDao;
|
||||||
|
import io.modules.item.dto.OrderDTO;
|
||||||
|
import io.modules.item.entity.OrderEntity;
|
||||||
|
import io.modules.item.service.OrderService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class OrderServiceImpl extends CrudServiceImpl<OrderDao, OrderEntity, OrderDTO> implements OrderService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper<OrderEntity> getWrapper(Map<String, Object> params){
|
||||||
|
String id = (String)params.get("id");
|
||||||
|
String orderStatus = (String)params.get("orderStatus");
|
||||||
|
String paymentStatus = (String)params.get("paymentStatus");
|
||||||
|
String userId = (String)params.get("userId");
|
||||||
|
QueryWrapper<OrderEntity> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq(StrUtil.isNotBlank(id), "id", id);
|
||||||
|
wrapper.eq(StrUtil.isNotBlank(orderStatus), "order_status", orderStatus);
|
||||||
|
wrapper.eq(StrUtil.isNotBlank(paymentStatus), "payment_status", paymentStatus);
|
||||||
|
wrapper.eq(StrUtil.isNotBlank(userId), "user_id", userId);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package io.controller;
|
package io.controller;
|
||||||
|
|
||||||
|
import io.annotation.Login;
|
||||||
import io.common.constant.Constant;
|
import io.common.constant.Constant;
|
||||||
import io.common.page.PageData;
|
import io.common.page.PageData;
|
||||||
import io.common.utils.Result;
|
import io.common.utils.Result;
|
||||||
@ -41,9 +42,10 @@ public class AddressController {
|
|||||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
||||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
||||||
})
|
})
|
||||||
public Result<PageData<AddressDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
|
@Login
|
||||||
|
public Result<PageData<AddressDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params,@Parameter(hidden = true) @RequestAttribute("userId") Long userId){
|
||||||
|
params.put("userId",userId);
|
||||||
PageData<AddressDTO> page = addressService.page(params);
|
PageData<AddressDTO> page = addressService.page(params);
|
||||||
|
|
||||||
return new Result<PageData<AddressDTO>>().ok(page);
|
return new Result<PageData<AddressDTO>>().ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +53,6 @@ public class AddressController {
|
|||||||
@Operation(summary = "信息")
|
@Operation(summary = "信息")
|
||||||
public Result<AddressDTO> get(@PathVariable("id") Long id){
|
public Result<AddressDTO> get(@PathVariable("id") Long id){
|
||||||
AddressDTO data = addressService.get(id);
|
AddressDTO data = addressService.get(id);
|
||||||
|
|
||||||
return new Result<AddressDTO>().ok(data);
|
return new Result<AddressDTO>().ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
package io.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import io.annotation.Login;
|
||||||
|
import io.common.constant.Constant;
|
||||||
|
import io.common.page.PageData;
|
||||||
|
import io.common.utils.Result;
|
||||||
|
import io.common.validator.AssertUtils;
|
||||||
|
import io.common.validator.ValidatorUtils;
|
||||||
|
import io.common.validator.group.AddGroup;
|
||||||
|
import io.common.validator.group.DefaultGroup;
|
||||||
|
import io.common.validator.group.UpdateGroup;
|
||||||
|
import io.modules.item.dto.OrderDTO;
|
||||||
|
import io.modules.item.service.OrderService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单表
|
||||||
|
*
|
||||||
|
* @author Mark #
|
||||||
|
* @since 1.0.0 2025-02-14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api/order")
|
||||||
|
@Tag(name="订单表")
|
||||||
|
public class OrderController {
|
||||||
|
@Autowired
|
||||||
|
private OrderService orderService;
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@Operation(summary = "分页")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref="int") ,
|
||||||
|
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY,required = true, ref="int") ,
|
||||||
|
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
||||||
|
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
||||||
|
})
|
||||||
|
@Login
|
||||||
|
public Result<PageData<OrderDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params,@Parameter(hidden = true) @RequestAttribute("userId") Long userId){
|
||||||
|
params.put("userId",userId);
|
||||||
|
PageData<OrderDTO> page = orderService.page(params);
|
||||||
|
return new Result<PageData<OrderDTO>>().ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@Operation(summary = "信息")
|
||||||
|
public Result<OrderDTO> get(@PathVariable("id") Long id){
|
||||||
|
OrderDTO data = orderService.get(id);
|
||||||
|
return new Result<OrderDTO>().ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary = "保存")
|
||||||
|
public Result save(@RequestBody OrderDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
orderService.save(dto);
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
public Result update(@RequestBody OrderDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
|
orderService.update(dto);
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
|
||||||
|
public Result delete(@RequestBody Long[] ids){
|
||||||
|
//效验数据
|
||||||
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
|
|
||||||
|
orderService.delete(ids);
|
||||||
|
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user