package com.fdkankan.scene.controller;

import com.fdkankan.common.response.ResultData;
import com.fdkankan.scene.service.ISceneProAppService;
import com.fdkankan.scene.vo.FileParamVO;
import com.fdkankan.scene.vo.SceneEditParamVO;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by Hb_zzZ on 2019/6/28.
 */

@Log4j2
@RestController
@RequestMapping("/service/scene/app/edit")
public class SceneAppEditController {

    @Autowired
    private ISceneProAppService sceneProAppService;

    /**
     * 保存初始页面
     * @return
     */
    @PostMapping(value = "/saveInitialPage")
    public ResultData saveInitialPage(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveInitialPage(param);
    }

    /**
     * 保存地面logo
     * @return
     */
    @PostMapping(value = "/saveFloorLogo")
    public ResultData saveFloorLogo(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveFloorLogo(param);
    }

    /**
     * 保存场景热点
     * @return
     */
    @PostMapping(value = "/saveHot")
    public ResultData saveHot(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveHot(param);
    }

    /**
     * 保存背景音乐(只是编辑页面生效)
     * @return
     */
    @PostMapping(value = "/saveBackgroundMusic")
    public ResultData saveBackgroundMusic(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveBackgroundMusic(param);
    }

    /**
     * 保存编辑的数据并生效
     * @return
     */
    @PostMapping(value = "/saveSceneInfo")
    public ResultData saveSceneInfo(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveSceneInfo(param);
    }

    /**
     * 修改场景秘钥
     * @return
     */
    @PostMapping(value = "/saveSceneKey")
    public ResultData saveSceneKey(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveSceneKey(param);
    }

    /**
     * 单独保存tourList
     * @return
     */
    @PostMapping(value = "/saveTourList")
    public ResultData saveTourList(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveTourList(param);
    }

    /**
     * 上传图片多媒体数据，直接到七牛云
     * @param file
     * @return
     */
    @PostMapping(value = "/uploadPic")
    public ResultData uploadPic(FileParamVO param, @RequestParam("file") MultipartFile file) throws Exception {
        return sceneProAppService.uploadPic(param.getNum(), param.getFolderName(), file);
    }

    /**
     * 上传音频
     * @param file
     * @return
     */
    @PostMapping(value = "/uploadScreencapVoice")
    public ResultData uploadScreencapVoice(FileParamVO param, @RequestParam("file")  MultipartFile file) throws Exception {
        return sceneProAppService.uploadScreencapVoice(param.getNum(), file);
    }

    /**
     * 增加热点媒体文件
     * @return
     */
    @PostMapping(value = "/saveScreencapFile")
    public ResultData saveScreencapFile(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveScreencapFile(param);
    }

    /**
     * 保存热点可见性的数据
     * @return
     *
     */
    @PostMapping(value = "/saveHotVisible")
    public ResultData saveHotVisible(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveHotVisible(param);
    }

    /**
     * 漫游可行
     * @return
     */
    @PostMapping(value = "/saveLinkPano")
    public ResultData saveLinkPano(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveLinkPano(param);
    }

    /**
     * 获取从微信服务器的音频
     * @return
     */
    @PostMapping(value = "/getRecordAudioFromWeixin")
    public ResultData getRecordAudioFromWeixin(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.getRecordAudioFromWeixin(param);
    }

    /**
     * V3版本获取从微信服务器的音频
     * @return
     */
    @PostMapping(value = "/getRecordAudioFromWeixinV3")
    public ResultData getRecordAudioFromWeixinV3(@RequestBody FileParamVO param) throws Exception {
        return sceneProAppService.getRecordAudioFromWeixinV3(param);
    }

    /**
     * V3版本获取app上传的音频
     * @return
     */
    @PostMapping(value = "/getRecordAudioFromAppV3")
    public ResultData getRecordAudioFromAppV3(@RequestBody FileParamVO param) throws Exception {
        return sceneProAppService.getRecordAudioFromAppV3(param);
    }

    /**
     * App端删除某部分音频
     * @return
     */
    @PostMapping(value = "/deleteRecordAudioPart")
    public ResultData deleteRecordAudioPart(@RequestBody FileParamVO param) throws Exception {
        return sceneProAppService.deleteRecordAudioPart(param);
    }

    /**
     * 新增画墙重建模型（钟文）
     */
    @PostMapping(value = "/uploadFloorJsonAndRebuild")
    public ResultData uploadFloorJsonAndRebuild(@RequestBody SceneEditParamVO param) throws Exception{
        return sceneProAppService.uploadFloorJsonAndRebuild(param);
    }


    /**
     * 保存场景热点
     * @return
     */
    @PostMapping(value = "/saveScreencapData")
    public ResultData saveScreencapData(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveScreencapData(param);
    }

    /**
     * 保存场景热点
     * @return
     */
    @PostMapping(value = "/saveAllVisi")
    public ResultData saveAllVisi(@RequestBody SceneEditParamVO param) throws Exception {
        return sceneProAppService.saveAllVisi(param);
    }

    /**
     * 上传图片多媒体数据，直接到七牛云
     * @param file
     * @return
     */
    @PostMapping(value = "/uploadFloorplanPng")
    public ResultData uploadFloorplanPng(FileParamVO param, @RequestParam("file") MultipartFile file) throws Exception {
        return sceneProAppService.uploadFloorplanPng(param.getNum(), file, param.getCadInfo());
    }

    /**
     * 上传场景背景音乐
     */
    @PostMapping(value = "/uploadBgMusic")
    public ResultData uploadBgMusic(FileParamVO param, @RequestParam("file") MultipartFile file) throws Exception{
        return sceneProAppService.uploadBgMusic(param.getNum(), param.getFileName(), file);
    }

    /**
     * 删除上传的场景背景音乐
     */
    @PostMapping(value = "/deleteUploadBgMusic")
    public ResultData deleteUploadBgMusic(@RequestBody FileParamVO param) throws Exception{
        return sceneProAppService.deleteUploadBgMusic(param.getNum());
    }


}
