DiscoverChannelLiveController.java 3.97 KB
package cn.com.glsx.busassistant.controller;

import cn.com.glsx.busassistant.request.DiscoverChannelLiveRequest;
import cn.com.glsx.busassistant.response.DiscoverChannelLiveResponse;
import cn.com.glsx.framework.rop.response.RopResponse;
import cn.com.glsx.scrm.shopmall.enums.DiscoverChannelTypeEnum;
import com.google.common.collect.Lists;
import com.rop.annotation.NeedInSessionType;
import com.rop.annotation.ServiceMethod;
import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;

import java.util.List;

@Slf4j
@ServiceMethodBean(version = "1.0.0", needInSession = NeedInSessionType.NO)
@Api("发现-频道直播(视频)")
public class DiscoverChannelLiveController {

    @Autowired
    private Environment env;

    @ApiOperation("频道视频")
    @ServiceMethod(method = "scrm.api.busassistant.discover.channel.live", needInSession = NeedInSessionType.NO)
    public RopResponse<List<DiscoverChannelLiveResponse>> getLive(DiscoverChannelLiveRequest request) {

        List<DiscoverChannelLiveResponse> responseList = Lists.newLinkedList();

        DiscoverChannelLiveResponse liveResponse1 = new DiscoverChannelLiveResponse(DiscoverChannelTypeEnum.NEW_CARS.getValue());
        String mediaTypeStr1 = env.getProperty("discover.channel.mediaType" + liveResponse1.getChannelType());
        if (StringUtils.isNotEmpty(mediaTypeStr1)) {
            String mediaList1 = env.getProperty("discover.channel.mediaList" + liveResponse1.getChannelType());
            liveResponse1.setMediaType(Integer.valueOf(mediaTypeStr1));
            if (StringUtils.isNotEmpty(mediaList1)) {
                liveResponse1.setMediaList(mediaList1.split(","));
            }
            responseList.add(liveResponse1);
        }

        DiscoverChannelLiveResponse liveResponse2 = new DiscoverChannelLiveResponse(DiscoverChannelTypeEnum.MEMBRANES.getValue());
        String mediaTypeStr2 = env.getProperty("discover.channel.mediaType" + liveResponse2.getChannelType());
        if (StringUtils.isNotEmpty(mediaTypeStr2)) {
            String mediaList2 = env.getProperty("discover.channel.mediaList" + liveResponse2.getChannelType());
            liveResponse2.setMediaType(Integer.valueOf(mediaTypeStr2));
            if (StringUtils.isNotEmpty(mediaList2)) {
                liveResponse2.setMediaList(mediaList2.split(","));
            }
            responseList.add(liveResponse2);
        }

        DiscoverChannelLiveResponse liveResponse3 = new DiscoverChannelLiveResponse(DiscoverChannelTypeEnum.CROWD_FUNDING.getValue());
        String mediaTypeStr3 = env.getProperty("discover.channel.mediaType" + liveResponse3.getChannelType());
        if (StringUtils.isNotEmpty(mediaTypeStr3)) {
            String mediaList3 = env.getProperty("discover.channel.mediaList" + liveResponse3.getChannelType());
            liveResponse3.setMediaType(Integer.valueOf(mediaTypeStr3));
            if (StringUtils.isNotEmpty(mediaList3)) {
                liveResponse3.setMediaList(mediaList3.split(","));
            }
            responseList.add(liveResponse3);
        }

        DiscoverChannelLiveResponse liveResponse4 = new DiscoverChannelLiveResponse(DiscoverChannelTypeEnum.FIXED_INSURANCE.getValue());
        String mediaTypeStr4 = env.getProperty("discover.channel.mediaType" + liveResponse4.getChannelType());
        if (StringUtils.isNotEmpty(mediaTypeStr4)) {
            String mediaList4 = env.getProperty("discover.channel.mediaList" + liveResponse4.getChannelType());
            liveResponse4.setMediaType(Integer.valueOf(mediaTypeStr4));
            if (StringUtils.isNotEmpty(mediaList4)) {
                liveResponse4.setMediaList(mediaList4.split(","));
            }
            responseList.add(liveResponse4);
        }

        return RopResponse.success(responseList);
    }

}