| | |
| | | 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.GoodsBrandDTO; |
| | | import com.ruoyi.goods.controller.mamagement.DTO.GoodsBrandQuery; |
| | | import com.ruoyi.goods.controller.mamagement.VO.GoodsBrandVO; |
| | | import com.ruoyi.goods.domain.pojo.GoodsBrand; |
| | | import com.ruoyi.goods.domain.vo.GoodsBrandVO; |
| | | import com.ruoyi.goods.mapper.GoodsBrandMapper; |
| | | import com.ruoyi.goods.service.IGoodsBrandService; |
| | | import java.util.List; |
| | |
| | | return BeanUtils.copyList(this.list(), GoodsBrandVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取商品品牌的分页信息 |
| | | * |
| | | * @param query 包含查询条件和分页信息的查询对象 |
| | | * @return 返回商品品牌分页DTO,包含分页信息和品牌列表 |
| | | */ |
| | | @Override |
| | | public PageDTO<GoodsBrandVO> getGoodsBrandPage(GoodsBrandQuery query) { |
| | | // 根据查询条件进行品牌查询,并分页 |
| | | Page<GoodsBrand> page = this.lambdaQuery() |
| | | .like(StringUtils.isNotEmpty(query.getBrandName()), GoodsBrand::getBrandName, |
| | | query.getBrandName()) |
| | | .page(new Page<GoodsBrand>(query.getPageCurr(), query.getPageSize())); |
| | | |
| | | // 将查询结果转换为VO类的分页DTO |
| | | return PageDTO.of(page, GoodsBrandVO.class); |
| | | } |
| | | |
| | | /** |
| | | * 保存或更新商品品牌信息。 |
| | | * |
| | | * @param dto 商品品牌数据传输对象,包含商品品牌的信息。 如果dto中的id为空,则认为是新品牌,调用save方法保存; |
| | | * 如果id不为空,则认为是更新已有品牌,调用updateById方法更新。 |
| | | * @return 无返回值 |
| | | */ |
| | | @Override |
| | | public void saveGoodsBrand(GoodsBrandDTO dto) { |
| | | // 将DTO对象复制到实体对象中 |
| | | GoodsBrand goodsBrand = BeanUtils.copyBean(dto, GoodsBrand.class); |
| | | // 判断DTO中的ID是否为空,决定是保存还是更新操作 |
| | | if (StringUtils.isNull(dto.getId())) { |
| | | this.save(goodsBrand); // 保存新品牌 |
| | | } else { |
| | | this.updateById(goodsBrand); // 更新已有品牌 |
| | | } |
| | | } |
| | | |
| | | } |