package com.crm.manager.controller;

import com.crm.manager.service.ActivityRequiteRebateService;
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.activity.requite.ActivityRequiteRebateDto;
import com.crm.rely.backend.core.entity.activity.requite.ActivityRequiteRebateAddEntity;
import com.crm.rely.backend.core.entity.activity.requite.ActivityRequiteRebateDeleteEntitys;
import com.crm.rely.backend.core.entity.activity.requite.ActivityRequiteRebateSearchEntity;
import com.crm.rely.backend.core.entity.activity.requite.ActivityRequiteRebateUpdateEntity;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
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;

@RestController
@RequestMapping("/activity/requite/rebate")
public class ActivityRequiteRebateController {

    @Autowired
    private ActivityRequiteRebateService sysActivityRebateService;
    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated ActivityRequiteRebateAddEntity entity) throws Exception {
        sysActivityRebateService.add(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated ActivityRequiteRebateDeleteEntitys entitys) throws Exception {

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

    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated ActivityRequiteRebateUpdateEntity entity) throws Exception {
        sysActivityRebateService.update(entity);
        return BaseResultDto.success();
    }

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

        return sysActivityRebateService.searchPageList(entity);
    }

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

}
