/**
 * @filename:CustomerAssignController 2024-06-03
 * @project trade-admin V1.0 Copyright(c) 2024 wanglang Co. Ltd. All right reserved.
 */
package com.trade.admin.enterprise.customer.controller;

import com.trade.admin.enterprise.customer.domain.CustomerAssign;
import com.trade.admin.enterprise.customer.domain.SearchCustomerAssign;
import com.trade.admin.enterprise.customer.dto.ClaimDto;
import com.trade.admin.enterprise.customer.dto.CustomerTransferVo;
import com.trade.admin.enterprise.customer.service.CustomerAssignService;
import com.trade.admin.system.controller.BaseController;
import com.trade.common.core.domain.ResponseResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 说明： 客户移交分配接口层
 * </P>
 * 
 * @version: V1.0
 * @author: wanglang
 * @time 2024-06-03
 */
@Api(tags = "客户分配接口", value = "客户分配接口")
@RestController
@RequestMapping("/customer/assign")
public class CustomerAssignController extends BaseController {

    @Resource
    private CustomerAssignService customerAssignService;

    /**
     * 客户分配列表查询
     */
    @ApiOperation(value = "客户分配列表查询", notes = "客户分配列表查询")
    @GetMapping("/queryList")
    @PreAuthorize("@ss.hasPermi('customer:enterprise:assignList')")
    public Object queryList(SearchCustomerAssign search) {
        return customerAssignService.findBySearch(search);
    }

    /**
     * 分配调整-获取数据
     */
    @ApiOperation(value = "分配调整获取数据", notes = "分配调整获取数据")
    @PostMapping(value = "/getAssignAdjustment")
    public ResponseResult<Map<String, Object>> getAssignAdjustment(@RequestBody List<Long> customerAssignIds) {
        return success(customerAssignService.getDetailById(customerAssignIds));
    }

    /**
     * 分配调整-保存
     */
    @ApiOperation(value = "分配调整保存数据", notes = "分配调整保存数据")
    @PostMapping(value = "/saveAssignAdjustment")
    @PreAuthorize("@ss.hasPermi('customer:enterprise:assignAdjustment')")
    public ResponseResult<Boolean> saveAssignAdjustment(@RequestBody List<CustomerAssign> assigns) {
        return success(customerAssignService.assignAdjustment(assigns));
    }

    /**
     * 认领
     */
    @ApiOperation(value = "认领", notes = "认领")
    @PostMapping("/claim")
    @PreAuthorize("@ss.hasPermi('customer:enterprise:claim')")
    public ResponseResult<Boolean> claim(@RequestBody ClaimDto claimDto) {
        return success(customerAssignService.claim(claimDto));
    }

    @ApiOperation(value = "移交获取数据", notes = "移交整获取数据")
    @PostMapping(value = "/getTransferInfo")
    public ResponseResult<List<CustomerTransferVo>> getTransferInfo(@RequestBody List<Long> customerAssignId) {
        return success(customerAssignService.getCustomerTransferInfo(customerAssignId));
    }

    @ApiOperation(value = "移交", notes = "移交")
    @PostMapping("/transfer")
    @PreAuthorize("@ss.hasPermi('customer:enterprise:transfer')")
    public ResponseResult<Boolean> transfer(@RequestBody @Valid List<CustomerTransferVo> assigns) {
        return success(customerAssignService.transfer(assigns));
    }

    /**
     * 操作记录列表显示数据
     * 
     * @param customerAssignId
     * @return
     */
    @ApiOperation(value = "操作记录列表数据", notes = "操作记录列表数据")
    @GetMapping("/queryRecordList")
    @PreAuthorize("@ss.hasPermi('customer:enterprise:assignRecordList')")
    public Object queryRecordList(Long customerAssignId) {
        return success(customerAssignService.findRecordByCustomerAssignId(customerAssignId));
    }
}
