Browse Source

2.0.0 新增轮播图,土地报告管理接口

feature/v.2.0.0
peihao 4 years ago
parent
commit
947e6a8cfa
  1. 41
      air/src/main/java/com/air/cityarea/controller/ReportController.java
  2. 28
      air/src/main/java/com/air/cityarea/controller/RotateGroupController.java
  3. 58
      air/src/main/java/com/air/cityarea/controller/RotateImageController.java
  4. 9
      air/src/main/java/com/air/cityarea/entity/Report.java
  5. 10
      air/src/main/java/com/air/cityarea/entity/RotateImage.java
  6. 28
      air/src/main/java/com/air/cityarea/vo/RotateImageStatusVo.java
  7. 42
      air/src/main/java/com/air/enums/ReportStatusEnum.java
  8. 42
      air/src/main/java/com/air/enums/ReportTypeEnum.java
  9. 42
      air/src/main/java/com/air/enums/RotateStatusEnum.java

41
air/src/main/java/com/air/cityarea/controller/ReportController.java

@ -1,5 +1,10 @@
package com.air.cityarea.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.air.enums.ReportStatusEnum;
import com.air.enums.ReportTypeEnum;
import com.air.utils.FileUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cinderella.framework.common.core.util.R;
@ -11,6 +16,8 @@ import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 土地报告
@ -26,6 +33,8 @@ public class ReportController {
private final ReportService reportService;
private final FileUtil fileUtil;
/**
* 分页查询
* @param page 分页对象
@ -35,7 +44,18 @@ public class ReportController {
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page")
public R getReportPage(QueryPage page, Report report) {
return R.ok(reportService.page(page.toPage(), Wrappers.query(report)));
Page<Report> reportPage = reportService.page(page.toPage(), Wrappers.<Report>query().lambda()
.eq(StrUtil.isNotEmpty(report.getReportType()),Report::getReportType,report.getReportType())
.like(StrUtil.isNotEmpty(report.getReportName()),Report::getReportName,report.getReportName())
.orderByDesc(Report::getCreateDate));
if (CollectionUtil.isNotEmpty(reportPage.getRecords())){
reportPage.getRecords().stream().forEach(e -> {
e.setFilePath(fileUtil.getUrlByInnerPath(e.getFilePath()));
e.setReportType(ReportTypeEnum.getName(e.getReportType()));
e.setStatusName(ReportStatusEnum.getName(e.getStatusCd()));
});
}
return R.ok(reportPage);
}
@ -47,7 +67,12 @@ public class ReportController {
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{id}")
public R getById(@PathVariable("id") Long id) {
return R.ok(reportService.getById(id));
Report report = reportService.getById(id);
if(report == null ){
return R.failed("id正确");
}
report.setReportType(ReportTypeEnum.getName(report.getReportType()));
return R.ok(report);
}
/**
@ -69,17 +94,21 @@ public class ReportController {
@ApiOperation(value = "修改土地报告", notes = "修改土地报告")
@PutMapping
public R updateById(@RequestBody Report report) {
if (report.getId() == null){
return R.failed("id不能为空");
}
fileUtil.getInnerPath(report.getFilePath());
return R.ok(reportService.updateById(report));
}
/**
* 通过id删除土地报告
* @param id id
* @param ids ids
* @return R
*/
@ApiOperation(value = "通过id删除土地报告", notes = "通过id删除土地报告")
@DeleteMapping("/{id}")
public R removeById(@PathVariable Long id) {
return R.ok(reportService.removeById(id));
@DeleteMapping("deleteByIds")
public R removeById(@RequestParam List<Long> ids) {
return R.ok(reportService.removeByIds(ids));
}
}

28
air/src/main/java/com/air/cityarea/controller/RotateGroupController.java

@ -1,5 +1,7 @@
package com.air.cityarea.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cinderella.framework.common.core.util.R;
@ -11,6 +13,10 @@ import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 轮播分组
@ -20,8 +26,8 @@ import org.springframework.web.bind.annotation.*;
*/
@RestController
@AllArgsConstructor
@RequestMapping("/rotategroup")
@Api(value = "rotategroup", tags = "轮播分组管理")
@RequestMapping("/rotateGroup")
@Api(value = "rotateGroup", tags = "轮播分组管理")
public class RotateGroupController {
private final RotateGroupService rotateGroupService;
@ -34,10 +40,24 @@ public class RotateGroupController {
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page")
public R getRotateGroupPage(QueryPage page, RotateGroup rotateGroup) {
public R<IPage<RotateGroup>> getRotateGroupPage(QueryPage page, RotateGroup rotateGroup) {
return R.ok(rotateGroupService.page(page.toPage(), Wrappers.query(rotateGroup)));
}
/**
* 查询分组
* @return R
*/
@ApiOperation(value = "查询分组", notes = "查询分组")
@GetMapping("getGroupName")
public R<Map<Long,String>> getGroupName() {
List<RotateGroup> list = rotateGroupService.list();
if (CollectionUtil.isNotEmpty(list)){
return R.ok(list.stream().collect(Collectors.toMap(RotateGroup::getGroupId, RotateGroup::getGroupName)),"查询成功");
}
return R.ok();
}
/**
* 通过id查询轮播分组
@ -46,7 +66,7 @@ public class RotateGroupController {
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{groupId}")
public R getById(@PathVariable("groupId") Long groupId) {
public R<RotateGroup> getById(@PathVariable("groupId") Long groupId) {
return R.ok(rotateGroupService.getById(groupId));
}

58
air/src/main/java/com/air/cityarea/controller/RotateImageController.java

@ -1,5 +1,10 @@
package com.air.cityarea.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.air.cityarea.vo.RotateImageStatusVo;
import com.air.enums.RotateStatusEnum;
import com.air.utils.FileUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cinderella.framework.common.core.util.R;
@ -9,8 +14,11 @@ import com.air.cityarea.service.RotateImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 轮播图片
@ -20,22 +28,33 @@ import org.springframework.web.bind.annotation.*;
*/
@RestController
@AllArgsConstructor
@RequestMapping("/rotateimage")
@Api(value = "rotateimage", tags = "轮播图片管理")
@RequestMapping("/rotateImage")
@Api(value = "rotateImage", tags = "轮播图片管理")
public class RotateImageController {
private final RotateImageService rotateImageService;
private final FileUtil fileUtil;
/**
* 分页查询
* @param page 分页对象
* @param rotateImage 轮播图片
* @param image 轮播图片
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page")
public R getRotateImagePage(QueryPage page, RotateImage rotateImage) {
return R.ok(rotateImageService.page(page.toPage(), Wrappers.query(rotateImage)));
public R getRotateImagePage(QueryPage page, RotateImage image) {
Page<RotateImage> rotateImagePage = rotateImageService.page(page.toPage(), Wrappers.<RotateImage>query().lambda()
.eq(StrUtil.isNotEmpty(image.getStatusCd()),RotateImage::getStatusCd,image.getStatusCd())
.eq(image.getGroupId() != null,RotateImage::getGroupId,image.getGroupId())
.like(StrUtil.isNotEmpty(image.getImageName()),RotateImage::getImageName,image.getImageName())
.orderByDesc(RotateImage::getCreateDate));
rotateImagePage.getRecords().stream().forEach(e ->{
e.setImagePath(fileUtil.getUrlByInnerPath(e.getImagePath()));
e.setStatusName(RotateStatusEnum.getName(e.getStatusCd()));
});
return R.ok(rotateImagePage);
}
@ -57,7 +76,7 @@ public class RotateImageController {
*/
@ApiOperation(value = "新增轮播图片", notes = "新增轮播图片")
@PostMapping
public R save(@RequestBody RotateImage rotateImage) {
public R save(@RequestBody @Validated RotateImage rotateImage) {
return R.ok(rotateImageService.save(rotateImage));
}
@ -68,18 +87,35 @@ public class RotateImageController {
*/
@ApiOperation(value = "修改轮播图片", notes = "修改轮播图片")
@PutMapping
public R updateById(@RequestBody RotateImage rotateImage) {
public R updateById(@RequestBody @Validated RotateImage rotateImage) {
if (rotateImage.getId() == null){
return R.failed("id不能为空");
}
rotateImage.setImagePath(fileUtil.getInnerPath(rotateImage.getImagePath()));
return R.ok(rotateImageService.updateById(rotateImage));
}
/**
* 修改轮播图状态
* @param statusVo
* @return R
*/
@ApiOperation(value = "修改轮播图状态", notes = "修改轮播图状态")
@PutMapping("updateStatus")
public R updateStatus(@RequestBody @Validated RotateImageStatusVo statusVo) {
RotateImage rotateImage = new RotateImage();
BeanUtil.copyProperties(statusVo,rotateImage);
return R.ok(rotateImageService.updateById(rotateImage));
}
/**
* 通过id删除轮播图片
* @param id id
* @param ids ids
* @return R
*/
@ApiOperation(value = "通过id删除轮播图片", notes = "通过id删除轮播图片")
@DeleteMapping("/{id}")
public R removeById(@PathVariable Long id) {
return R.ok(rotateImageService.removeById(id));
@DeleteMapping("deleteByIds")
public R deleteByIds(@RequestParam List<Long> ids) {
return R.ok(rotateImageService.removeByIds(ids));
}
}

9
air/src/main/java/com/air/cityarea/entity/Report.java

@ -1,5 +1,6 @@
package com.air.cityarea.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@ -7,6 +8,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.context.annotation.Conditional;
import java.io.Serializable;
import java.time.LocalDateTime;
@ -35,7 +38,7 @@ public class Report extends Model<Report> {
private String fileType;
@ApiModelProperty(value="文件地址")
private String filePath;
@ApiModelProperty(value="状态")
@ApiModelProperty(value="状态(1000:保存(下架),1100:发布(推荐)")
private String statusCd;
@ApiModelProperty(value="状态时间")
private LocalDateTime statusDate;
@ -49,4 +52,8 @@ public class Report extends Model<Report> {
private LocalDateTime updateDate;
@ApiModelProperty(value="备注")
private String remark;
@TableField(exist = false)
@ApiModelProperty(value="状态名称(1000:保存(下架),1100:发布(推荐)")
private String statusName;
}

10
air/src/main/java/com/air/cityarea/entity/RotateImage.java

@ -1,5 +1,6 @@
package com.air.cityarea.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
@ -7,6 +8,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
@ -27,12 +31,15 @@ public class RotateImage extends Model<RotateImage> {
@TableId
@ApiModelProperty(value="主键")
private Long id;
@NotNull(message = "分组不能为空")
@ApiModelProperty(value="分组id")
private Long groupId;
@NotBlank(message = "图片名称不能为空")
@ApiModelProperty(value="图片名称")
private String imageName;
@ApiModelProperty(value="图片地址")
private String imagePath;
@NotNull(message = "排序不能为空")
@ApiModelProperty(value="排序")
private Integer sort;
@ApiModelProperty(value="状态")
@ -49,4 +56,7 @@ public class RotateImage extends Model<RotateImage> {
private LocalDateTime updateDate;
@ApiModelProperty(value="备注")
private String remark;
@TableField(exist = false)
@ApiModelProperty(value="状态名称(显示用)")
private String statusName;
}

28
air/src/main/java/com/air/cityarea/vo/RotateImageStatusVo.java

@ -0,0 +1,28 @@
package com.air.cityarea.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 轮播图片
*
* @author peihao
* @date 2021-10-08 17:24:48
*/
@Data
@ApiModel
public class RotateImageStatusVo {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空")
@ApiModelProperty(value = "id")
private Long id;
@NotBlank(message = "状态不能为空")
@ApiModelProperty(value = "状态")
private String statusCd;
}

42
air/src/main/java/com/air/enums/ReportStatusEnum.java

@ -0,0 +1,42 @@
package com.air.enums;
import java.util.Arrays;
import java.util.Optional;
/**
* 土地报告类型
*
* @author peihao
* @date 2021-05-20
**/
public enum ReportStatusEnum {
REPORT_1000("1000","下架"),
REPORT_1100("1100","推荐");
private final String code;
private final String name;
ReportStatusEnum(String code, String name){
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
public static String getName(String code){
Optional<ReportStatusEnum> typeEnum = Arrays.stream(ReportStatusEnum.values()).filter(e -> e.getCode().equals(code)).findAny();
if (typeEnum.isPresent()){
return typeEnum.get().getName();
}
return null;
}
}

42
air/src/main/java/com/air/enums/ReportTypeEnum.java

@ -0,0 +1,42 @@
package com.air.enums;
import java.util.Arrays;
import java.util.Optional;
/**
* 土地报告类型
*
* @author peihao
* @date 2021-05-20
**/
public enum ReportTypeEnum {
PROMOTION_REPORT("promotionReport","土地推介"),
RESEARCH_REPORT("researchReport","研究报告");
private final String code;
private final String name;
ReportTypeEnum(String code, String name){
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
public static String getName(String code){
Optional<ReportTypeEnum> typeEnum = Arrays.stream(ReportTypeEnum.values()).filter(e -> e.getCode().equals(code)).findAny();
if (typeEnum.isPresent()){
return typeEnum.get().getName();
}
return null;
}
}

42
air/src/main/java/com/air/enums/RotateStatusEnum.java

@ -0,0 +1,42 @@
package com.air.enums;
import java.util.Arrays;
import java.util.Optional;
/**
* 轮播图状态
*
* @author peihao
* @date 2021-05-20
**/
public enum RotateStatusEnum {
ROTATE_1000("1000","发布"),
ROTATE_1100("1100","禁用");
private final String code;
private final String name;
RotateStatusEnum(String code, String name){
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
public static String getName(String code){
Optional<RotateStatusEnum> statusEnum = Arrays.stream(RotateStatusEnum.values()).filter(e -> e.getCode().equals(code)).findAny();
if (statusEnum.isPresent()){
return statusEnum.get().getName();
}
return null;
}
}
Loading…
Cancel
Save