package com.crm.manager.controller;

import com.crm.manager.service.emial.EmailSendFeignService;
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.system.email.record.SysEmailRecordSearchDto;
import com.crm.rely.backend.core.entity.system.email.SupplementSendEmailEntity;
import com.crm.rely.backend.core.entity.system.email.record.SysEmailRecordSearchEntity;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 发送记录
 *
 * @author houn
 */
@RestController
@RequestMapping("/email/record")
public class SysEmailSentRecordController {

    @Autowired
    private EmailSendFeignService emailSendFeignService;

    /**
     * 列表邮件模版
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/list")
    public BaseResultDto pageList(@RequestBody @Validated SysEmailRecordSearchEntity entity) throws Exception {

        ResultWithPagerDto<SysEmailRecordSearchDto> result = emailSendFeignService.searchList(entity);

        return result;
    }

    @PostMapping("/supplement/send")
    public BaseResultDto supplementSend(@RequestBody @Validated SupplementSendEmailEntity entity) throws Exception {

        BaseResultDto result = emailSendFeignService.managerSupplementSendEmail(entity);

        return result;
    }
}
