|
|
@@ -0,0 +1,68 @@
|
|
|
+package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.CarouselImagesDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.CarouselImagesModifyParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.CarouselImagesPagingParam;
|
|
|
+import com.chelvc.cloud.vehicle.server.copier.CarouselImagesCopier;
|
|
|
+import com.chelvc.cloud.vehicle.server.dao.CarouselImagesMapper;
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.CarouselImages;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.CarouselImagesService;
|
|
|
+import com.chelvc.framework.base.util.ResourceUtils;
|
|
|
+import com.chelvc.framework.common.model.Pagination;
|
|
|
+import com.chelvc.framework.common.util.StringUtils;
|
|
|
+import com.chelvc.framework.database.util.PagingUtils;
|
|
|
+import lombok.NonNull;
|
|
|
+import org.apache.dubbo.config.annotation.DubboService;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 轮播图业务操作实现
|
|
|
+ *
|
|
|
+ * @author liude
|
|
|
+ * @date 2023/12/16
|
|
|
+ */
|
|
|
+@DubboService(interfaceClass = com.chelvc.cloud.vehicle.api.service.CarouselImagesService.class)
|
|
|
+public class CarouselImagesServiceImpl extends ServiceImpl<CarouselImagesMapper, CarouselImages> implements CarouselImagesService,
|
|
|
+ com.chelvc.cloud.vehicle.api.service.CarouselImagesService {
|
|
|
+ @Override
|
|
|
+ public Long addCarouselImages(@NonNull CarouselImagesModifyParam param) {
|
|
|
+ Integer count = this.lambdaQuery().eq(CarouselImages::getTitle, param.getTitle()).count();
|
|
|
+ ResourceUtils.available(count <= 0, "该轮播图已存在");
|
|
|
+ CarouselImages carouselImages = CarouselImagesCopier.INSTANCE.copying(param);
|
|
|
+ this.save(carouselImages);
|
|
|
+ return carouselImages.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateCarouselImages(@NonNull Long id, @NonNull CarouselImagesModifyParam param) {
|
|
|
+ CarouselImages carouselImages = ResourceUtils.required(this.getById(id), "该轮播图不存在");
|
|
|
+ CarouselImagesCopier.INSTANCE.copying(param, carouselImages);
|
|
|
+ this.updateById(carouselImages);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Pagination<CarouselImagesDTO> getCarouselImagesPaging(@NonNull CarouselImagesPagingParam param) {
|
|
|
+ Page<CarouselImages> page = this.lambdaQuery()
|
|
|
+ .like(StringUtils.nonEmpty(param.getTitle()), CarouselImages::getTitle, param.getTitle())
|
|
|
+ .eq(Objects.nonNull(param.getStatus()), CarouselImages::getStatus, param.getStatus())
|
|
|
+ .orderByAsc(CarouselImages::getSeq).page(PagingUtils.convert(param.getPaging()));
|
|
|
+ return PagingUtils.convert(page, CarouselImagesCopier.INSTANCE::copying);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deleteCarouselImages(Long id){
|
|
|
+ ResourceUtils.required(this.getById(id), "该轮播图存在");
|
|
|
+ this.baseMapper.deleteById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<CarouselImagesDTO> listCarouselImages(){
|
|
|
+ List<CarouselImages> carouselImagesList = this.lambdaQuery()
|
|
|
+ .eq(CarouselImages::getStatus, "1")
|
|
|
+ .orderByAsc(CarouselImages::getSeq).list();
|
|
|
+ return CarouselImagesCopier.INSTANCE.copying(carouselImagesList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|