| | |
| | | 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.domain.dto.GoodsInfoTitleDTO; |
| | | import com.ruoyi.goods.domain.pojo.GoodsInfoTitle; |
| | | import com.ruoyi.goods.domain.query.GoodsInfoTitleQuery; |
| | | import com.ruoyi.goods.domain.vo.GoodsInfoTitleVO; |
| | | import com.ruoyi.goods.mapper.GoodsInfoTitleMapper; |
| | | import com.ruoyi.goods.service.IGoodsInfoTitleService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | |
| | | @Service |
| | | public class GoodsInfoTitleServiceImpl extends ServiceImpl<GoodsInfoTitleMapper, GoodsInfoTitle> implements IGoodsInfoTitleService { |
| | | |
| | | /** |
| | | * 获取商品信息标题的分页数据。 |
| | | * |
| | | * @param query 查询条件,包含当前页、每页大小和标题名称等条件。 |
| | | * @return 返回商品信息标题的分页DTO,包含分页信息和转换后的VO对象列表。 |
| | | */ |
| | | @Override |
| | | public PageDTO<GoodsInfoTitleVO> getGoodsInfoTitlePage(GoodsInfoTitleQuery query) { |
| | | // 根据查询条件进行查询,包括标题名称的模糊查询,并分页 |
| | | Page<GoodsInfoTitle> page = this.lambdaQuery() |
| | | .like(StringUtils.isNotEmpty(query.getTitleName()), GoodsInfoTitle::getTitleName, |
| | | query.getTitleName()) |
| | | .page(new Page<GoodsInfoTitle>(query.getPageCurr(), query.getPageSize())); |
| | | // 将查询结果转换为VO对象的分页DTO返回 |
| | | return PageDTO.of(page, GoodsInfoTitleVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 保存或更新商品信息标题。 |
| | | * |
| | | * @param dto 商品信息标题数据传输对象,包含商品标题的信息。 如果dto中的id为空,则认为是新纪录,执行保存操作; 如果id不为空,则认为是更新现有纪录。 |
| | | * @return 无返回值。 |
| | | */ |
| | | @Override |
| | | public void saveGoodsInfoTitle(GoodsInfoTitleDTO dto) { |
| | | // 将DTO对象复制为GoodsInfoTitle实体对象 |
| | | GoodsInfoTitle goodsInfoTitle = BeanUtils.copyBean(dto, GoodsInfoTitle.class); |
| | | // 判断DTO中的ID是否为空,决定是进行保存还是更新操作 |
| | | if (StringUtils.isNull(dto.getId())) { |
| | | this.save(goodsInfoTitle); // 保存新纪录 |
| | | } else { |
| | | this.updateById(goodsInfoTitle); // 更新现有纪录 |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除商品信息标题 |
| | | * |
| | | * @param id 商品信息的唯一标识符 |
| | | * @return 无返回值 |
| | | */ |
| | | @Override |
| | | public void deleteGoodsInfoTitle(Long id) { |
| | | this.removeById(id); |
| | | } |
| | | } |