package com.crm.manager.controller;

import com.crm.manager.service.SalesDpsBasicSalaryService;
import com.crm.manager.service.task.SalesDpsBasicSalaryFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
import com.crm.rely.backend.core.dto.sales.SalesDpsBasicSalaryDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.login.InfoEntity;
import com.crm.rely.backend.core.entity.sales.SalesDpsBasicSalaryAddEntity;
import com.crm.rely.backend.core.entity.sales.SalesDpsBasicSalaryListEntity;
import com.crm.rely.backend.core.entity.sales.SalesDpsBasicSalaryUpdateEntity;
import com.crm.rely.backend.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
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;

@RestController
@RequestMapping("/sales/dps/basic/salary")
public class SalesDpsBasicSalaryController {

    @Autowired
    private SalesDpsBasicSalaryFeignService salesDpsBasicSalaryFeignService;
    @Autowired
    private SalesDpsBasicSalaryService salesDpsBasicSalaryService;


    @PostMapping("/add")
    public BaseResultDto<Object> save(@RequestBody SalesDpsBasicSalaryAddEntity entity, InfoEntity infoEntity) throws ServiceException {
        return salesDpsBasicSalaryFeignService.save(entity);
    }

    @PostMapping("/update")
    public BaseResultDto<Object> updateById(@RequestBody SalesDpsBasicSalaryUpdateEntity entity, InfoEntity infoEntity) throws ServiceException {
        return salesDpsBasicSalaryFeignService.updateById(entity);
    }


    @PostMapping("/delete")
    public BaseResultDto<Object> deleteById(@RequestBody SingleLongEntity entity, InfoEntity infoEntity) throws ServiceException {
        return salesDpsBasicSalaryFeignService.deleteById(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto<SalesDpsBasicSalaryDto> searchSingle(@RequestBody SingleLongEntity entity) throws ServiceException {
        return salesDpsBasicSalaryService.searchSingleById(entity.getId());
    }

    @PostMapping("/search/list")
    public BaseResultWithPagerDto<List<SalesDpsBasicSalaryDto>> searchList(@RequestBody SalesDpsBasicSalaryListEntity entity) throws ServiceException {
        return salesDpsBasicSalaryService.searchList(entity);
    }


}
