轮播图
This commit is contained in:
		| @ -0,0 +1,95 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.carousel; | ||||
|  | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import java.util.*; | ||||
| import java.io.IOException; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.carousel.CarouselDO; | ||||
| import cn.iocoder.yudao.module.member.service.carousel.CarouselService; | ||||
|  | ||||
| @Tag(name = "管理后台 - 小程序轮播图") | ||||
| @RestController | ||||
| @RequestMapping("/member/carousel") | ||||
| @Validated | ||||
| public class CarouselController { | ||||
|  | ||||
|     @Resource | ||||
|     private CarouselService carouselService; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建小程序轮播图") | ||||
|     @PreAuthorize("@ss.hasPermission('member:carousel:create')") | ||||
|     public CommonResult<Long> createCarousel(@Valid @RequestBody CarouselSaveReqVO createReqVO) { | ||||
|         return success(carouselService.createCarousel(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新小程序轮播图") | ||||
|     @PreAuthorize("@ss.hasPermission('member:carousel:update')") | ||||
|     public CommonResult<Boolean> updateCarousel(@Valid @RequestBody CarouselSaveReqVO updateReqVO) { | ||||
|         carouselService.updateCarousel(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @DeleteMapping("/delete") | ||||
|     @Operation(summary = "删除小程序轮播图") | ||||
|     @Parameter(name = "id", description = "编号", required = true) | ||||
|     @PreAuthorize("@ss.hasPermission('member:carousel:delete')") | ||||
|     public CommonResult<Boolean> deleteCarousel(@RequestParam("id") Long id) { | ||||
|         carouselService.deleteCarousel(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获得小程序轮播图") | ||||
|     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||
|     @PreAuthorize("@ss.hasPermission('member:carousel:query')") | ||||
|     public CommonResult<CarouselRespVO> getCarousel(@RequestParam("id") Long id) { | ||||
|         CarouselDO carousel = carouselService.getCarousel(id); | ||||
|         return success(BeanUtils.toBean(carousel, CarouselRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|     @Operation(summary = "获得小程序轮播图分页") | ||||
|     @PreAuthorize("@ss.hasPermission('member:carousel:query')") | ||||
|     public CommonResult<PageResult<CarouselRespVO>> getCarouselPage(@Valid CarouselPageReqVO pageReqVO) { | ||||
|         PageResult<CarouselDO> pageResult = carouselService.getCarouselPage(pageReqVO); | ||||
|         return success(BeanUtils.toBean(pageResult, CarouselRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/export-excel") | ||||
|     @Operation(summary = "导出小程序轮播图 Excel") | ||||
|     @PreAuthorize("@ss.hasPermission('member:carousel:export')") | ||||
|     @OperateLog(type = EXPORT) | ||||
|     public void exportCarouselExcel(@Valid CarouselPageReqVO pageReqVO, | ||||
|               HttpServletResponse response) throws IOException { | ||||
|         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||||
|         List<CarouselDO> list = carouselService.getCarouselPage(pageReqVO).getList(); | ||||
|         // 导出 Excel | ||||
|         ExcelUtils.write(response, "小程序轮播图.xls", "数据", CarouselRespVO.class, | ||||
|                         BeanUtils.toBean(list, CarouselRespVO.class)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,31 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.carousel.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @Schema(description = "管理后台 - 小程序轮播图分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class CarouselPageReqVO extends PageParam { | ||||
|  | ||||
|     @Schema(description = "图片名称", example = "赵六") | ||||
|     private String name; | ||||
|  | ||||
|     @Schema(description = "图片地址", example = "https://www.iocoder.cn") | ||||
|     private String url; | ||||
|  | ||||
|     @Schema(description = "0-停用,1-启用") | ||||
|     private Integer state; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,36 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.carousel.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.util.*; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
| import com.alibaba.excel.annotation.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 小程序轮播图 Response VO") | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| public class CarouselRespVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9602") | ||||
|     @ExcelProperty("编号") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "图片名称", example = "赵六") | ||||
|     @ExcelProperty("图片名称") | ||||
|     private String name; | ||||
|  | ||||
|     @Schema(description = "图片地址", example = "https://www.iocoder.cn") | ||||
|     @ExcelProperty("图片地址") | ||||
|     private String url; | ||||
|  | ||||
|     @Schema(description = "0-停用,1-启用") | ||||
|     @ExcelProperty("0-停用,1-启用") | ||||
|     private Integer state; | ||||
|  | ||||
|     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.carousel.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @Schema(description = "管理后台 - 小程序轮播图新增/修改 Request VO") | ||||
| @Data | ||||
| public class CarouselSaveReqVO { | ||||
|  | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9602") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "图片名称", example = "赵六") | ||||
|     private String name; | ||||
|  | ||||
|     @Schema(description = "图片地址", example = "https://www.iocoder.cn") | ||||
|     private String url; | ||||
|  | ||||
|     @Schema(description = "0-停用,1-启用") | ||||
|     private Integer state; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,45 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.app.carousel; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.CarouselPageReqVO; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.CarouselRespVO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.carousel.CarouselDO; | ||||
| import cn.iocoder.yudao.module.member.service.carousel.CarouselService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import javax.validation.Valid; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| @Tag(name = "用户APP - 小程序轮播图") | ||||
| @RestController | ||||
| @RequestMapping("/member/carousel") | ||||
| @Validated | ||||
| public class AppCarouselController { | ||||
|  | ||||
|     @Resource | ||||
|     private CarouselService carouselService; | ||||
|  | ||||
|  | ||||
|     @GetMapping("/list") | ||||
|     @Operation(summary = "获得小程序轮播图") | ||||
|     public CommonResult<PageResult<CarouselRespVO>> getCarouselPage() { | ||||
|         CarouselPageReqVO pageReqVO = new CarouselPageReqVO(); | ||||
|         pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||||
|         pageReqVO.setState(1); | ||||
|         PageResult<CarouselDO> pageResult = carouselService.getCarouselPage(pageReqVO); | ||||
|         return success(BeanUtils.toBean(pageResult, CarouselRespVO.class)); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,43 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.dataobject.carousel; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalDateTime; | ||||
| import com.baomidou.mybatisplus.annotation.*; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
|  | ||||
| /** | ||||
|  * 小程序轮播图 DO | ||||
|  * | ||||
|  * @author 秦俊旗 | ||||
|  */ | ||||
| @TableName("member_carousel") | ||||
| @KeySequence("member_carousel_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class CarouselDO extends BaseDO { | ||||
|  | ||||
|     /** | ||||
|      * 编号 | ||||
|      */ | ||||
|     @TableId | ||||
|     private Long id; | ||||
|     /** | ||||
|      * 图片名称 | ||||
|      */ | ||||
|     private String name; | ||||
|     /** | ||||
|      * 图片地址 | ||||
|      */ | ||||
|     private String url; | ||||
|     /** | ||||
|      * 0-停用,1-启用 | ||||
|      */ | ||||
|     private Integer state; | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,29 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.mysql.carousel; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.carousel.CarouselDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.*; | ||||
|  | ||||
| /** | ||||
|  * 小程序轮播图 Mapper | ||||
|  * | ||||
|  * @author 秦俊旗 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface CarouselMapper extends BaseMapperX<CarouselDO> { | ||||
|  | ||||
|     default PageResult<CarouselDO> selectPage(CarouselPageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<CarouselDO>() | ||||
|                 .likeIfPresent(CarouselDO::getName, reqVO.getName()) | ||||
|                 .eqIfPresent(CarouselDO::getUrl, reqVO.getUrl()) | ||||
|                 .eqIfPresent(CarouselDO::getState, reqVO.getState()) | ||||
|                 .betweenIfPresent(CarouselDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(CarouselDO::getId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,55 @@ | ||||
| package cn.iocoder.yudao.module.member.service.carousel; | ||||
|  | ||||
| import java.util.*; | ||||
| import javax.validation.*; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.carousel.CarouselDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
|  | ||||
| /** | ||||
|  * 小程序轮播图 Service 接口 | ||||
|  * | ||||
|  * @author 秦俊旗 | ||||
|  */ | ||||
| public interface CarouselService { | ||||
|  | ||||
|     /** | ||||
|      * 创建小程序轮播图 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createCarousel(@Valid CarouselSaveReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新小程序轮播图 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateCarousel(@Valid CarouselSaveReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除小程序轮播图 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteCarousel(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得小程序轮播图 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 小程序轮播图 | ||||
|      */ | ||||
|     CarouselDO getCarousel(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得小程序轮播图分页 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 小程序轮播图分页 | ||||
|      */ | ||||
|     PageResult<CarouselDO> getCarouselPage(CarouselPageReqVO pageReqVO); | ||||
|  | ||||
| } | ||||
| @ -0,0 +1,74 @@ | ||||
| package cn.iocoder.yudao.module.member.service.carousel; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import java.util.*; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.carousel.vo.*; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.carousel.CarouselDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.module.member.dal.mysql.carousel.CarouselMapper; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 小程序轮播图 Service 实现类 | ||||
|  * | ||||
|  * @author 秦俊旗 | ||||
|  */ | ||||
| @Service | ||||
| @Validated | ||||
| public class CarouselServiceImpl implements CarouselService { | ||||
|  | ||||
|     @Resource | ||||
|     private CarouselMapper carouselMapper; | ||||
|  | ||||
|     @Override | ||||
|     public Long createCarousel(CarouselSaveReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         CarouselDO carousel = BeanUtils.toBean(createReqVO, CarouselDO.class); | ||||
|         carouselMapper.insert(carousel); | ||||
|         // 返回 | ||||
|         return carousel.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateCarousel(CarouselSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateCarouselExists(updateReqVO.getId()); | ||||
|         // 更新 | ||||
|         CarouselDO updateObj = BeanUtils.toBean(updateReqVO, CarouselDO.class); | ||||
|         carouselMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteCarousel(Long id) { | ||||
|         // 校验存在 | ||||
|         validateCarouselExists(id); | ||||
|         // 删除 | ||||
|         carouselMapper.deleteById(id); | ||||
|     } | ||||
|  | ||||
|     private void validateCarouselExists(Long id) { | ||||
|         if (carouselMapper.selectById(id) == null) { | ||||
|             throw exception(CAROUSEL_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public CarouselDO getCarousel(Long id) { | ||||
|         return carouselMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<CarouselDO> getCarouselPage(CarouselPageReqVO pageReqVO) { | ||||
|         return carouselMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -610,6 +610,7 @@ public class StoreOrderServiceImpl implements StoreOrderService { | ||||
|             GoodsInfoReqVO vo = new GoodsInfoReqVO(); | ||||
|             BeanUtil.copyProperties(detail,vo); | ||||
|             vo.setCarteenId(storeOrderDO.getCarteenId()); | ||||
|             vo.setWeight(0D); | ||||
|             infos.add(vo); | ||||
|         } | ||||
|         addReqVO.setList(infos); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 seesaw
					seesaw