package com.crm.manager.service;

import com.crm.manager.configuration.FeignMultipartSupportConfig;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.dto.market.MarketEmailStatusNumberDto;
import com.crm.rely.backend.core.dto.market.promo.code.email.MarketPromoCodeEmailListDto;
import com.crm.rely.backend.core.dto.market.promo.code.email.record.MarketPromoCodeEmailRecordListDto;
import com.crm.rely.backend.core.dto.market.upload.email.MarketUploadEmailListDto;
import com.crm.rely.backend.core.dto.system.email.template.SysEmailTemplateSearchDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.market.promo.code.email.MarketPromoCodeEmailAddEntity;
import com.crm.rely.backend.core.entity.market.promo.code.email.MarketPromoCodeEmailSearchPageEntity;
import com.crm.rely.backend.core.entity.market.promo.code.email.record.MarketPromoCodeEmailRecordSearchPageEntity;
import com.crm.rely.backend.core.entity.market.promo.code.email.record.MarketPromoCodeEmailRecordSendEntity;
import com.crm.rely.backend.core.entity.market.promo.code.email.record.MarketPromoCodeEmailRecordStatusNumberEntity;
import com.crm.rely.backend.core.entity.market.promo.code.email.record.MarketPromoCodeRecordSupplementSendEntity;
import com.crm.rely.backend.exception.ServiceException;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @description:
 * @author: houn
 * @create: 2021-07-21 16:25
 **/
@FeignClient(name = "MARKETS-SERVICE", path = "/market/promo/code/email", configuration = FeignMultipartSupportConfig.class)
public interface MarketPromoCodeEmailFeignService {

    /**
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/add")
    BaseResultDto add(@RequestBody @Validated MarketPromoCodeEmailAddEntity entity) throws Exception;

    @PostMapping("/add/email/template")
    BaseResultDto<List<SysEmailTemplateSearchDto>> getEmailTemplate() throws Exception;

    @PostMapping("/add/upload/email")
    BaseResultDto<List<MarketUploadEmailListDto>> getUploadEmialList() throws Exception;

    @PostMapping("/send/email")
    BaseResultDto send(@RequestBody @Validated MarketPromoCodeEmailRecordSendEntity entity) throws ServiceException;

    @PostMapping("/search/list")
    ResultWithPagerDto<MarketPromoCodeEmailListDto> pageList(@RequestBody @Validated MarketPromoCodeEmailSearchPageEntity entity) throws Exception;

    @PostMapping("/search/single")
    BaseResultDto<MarketPromoCodeEmailListDto> single(@RequestBody @Validated SingleLongEntity entity) throws Exception;

    /**
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/list/record")
    ResultWithPagerDto<MarketPromoCodeEmailRecordListDto> pageListRecord(@RequestBody @Validated MarketPromoCodeEmailRecordSearchPageEntity entity) throws Exception;

    @PostMapping("/search/list/record/status/number")
    BaseResultDto<MarketEmailStatusNumberDto> statusNumber(@RequestBody @Validated MarketPromoCodeEmailRecordStatusNumberEntity entity) throws Exception;

    @PostMapping("/supplement/send")
    BaseResultDto supplementSend(@RequestBody @Validated SingleLongEntity entity) throws Exception;

    @PostMapping("/supplement/send/batch")
    BaseResultDto supplementSend(@RequestBody @Validated MarketPromoCodeRecordSupplementSendEntity entity) throws Exception;

    @PostMapping(value = "/add/upload", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE}, consumes =
            MediaType.MULTIPART_FORM_DATA_VALUE)
    BaseResultDto upload(@RequestPart(value = "file", required = false) MultipartFile file) throws Exception;
}
