Browse Source

2.0.0 新增小程序端轮播图接口

feature/v.2.0.0
peihao 3 years ago
parent
commit
37748bd241
  1. 71
      air/src/main/java/com/air/applets/controller/RotateImageController.java
  2. 34
      air/src/main/java/com/air/applets/dto/RotateImageDto.java

71
air/src/main/java/com/air/applets/controller/RotateImageController.java

@ -0,0 +1,71 @@
package com.air.applets.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.air.applets.dto.RotateImageDto;
import com.air.cityarea.entity.RotateGroup;
import com.air.cityarea.entity.RotateImage;
import com.air.cityarea.service.RotateGroupService;
import com.air.cityarea.service.RotateImageService;
import com.air.enums.RotateStatusEnum;
import com.air.utils.FileUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.cinderella.framework.common.core.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 小程序轮播图管理
*
* @author peihao
* @date 2021-10-08 17:24:48
*/
@RestController("applets_rotateImage")
@AllArgsConstructor
@RequestMapping("/applets/rotateImage")
@Api(value = "rotateImage", tags = "小程序轮播图管理")
public class RotateImageController {
private final RotateImageService rotateImageService;
private final RotateGroupService rotateGroupService;
private final FileUtil fileUtil;
@ApiOperation(value = "查询轮播图", notes = "查询轮播图")
@GetMapping("/getRotateImages")
public R<RotateImageDto> getRotateImages(Long groupId, String groupCode) {
if (StrUtil.isEmpty(groupCode) && groupId == null) {
return R.failed("分组id和分组编码至少传1个");
}
RotateGroup group;
if (groupId == null) {
group = rotateGroupService.getOne(Wrappers.<RotateGroup>query().lambda().eq(RotateGroup::getGroupCode, groupCode));
} else {
group = rotateGroupService.getById(groupId);
}
if (group == null) {
return R.ok(null, "未查询到数据");
}
List<RotateImage> list = rotateImageService.list(Wrappers.<RotateImage>query().lambda()
.eq(RotateImage::getGroupId, group.getGroupId()).orderByDesc(RotateImage::getCreateDate));
if (CollectionUtil.isNotEmpty(list)) {
list.stream().forEach(e -> {
e.setImagePath(fileUtil.getUrlByInnerPath(e.getImagePath()));
e.setStatusName(RotateStatusEnum.getName(e.getStatusCd()));
});
}
RotateImageDto rotateImageDto = new RotateImageDto();
BeanUtil.copyProperties(group, rotateImageDto);
rotateImageDto.setRotateImageList(list);
return R.ok(rotateImageDto, "查询成功");
}
}

34
air/src/main/java/com/air/applets/dto/RotateImageDto.java

@ -0,0 +1,34 @@
package com.air.applets.dto;
import com.air.cityarea.entity.RotateImage;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 轮播图片
*
* @author peihao
* @date 2021-10-08 17:24:48
*/
@Data
@ApiModel(value = "轮播图")
public class RotateImageDto extends Model<RotateImageDto> {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long groupId;
@ApiModelProperty(value = "分组编码")
private String groupCode;
@ApiModelProperty(value = "分组名称")
private String groupName;
@ApiModelProperty(value = "切换时间(毫秒)")
private Long time;
@ApiModelProperty(value = "轮播图数据")
private List<RotateImage> rotateImageList;
}
Loading…
Cancel
Save