package com.crm.manager.controller;

import com.crm.manager.service.emial.EmailSentConfigFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.entity.system.email.sent.config.*;
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/receive/config")
public class SysEmailReceiveConfigController {

    @Autowired
    private EmailSentConfigFeignService feignService;

    /**
     * 添加配置
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated SysEmailSentConfigAddEntity entity) throws Exception {

        return feignService.add(entity);
    }

    /**
     * 删除配置
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated SysEmailSentConfigDeleteEntity entity) throws Exception {

        return feignService.delete(entity);
    }

    /**
     * 修改配置
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated SysEmailSentConfigUpdateEntity entity) throws Exception {

        return feignService.update(entity);
    }

    @PostMapping("/batch/update")
    public BaseResultDto updateBatch(@RequestBody @Validated SysEmailSentConfigBatchUpdateEntity entity) throws Exception {

        return feignService.updateBatch(entity);
    }

    /**
     * 列表查询
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/list")
    public BaseResultDto searchList(@RequestBody @Validated SysEmailSentConfigSearchEntity entity) throws Exception {

        return feignService.searchList(entity);
    }

    /**
     * 单个查询
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/single")
    public BaseResultDto searchLingle(@RequestBody @Validated SysEmailSentConfigSingleEntity entity) throws Exception {

        return feignService.searchLingle(entity);
    }

    @PostMapping("/list")
    public BaseResultDto list() throws Exception {

        return feignService.list();
    }


}
