package com.crm.manager.controller;

import com.crm.manager.service.risk.RiskCopyTradeArrayFeignService;
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.risk.copy.trade.array.RiskCopyTradeArrayDto;
import com.crm.rely.backend.core.dto.risk.copy.trade.array.record.RiskCopyTradeArrayMtRecordDto;
import com.crm.rely.backend.core.entity.risk.copy.trade.array.RiskCopyTradeArrayAddEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.array.RiskCopyTradeArrayDeleteEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.array.RiskCopyTradeArraySearchPageEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.array.record.RiskCopyTradeArrayRecordAddEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.array.record.RiskCopyTradeArrayRecordCloseEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.array.record.RiskCopyTradeArrayRecordSearchPageEntity;
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("/risk/copy/trade/array")
public class RiskCopyTradeArrayController {

    @Autowired
    private RiskCopyTradeArrayFeignService feignService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated RiskCopyTradeArrayAddEntity entity) throws Exception {
        return feignService.add(entity);
    }

    /**
     * 删除规则
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated RiskCopyTradeArrayDeleteEntity entity) throws Exception {
        return feignService.delete(entity);
    }


    /**
     * 查看绑定列表
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/list")
    public ResultWithPagerDto<RiskCopyTradeArrayDto> searchPage(@RequestBody @Validated RiskCopyTradeArraySearchPageEntity entity) throws Exception {
        return feignService.searchPage(entity);
    }

    /**
     * 查看绑定主账户持仓订单列表-关系列表中有是否订单已拷贝标记
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/record/list")
    public ResultWithPagerDto<RiskCopyTradeArrayMtRecordDto> searchRecordList(@RequestBody @Validated RiskCopyTradeArrayRecordSearchPageEntity entity) throws Exception {

        return feignService.searchRecordList(entity);
    }

    /**
     * 订单拷贝
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/record/add")
    public BaseResultDto searchRecordAdd(@RequestBody @Validated RiskCopyTradeArrayRecordAddEntity entity) throws Exception {
        return feignService.searchRecordAdd(entity);
    }

    @PostMapping("/record/close")
    public BaseResultDto searchRecordClose(@RequestBody @Validated RiskCopyTradeArrayRecordCloseEntity entity) throws Exception {

        return feignService.searchRecordClose(entity);
    }

}
