10 changed files with 283 additions and 8 deletions
			
			
		| @ -0,0 +1,25 @@ | ||||
| package com.hnac.hzims.operational.station.entity; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.experimental.Accessors; | ||||
| import org.springblade.core.tenant.mp.TenantEntity; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * @author ysj | ||||
|  */ | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = false) | ||||
| @Accessors(chain = true) | ||||
| @TableName("hzims_station_video_carousel") | ||||
| public class VideoCarouselEntity extends TenantEntity { | ||||
| 
 | ||||
|     @ApiModelProperty("视频保存配置ID") | ||||
|     private String carouselId; | ||||
| 
 | ||||
|     @ApiModelProperty("视频保存名称") | ||||
|     private String carouselName; | ||||
| } | ||||
| @ -0,0 +1,32 @@ | ||||
| package com.hnac.hzims.operational.station.vo; | ||||
| 
 | ||||
| import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; | ||||
| import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * @author ysj | ||||
|  */ | ||||
| @Data | ||||
| @ApiModel("视频轮播配置响应对象") | ||||
| public class StationVideoCarouselVO { | ||||
| 
 | ||||
|     @ApiModelProperty("站点ID") | ||||
|     private String stationId; | ||||
| 
 | ||||
|     @ApiModelProperty("站点名称") | ||||
|     private String stationName; | ||||
| 
 | ||||
|     @ApiModelProperty("视频保存配置ID") | ||||
|     private String carouselId; | ||||
| 
 | ||||
|     @ApiModelProperty("视频保存名称") | ||||
|     private String carouselName; | ||||
| 
 | ||||
|     @ApiModelProperty("视频播放记录") | ||||
|     private List<StationVideoTypeEntity> videoTypes; | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,19 @@ | ||||
| package com.hnac.hzims.operational.station.vo; | ||||
| 
 | ||||
| import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| 
 | ||||
| /** | ||||
|  * @author ysj | ||||
|  */ | ||||
| @Data | ||||
| @ApiModel("视频轮播配置响应对象") | ||||
| public class StationVideoConfigPointVO { | ||||
| 
 | ||||
|     @ApiModelProperty("视频点位id") | ||||
|     private Long id; | ||||
| 
 | ||||
|     @ApiModelProperty("视频点位名称") | ||||
|     private String name; | ||||
| } | ||||
| @ -0,0 +1,24 @@ | ||||
| package com.hnac.hzims.operational.station.vo; | ||||
| 
 | ||||
| import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * @author ysj | ||||
|  */ | ||||
| @Data | ||||
| @ApiModel("视频轮播配置响应对象") | ||||
| public class StationVideoConfigVO { | ||||
| 
 | ||||
|     @ApiModelProperty("站点ID") | ||||
|     private String name; | ||||
| 
 | ||||
|     @ApiModelProperty("站点名称") | ||||
|     private String layout; | ||||
| 
 | ||||
|     @ApiModelProperty("视频保存配置ID") | ||||
|     private List<StationVideoConfigPointVO> stations; | ||||
| } | ||||
| @ -0,0 +1,43 @@ | ||||
| package com.hnac.hzims.operational.station.controller; | ||||
| 
 | ||||
| import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; | ||||
| import com.hnac.hzims.operational.station.entity.VideoCarouselEntity; | ||||
| import com.hnac.hzims.operational.station.service.VideoCarouselService; | ||||
| import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.springblade.core.boot.ctrl.BladeController; | ||||
| import org.springblade.core.tool.api.R; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| 
 | ||||
| import javax.validation.Valid; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * @author ysj | ||||
|  */ | ||||
| @RestController | ||||
| @RequestMapping("/station/carouselRecord") | ||||
| @RequiredArgsConstructor | ||||
| @Api(value = "站点视频轮播保存记录", tags = "视频轮播保存记录") | ||||
| public class StationVideoCarouselController extends BladeController { | ||||
| 
 | ||||
|     private final VideoCarouselService videoCarouselService; | ||||
| 
 | ||||
|     @PostMapping("/submit") | ||||
|     @ApiOperationSupport(order = 1) | ||||
|     @ApiOperation(value = "新增或修改站点视频轮播保存记录", notes = "传入VideoRecordEntity") | ||||
|     public R submit(@Valid @RequestBody VideoCarouselEntity entity) { | ||||
|         return R.status(videoCarouselService.submit(entity)); | ||||
|     } | ||||
| 
 | ||||
|     @GetMapping("/query") | ||||
|     @ApiOperationSupport(order = 2) | ||||
|     @ApiOperation(value = "查询站点视频轮播保存记录", notes = "传入VideoRecordEntity") | ||||
|     public R query(@RequestParam("stationId") String stationId, | ||||
|                    @RequestParam("userId") String userId) { | ||||
|         return R.data(videoCarouselService.videoCarousel(stationId,userId)); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,13 @@ | ||||
| package com.hnac.hzims.operational.station.mapper; | ||||
| 
 | ||||
| import com.hnac.hzims.operational.station.entity.VideoCarouselEntity; | ||||
| import com.hnac.hzims.operational.station.entity.VideoRecordEntity; | ||||
| import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * @author ysj | ||||
|  */ | ||||
| public interface VideoCarouselMapper extends UserDataScopeBaseMapper<VideoCarouselEntity> { | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,6 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.hnac.hzims.operational.station.mapper.VideoCarouselMapper"> | ||||
| 
 | ||||
| 
 | ||||
| </mapper> | ||||
| @ -0,0 +1,14 @@ | ||||
| package com.hnac.hzims.operational.station.service; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import com.hnac.hzims.operational.station.entity.VideoCarouselEntity; | ||||
| import com.hnac.hzims.operational.station.vo.StationVideoCarouselVO; | ||||
| 
 | ||||
| /** | ||||
|  * @author ysj | ||||
|  */ | ||||
| public interface VideoCarouselService extends IService<VideoCarouselEntity> { | ||||
|     boolean submit(VideoCarouselEntity entity); | ||||
| 
 | ||||
|     StationVideoCarouselVO videoCarousel(String stationId, String userId); | ||||
| } | ||||
| @ -0,0 +1,102 @@ | ||||
| package com.hnac.hzims.operational.station.service.impl; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | ||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; | ||||
| import com.hnac.hzims.operational.station.entity.VideoCarouselEntity; | ||||
| import com.hnac.hzims.operational.station.entity.VideoConfigEntity; | ||||
| import com.hnac.hzims.operational.station.entity.VideoRecordEntity; | ||||
| import com.hnac.hzims.operational.station.mapper.VideoCarouselMapper; | ||||
| import com.hnac.hzims.operational.station.service.IStationVideoTypeService; | ||||
| import com.hnac.hzims.operational.station.service.VideoCarouselService; | ||||
| import com.hnac.hzims.operational.station.service.VideoConfigService; | ||||
| import com.hnac.hzims.operational.station.vo.StationVideoCarouselVO; | ||||
| import com.hnac.hzims.operational.station.vo.StationVideoConfigVO; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springblade.core.secure.utils.AuthUtil; | ||||
| import org.springblade.core.tool.api.R; | ||||
| import org.springblade.core.tool.utils.CollectionUtil; | ||||
| import org.springblade.core.tool.utils.ObjectUtil; | ||||
| import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * @author 86187 | ||||
|  */ | ||||
| @Service | ||||
| @RequiredArgsConstructor | ||||
| @Slf4j | ||||
| public class VideoCarouselServiceImpl extends ServiceImpl<VideoCarouselMapper, VideoCarouselEntity> implements VideoCarouselService { | ||||
| 
 | ||||
|     private final VideoConfigService videoConfigService; | ||||
| 
 | ||||
|     private final IStationVideoTypeService stationVideoTypeService; | ||||
| 
 | ||||
|     /** | ||||
|      * 视频配置记录提交 | ||||
|      * @param entity | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public boolean submit(VideoCarouselEntity entity) { | ||||
|         // 根据用户,站点查询历史配置记录
 | ||||
|         VideoCarouselEntity videoCarousel = this.getOne(Wrappers.<VideoCarouselEntity>lambdaQuery() | ||||
|                 .eq(VideoCarouselEntity::getCreateUser,AuthUtil.getUserId()) | ||||
|         ); | ||||
|         if(ObjectUtils.isEmpty(videoCarousel)){ | ||||
|            return this.save(entity); | ||||
|         } | ||||
|         entity.setId(videoCarousel.getId()); | ||||
|         return this.updateById(entity); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 查询视频轮播保存记录 | ||||
|      * @param stationId | ||||
|      * @param userId | ||||
|      * @return | ||||
|      */ | ||||
|     @Override | ||||
|     public StationVideoCarouselVO videoCarousel(String stationId, String userId) { | ||||
|         VideoCarouselEntity videoCarousel = this.getOne(Wrappers.<VideoCarouselEntity>lambdaQuery() | ||||
|                 .eq(VideoCarouselEntity::getCreateUser,userId) | ||||
|         ); | ||||
|         if(ObjectUtil.isEmpty(videoCarousel)){ | ||||
|             return new StationVideoCarouselVO(); | ||||
|         } | ||||
|         StationVideoCarouselVO carousel = new StationVideoCarouselVO(); | ||||
|         carousel.setCarouselId(videoCarousel.getCarouselId()); | ||||
|         carousel.setCarouselName(videoCarousel.getCarouselName()); | ||||
| 
 | ||||
|         // 查询视频轮播记录
 | ||||
|         VideoConfigEntity config = videoConfigService.getById(carousel.getCarouselId()); | ||||
|         if(ObjectUtil.isEmpty(config)){ | ||||
|             return carousel; | ||||
|         } | ||||
|         List<StationVideoConfigVO> childs = JSONObject.parseArray(config.getConfigEntity(),StationVideoConfigVO.class); | ||||
|         if(CollectionUtil.isEmpty(childs)){ | ||||
|             return carousel; | ||||
|         } | ||||
|         List<StationVideoTypeEntity> videoTypes = new ArrayList<>(); | ||||
|         childs.forEach(child->{ | ||||
|             if(CollectionUtil.isEmpty(childs)){ | ||||
|                 return; | ||||
|             } | ||||
|             child.getStations().forEach(station->{ | ||||
|                 StationVideoTypeEntity videoType = stationVideoTypeService.getById(station.getId()); | ||||
|                 if(ObjectUtil.isEmpty(videoType)){ | ||||
|                     return; | ||||
|                 } | ||||
|                 videoTypes.add(videoType); | ||||
|             }); | ||||
|         }); | ||||
|         carousel.setVideoTypes(videoTypes); | ||||
|         return carousel; | ||||
|     } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue