package com.crm.manager.controller;

import com.crm.manager.service.emial.SysEmailUnsubscribeFeignService;
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.unsubscribe.SysEmailUnsubscribeSearchDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.system.email.unsubscribe.SysEmailUnsubscribeAddEntity;
import com.crm.rely.backend.core.entity.system.email.unsubscribe.SysEmailUnsubscribeDeleteEntity;
import com.crm.rely.backend.core.entity.system.email.unsubscribe.SysEmailUnsubscribeSearchListEntity;
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;

import javax.annotation.Resource;

@RestController
@RequestMapping("/email/unsubscribe")
public class EmailUnsubscribeController {

    @Resource
    private SysEmailUnsubscribeFeignService sysEmailUnsubscribeService;

    /**
     * 添加退订
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/add")
    public BaseResultDto add(@RequestBody SysEmailUnsubscribeAddEntity entity) throws Exception {

        return sysEmailUnsubscribeService.add(entity);
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody SysEmailUnsubscribeDeleteEntity entity) throws Exception {

        return sysEmailUnsubscribeService.delete(entity);
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<SysEmailUnsubscribeSearchDto> searchList(@RequestBody @Validated SysEmailUnsubscribeSearchListEntity entity) throws Exception {

        return sysEmailUnsubscribeService.searchList(entity);
    }

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

}

