package com.crm.manager.controller;

import com.crm.manager.service.risk.RiskCopyTradeFeignService;
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.RiskCopyTradeDto;
import com.crm.rely.backend.core.dto.risk.copy.trade.record.RiskCopyTradeRecordDto;
import com.crm.rely.backend.core.entity.risk.copy.trade.RiskCopyTradeAddEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.RiskCopyTradeDeleteEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.RiskCopyTradeSearchPageEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.record.RiskCopyTradeRecordAddEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.record.RiskCopyTradeRecordCloseEntity;
import com.crm.rely.backend.core.entity.risk.copy.trade.record.RiskCopyTradeRecordSearchPageEntity;
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")
public class RiskCopyTradeController {

    @Autowired
    private RiskCopyTradeFeignService riskCopyTradeFeignService;

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

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


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

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

        return riskCopyTradeFeignService.searchRecordList(entity);
    }

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

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

        return riskCopyTradeFeignService.searchRecordClose(entity);
    }

}
