package com.crm.manager.controller;

import com.crm.login.rely.backend.controller.BaseLoginController;
import com.crm.manager.service.activity.CustomActivityExceptionalManagerReasonFeignService;
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.custom.activity.exceptional.manager.reason.CustomActivityExceptionalManagerReasonDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.custom.exceptional.manager.reason.CustomActivityExceptionalManagerReasonAddEntity;
import com.crm.rely.backend.core.entity.custom.exceptional.manager.reason.CustomActivityExceptionalManagerReasonDeleteEntity;
import com.crm.rely.backend.core.entity.custom.exceptional.manager.reason.CustomActivityExceptionalManagerReasonSearchListEntity;
import com.crm.rely.backend.core.entity.custom.exceptional.manager.reason.CustomActivityExceptionalManagerReasonUpdateEntity;
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;

import java.util.List;

/**
 * @author: houn
 */
@RestController
@RequestMapping("/custom/activity/exceptional/manager/reason")
public class CustomActivityExceptionalManagerReasonController extends BaseLoginController {

    @Autowired
    private CustomActivityExceptionalManagerReasonFeignService service;

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


        return service.add(entity);
    }

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


        return service.delete(entity);
    }

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

        return service.update(entity);
    }

    /**
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/list")
    public ResultWithPagerDto<CustomActivityExceptionalManagerReasonDto> pageSearchList(@RequestBody @Validated CustomActivityExceptionalManagerReasonSearchListEntity entity) throws Exception {
        return service.pageSearchList(entity);
    }

    @PostMapping("/all")
    public BaseResultDto<List<CustomActivityExceptionalManagerReasonDto>> allReason() throws Exception {

        return BaseResultDto.success(service.allReason());
    }

    @PostMapping("/search/single")
    public BaseResultDto<CustomActivityExceptionalManagerReasonDto> single(@RequestBody @Validated SingleLongEntity entity) throws Exception {

        return service.single(entity);
    }

}
