package com.crm.manager.controller;

import com.crm.manager.service.golden.GoldenGoodsVideoFeignService;
import com.crm.rely.backend.core.constant.Constants;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.model.dto.golden.goods.GoldenGoodsVideoListDto;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoAddEntity;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoDeleteEntitys;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoUpdateEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/goods/video")
public class GoldenGoodsVideoController {

    @Autowired
    private GoldenGoodsVideoFeignService goldenGoodsVideoService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated GoldenGoodsVideoAddEntity entity) throws Exception {

        return goldenGoodsVideoService.add(entity);
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated GoldenGoodsVideoDeleteEntitys entitys) throws Exception {

        return goldenGoodsVideoService.delete(entitys);
    }

    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated GoldenGoodsVideoUpdateEntity entity) throws Exception {

        return goldenGoodsVideoService.update(entity);
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<GoldenGoodsVideoListDto> pageList(@RequestBody GoldenGoodsVideoSearchEntity entity) throws Exception {
        return goldenGoodsVideoService.searchPageList(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        return goldenGoodsVideoService.searchSingle(entity);
    }

    @PostMapping("/upload")
    public BaseResultDto upload(@RequestParam(value = "file", required = false) MultipartFile file,
                                @RequestParam(value = "goodsId", required = false) Long goodsId) throws Exception {
        return goldenGoodsVideoService.managerUpload(file, goodsId);
    }

}
