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

import com.trade.admin.customer.domain.CustomerAssign;
import com.trade.admin.customer.domain.SearchCustomerAssign;
import com.trade.admin.customer.dto.CustomerTransferVo;
import com.trade.admin.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.Map;

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

    @Resource
    private CustomerAssignService customerAssignService;

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

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

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

    /**
     * 认领
     */
    @ApiOperation(value = "认领", notes = "认领")
    @PostMapping("/claim")
    @PreAuthorize("@ss.hasPermi('customer:assign:claim')")
    public ResponseResult<Boolean> claim(Long customerAssignId, String remark) {
        return success(customerAssignService.claim(customerAssignId, remark));
    }

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

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

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