package com.crm.manager.controller;

import com.crm.manager.service.CustomAllocationRosterAreaService;
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.allocation.roster.area.CustomAllocationRosterAreaListDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.custom.allocation.roster.area.CustomAllocationRosterAreaAddEntity;
import com.crm.rely.backend.core.entity.custom.allocation.roster.area.CustomAllocationRosterAreaDeleteEntitys;
import com.crm.rely.backend.core.entity.custom.allocation.roster.area.CustomAllocationRosterAreaSearchEntity;
import com.crm.rely.backend.core.entity.custom.allocation.roster.area.CustomAllocationRosterAreaUpdateEntity;
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("/custom/allocation/roster/area")
public class CustomAllocationRosterAreaController {

    @Autowired
    private CustomAllocationRosterAreaService customAllocationRosterAreaService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated CustomAllocationRosterAreaAddEntity entity) throws Exception {
        customAllocationRosterAreaService.add(entity);
        return BaseResultDto.success();
    }

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

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

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

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

        return customAllocationRosterAreaService.searchPageList(entity);
    }

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

    @PostMapping("/all/list")
    public BaseResultDto getAllList(@RequestBody CustomAllocationRosterAreaSearchEntity entity) throws Exception {
        return BaseResultDto.success(customAllocationRosterAreaService.getAllList(entity));
    }

}
