package com.crm.manager.controller;

import com.crm.manager.service.CustomAllocationRosterScheduledService;
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.scheduled.CustomAllocationRosterScheduledDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.custom.allocation.roster.scheduled.CustomAllocationRosterScheduledAddEntity;
import com.crm.rely.backend.core.entity.custom.allocation.roster.scheduled.CustomAllocationRosterScheduledDeleteEntity;
import com.crm.rely.backend.core.entity.custom.allocation.roster.scheduled.CustomAllocationRosterScheduledSearchEntity;
import com.crm.rely.backend.core.entity.custom.allocation.roster.scheduled.CustomAllocationRosterScheduledUpdateEntity;
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("/custom/allocation/roster/scheduled")
public class CustomAllocationRosterScheduledController {

    @Autowired
    private CustomAllocationRosterScheduledService service;

    /**
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated CustomAllocationRosterScheduledAddEntity entity) throws Exception {
        service.add(entity);
        return BaseResultDto.success();
    }

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

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated CustomAllocationRosterScheduledDeleteEntity entity) throws Exception {
        service.delete(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<CustomAllocationRosterScheduledDto> pageList(@RequestBody @Validated CustomAllocationRosterScheduledSearchEntity entity) throws Exception {
        ResultWithPagerDto<CustomAllocationRosterScheduledDto> result = service.searchPageList(entity);
        return result;
    }

    @PostMapping("/search/single")
    public BaseResultDto<CustomAllocationRosterScheduledDto> single(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        CustomAllocationRosterScheduledDto dto = service.searchSingle(entity);
        return BaseResultDto.success(dto);
    }
}
