package com.crm.manager.controller;

import com.crm.manager.service.golden.GoldenGoodsFeignService;
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.GoldenGoodsListDto;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsAddEntity;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsDeleteEntitys;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsSearchEntity;
import com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsUpdateEntity;
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")
public class GoldenGoodsController {

    @Autowired
    private GoldenGoodsFeignService goldenGoodsService;

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

        return goldenGoodsService.add(entity);
    }

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


        return goldenGoodsService.delete(entitys);
    }

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

        return goldenGoodsService.update(entity);
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<GoldenGoodsListDto> pageList(@RequestBody GoldenGoodsSearchEntity entity) throws Exception {
        return goldenGoodsService.searchPageList(entity);
    }

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

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

}
