package com.crm.manager.controller;

import com.crm.manager.service.SalesRewardRobotService;
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.sales.SalesRewardRobotListDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.sales.SalesRewardRobotAddEntity;
import com.crm.rely.backend.core.entity.sales.SalesRewardRobotDeleteEntitys;
import com.crm.rely.backend.core.entity.sales.SalesRewardRobotSearchEntity;
import com.crm.rely.backend.core.entity.sales.SalesRewardRobotUpdateEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 审核邮箱管理
 */
@RestController
@RequestMapping("/sales/robot")
public class SalesRewardRobotController {

    @Autowired
    private SalesRewardRobotService salesRewardRobotService;

    /**
     * 添加修改机器人
     */
    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated SalesRewardRobotAddEntity entity) throws Exception {

        salesRewardRobotService.add(entity);
        return BaseResultDto.success();
    }

    /**
     * 删除修改机器人
     */
    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated SalesRewardRobotDeleteEntitys entitys) throws Exception {

        salesRewardRobotService.delete(entitys);
        return BaseResultDto.success();
    }

    /**
     * 修改机器人
     */
    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated SalesRewardRobotUpdateEntity entity) throws Exception {
        salesRewardRobotService.update(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<SalesRewardRobotListDto> pageList(@RequestBody SalesRewardRobotSearchEntity entity) throws Exception {

        return salesRewardRobotService.searchPageList(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        SalesRewardRobotListDto result = salesRewardRobotService.searchSingle(entity);
        return BaseResultDto.success(result);
    }

}
