添加订单表
This commit is contained in:
parent
49405d420c
commit
7cd44d430b
@ -1,11 +1,14 @@
|
||||
package io.modules.item.dto;
|
||||
|
||||
import io.modules.item.entity.FrontUserEntity;
|
||||
import io.modules.item.entity.OrderEntity;
|
||||
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.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -25,7 +28,6 @@ public class ItemDTO implements Serializable {
|
||||
|
||||
@SchemaProperty(name = "类别编号")
|
||||
private Long categoryId;
|
||||
private String categoryName;
|
||||
|
||||
@SchemaProperty(name = "图片")
|
||||
private String image;
|
||||
@ -64,4 +66,16 @@ public class ItemDTO implements Serializable {
|
||||
private String attribute;
|
||||
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String categoryName;
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private FrontUserEntity user;
|
||||
/**
|
||||
* 评论信息信息
|
||||
*/
|
||||
private List<OrderDTO> orderEntityList;
|
||||
}
|
||||
|
@ -50,5 +50,5 @@ public class OrderDTO implements Serializable {
|
||||
@SchemaProperty(name = "订单创建时间")
|
||||
private Date createdTime;
|
||||
|
||||
|
||||
private UserDTO user;
|
||||
}
|
||||
|
@ -8,9 +8,6 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
*
|
||||
* @author Mark #
|
||||
* @since 1.0.0 2025-02-14
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_order")
|
||||
|
@ -5,6 +5,8 @@ import io.common.service.CrudService;
|
||||
import io.modules.item.dto.OrderDTO;
|
||||
import io.modules.item.entity.OrderEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
*
|
||||
@ -13,4 +15,10 @@ import io.modules.item.entity.OrderEntity;
|
||||
*/
|
||||
public interface OrderService extends CrudService<OrderEntity, OrderDTO> {
|
||||
|
||||
/**
|
||||
* 获取评论信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<OrderDTO> getCommintList(Long id);
|
||||
}
|
@ -1,15 +1,24 @@
|
||||
package io.modules.item.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.dto.UserDTO;
|
||||
import io.modules.item.entity.OrderEntity;
|
||||
import io.modules.item.service.OrderService;
|
||||
import io.modules.item.service.UserService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 订单表
|
||||
@ -17,6 +26,9 @@ import java.util.Map;
|
||||
@Service
|
||||
public class OrderServiceImpl extends CrudServiceImpl<OrderDao, OrderEntity, OrderDTO> implements OrderService {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public QueryWrapper<OrderEntity> getWrapper(Map<String, Object> params){
|
||||
String id = (String)params.get("id");
|
||||
@ -31,5 +43,22 @@ public class OrderServiceImpl extends CrudServiceImpl<OrderDao, OrderEntity, Ord
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<OrderDTO> getCommintList(Long id) {
|
||||
LambdaQueryWrapper<OrderEntity> lwq = new LambdaQueryWrapper<>();
|
||||
lwq.eq(OrderEntity::getOrderStatus,3);
|
||||
List<OrderEntity> list = baseDao.selectList(lwq);
|
||||
List<OrderDTO> stream = list.stream().map(e -> {
|
||||
OrderDTO dto = new OrderDTO();
|
||||
BeanUtils.copyProperties(e, dto);
|
||||
if (dto.getUserId() != null) {
|
||||
UserDTO userDTO = userService.get(e.getUserId());
|
||||
if (userDTO!= null) {
|
||||
dto.setUser(userDTO);
|
||||
}
|
||||
}
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
return stream;
|
||||
}
|
||||
}
|
@ -12,9 +12,13 @@ import io.common.validator.group.AddGroup;
|
||||
import io.common.validator.group.DefaultGroup;
|
||||
import io.common.validator.group.UpdateGroup;
|
||||
import io.modules.item.dto.ItemDTO;
|
||||
import io.modules.item.dto.OrderDTO;
|
||||
import io.modules.item.entity.ItemEntity;
|
||||
import io.modules.item.entity.OrderEntity;
|
||||
import io.modules.item.service.ItemService;
|
||||
import io.modules.item.service.OrderService;
|
||||
import io.modules.item.service.UserBehaviorService;
|
||||
import io.modules.item.service.UserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
@ -38,6 +42,10 @@ import java.util.stream.Collectors;
|
||||
public class ItemController {
|
||||
@Autowired
|
||||
private ItemService itemService;
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private UserBehaviorService userBehaviorService;
|
||||
@Value("${upload.url}")
|
||||
@ -56,6 +64,10 @@ public class ItemController {
|
||||
PageData<ItemDTO> page = itemService.page(params);
|
||||
List<ItemDTO> list = page.getList().stream().map(e -> {
|
||||
e.setImage(uploadUrl + e.getImage());
|
||||
|
||||
// 获取评价信息
|
||||
List<OrderDTO> orderEntityList = orderService.getCommintList(e.getId() );
|
||||
e.setOrderEntityList(orderEntityList);
|
||||
return e;
|
||||
}).collect(Collectors.toList());
|
||||
page.setList(list);
|
||||
|
Loading…
Reference in New Issue
Block a user