| | |
| | | package com.ruoyi.goods.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | | import com.ruoyi.common.core.utils.page.PageDTO; |
| | | import com.ruoyi.goods.controller.mamagement.DTO.GoodsSeriesDTO; |
| | | import com.ruoyi.goods.controller.mamagement.DTO.GoodsSeriesQuery; |
| | | import com.ruoyi.goods.controller.mamagement.VO.GoodsSeriesVO; |
| | | import com.ruoyi.goods.domain.pojo.GoodsSeries; |
| | | import com.ruoyi.goods.mapper.GoodsSeriesMapper; |
| | |
| | | return BeanUtils.copyList(this.list(), GoodsSeriesVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取商品系列的分页信息 |
| | | * |
| | | * @param query 包含分页参数和查询条件的查询对象 |
| | | * @return 返回商品系列的分页数据传输对象(DTO),包含分页信息和商品系列列表 |
| | | */ |
| | | @Override |
| | | public PageDTO<GoodsSeriesVO> getGoodsSeriesPage(GoodsSeriesQuery query) { |
| | | Page<GoodsSeries> page = this.lambdaQuery() |
| | | .like(StringUtils.isNotEmpty(query.getSeriesName()), GoodsSeries::getSeriesName, |
| | | query.getSeriesName()) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | if (StringUtils.isEmpty(page.getRecords())) { |
| | | return PageDTO.empty(page.getTotal(), page.getPages()); |
| | | } |
| | | return PageDTO.of(page, GoodsSeriesVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 保存或更新商品系列信息。 |
| | | * |
| | | * @param dto 商品系列数据传输对象,包含商品系列的详细信息。 如果商品系列ID为空,则视为新记录,进行保存; 如果商品系列ID不为空,则视为更新记录,进行更新。 |
| | | */ |
| | | @Override |
| | | public void saveGoodsSeries(GoodsSeriesDTO dto) { |
| | | GoodsSeries goodsSeries = BeanUtils.copyBean(dto, GoodsSeries.class); |
| | | if (StringUtils.isNull(goodsSeries.getId())) { |
| | | this.save(goodsSeries); |
| | | } else { |
| | | this.updateById(goodsSeries); |
| | | } |
| | | } |
| | | } |