diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/controller/OrderController.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/controller/OrderController.java index 0207774..68a8414 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/controller/OrderController.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/controller/OrderController.java @@ -5,11 +5,15 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt; +import org.jeecg.modules.demo.erp.entity.ext.OrderExt; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; @@ -69,14 +73,30 @@ public class OrderController { //@AutoLog(value = "订单-分页列表查询") @ApiOperation(value="订单-分页列表查询", notes="订单-分页列表查询") @GetMapping(value = "/list") - public Result> queryPageList(Order order, + public Result> queryPageList(Order order, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) { QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(order, req.getParameterMap()); Page page = new Page(pageNo, pageSize); IPage pageList = orderService.page(page, queryWrapper); - return Result.OK(pageList); + + List orderDetailExtList = orderDetailService.selectByMainIdExt(""); + Map> orderDetailExtMap = orderDetailExtList + .stream() + .collect( + Collectors.groupingBy(OrderDetailExt::getOrderId) + ); + Page pageExt = new Page<>(pageNo, pageSize); + List records = new ArrayList<>(); + pageList.getRecords().forEach(e ->{ + OrderExt orderExt = new OrderExt(); + BeanUtils.copyProperties(e,orderExt); + orderExt.setOrderDetailList(orderDetailExtMap.get(e.getId())); + records.add(orderExt); + }); + pageExt.setRecords(records); + return Result.OK(pageExt); } /** diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/entity/ext/OrderDetailExt.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/entity/ext/OrderDetailExt.java new file mode 100644 index 0000000..69ed28d --- /dev/null +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/entity/ext/OrderDetailExt.java @@ -0,0 +1,16 @@ +package org.jeecg.modules.demo.erp.entity.ext; + +import lombok.Data; +import org.jeecg.modules.demo.erp.entity.OrderDetail; + +/** + * @author NH-LHG + */ +@Data +public class OrderDetailExt extends OrderDetail { + private java.lang.String factory; + private java.lang.String specs; + private java.lang.String category; + private java.lang.String unit; + private java.lang.String url; +} diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/entity/ext/OrderExt.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/entity/ext/OrderExt.java new file mode 100644 index 0000000..e17a721 --- /dev/null +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/entity/ext/OrderExt.java @@ -0,0 +1,16 @@ +package org.jeecg.modules.demo.erp.entity.ext; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecg.modules.demo.erp.entity.Order; + +import java.util.List; + +/** + * @author NH-LHG + */ +@Data +public class OrderExt extends Order { + @ApiModelProperty(value = "订单详情") + private List orderDetailList; +} diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/OrderDetailMapper.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/OrderDetailMapper.java index 7a7d450..db67772 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/OrderDetailMapper.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/OrderDetailMapper.java @@ -4,6 +4,7 @@ import java.util.List; import org.jeecg.modules.demo.erp.entity.OrderDetail; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt; /** * @Description: 订单详情 @@ -28,4 +29,14 @@ public interface OrderDetailMapper extends BaseMapper { * @return List */ public List selectByMainId(@Param("mainId") String mainId); + + + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List + */ + public List selectByMainIdExt(@Param("mainId") String mainId); + } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/xml/OrderDetailMapper.xml b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/xml/OrderDetailMapper.xml index 0016b41..e35c820 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/xml/OrderDetailMapper.xml +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/mapper/xml/OrderDetailMapper.xml @@ -3,14 +3,26 @@ - DELETE - FROM order_detail + DELETE + FROM order_detail WHERE order_id = #{mainId} - + + + + diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/IOrderDetailService.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/IOrderDetailService.java index 52347bc..0986b90 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/IOrderDetailService.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/IOrderDetailService.java @@ -2,6 +2,8 @@ package org.jeecg.modules.demo.erp.service; import org.jeecg.modules.demo.erp.entity.OrderDetail; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt; + import java.util.List; /** @@ -19,4 +21,11 @@ public interface IOrderDetailService extends IService { * @return List */ public List selectByMainId(String mainId); + /** + * 通过主表id查询子表数据 + * + * @param mainId 主表id + * @return List + */ + public List selectByMainIdExt(String mainId); } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/impl/OrderDetailServiceImpl.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/impl/OrderDetailServiceImpl.java index 042cfac..ec80d58 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/impl/OrderDetailServiceImpl.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/erp/service/impl/OrderDetailServiceImpl.java @@ -1,6 +1,7 @@ package org.jeecg.modules.demo.erp.service.impl; import org.jeecg.modules.demo.erp.entity.OrderDetail; +import org.jeecg.modules.demo.erp.entity.ext.OrderDetailExt; import org.jeecg.modules.demo.erp.mapper.OrderDetailMapper; import org.jeecg.modules.demo.erp.service.IOrderDetailService; import org.springframework.stereotype.Service; @@ -16,12 +17,18 @@ import org.springframework.beans.factory.annotation.Autowired; */ @Service public class OrderDetailServiceImpl extends ServiceImpl implements IOrderDetailService { - + @Autowired private OrderDetailMapper orderDetailMapper; - + @Override public List selectByMainId(String mainId) { return orderDetailMapper.selectByMainId(mainId); } + + @Override + public List selectByMainIdExt(String mainId) { + return orderDetailMapper.selectByMainIdExt(mainId); + } + } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysRole.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysRole.java index a9c7ad9..bb4e686 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysRole.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysRole.java @@ -1,7 +1,6 @@ package org.jeecg.modules.system.entity; import java.io.Serializable; -import java.time.LocalDateTime; import java.util.Date; import org.jeecgframework.poi.excel.annotation.Excel; @@ -35,19 +34,19 @@ public class SysRole implements Serializable { */ @TableId(type = IdType.ASSIGN_ID) private String id; - + /** * 角色名称 */ @Excel(name="角色名",width=15) private String roleName; - + /** * 角色编码 */ @Excel(name="角色编码",width=15) private String roleCode; - + /** * 描述 */