package com.muchinfo.mtp3century.controller;

import com.muchinfo.mtp3century.service.ITradingMarketService;
import com.muchinfo.mtp3century.utils.AjaxResult;
import com.muchinfo.mtp3common.vo.PageResult;
import com.muchinfo.mtp3pojos.entity.Mmrelation1;
import com.muchinfo.mtp3pojos.entity.Mmrelation2;
import com.muchinfo.mtp3pojos.entity.Quoter;
import com.muchinfo.mtp3pojos.vo.common.OrganSelectResult;
import com.muchinfo.mtp3pojos.vo.tradingmarket.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/quoter")
@Api(value = "交易市场API", description = "交易市场管理-->做市管理")
public class TradingMarketController {
    @Resource
    private ITradingMarketService iTradingMarketService;

    @RequestMapping(method = RequestMethod.GET, value = "/queryquoter")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<Quoter> queryquoter(TradingMarketQuoterParam param, HttpServletRequest request) {
        return iTradingMarketService.queryquoter(param, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/quoteradd")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 新增")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult quoteradd(@RequestBody TradingMarketQuoterAddParam param, HttpServletRequest request) {
        return iTradingMarketService.quoteradd(param, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/delquoter")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 删除")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult delquoter(Long quoterid, HttpServletRequest request) {
        return iTradingMarketService.delquoter(quoterid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryFirstRelation")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 对手关系 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<Mmrelation1> queryFirstRelation(Long quoterid, Integer pageSize, Integer pageNum, HttpServletRequest request) {
        return iTradingMarketService.queryFirstRelation(quoterid, pageSize, pageNum, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/getQuoterOrgan")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 对手关系 --> 配置一级新增获取备选机构")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<TradingMarketQuoterFirstResult> getQuoterOrgan(Long matchuserid, Long quoterid, HttpServletRequest request) {
        return iTradingMarketService.getQuoterOrgan(quoterid, matchuserid, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/quoteraddFir")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 对手关系 --> 保存一级做市关系")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult quoteraddFir(@RequestBody TradingMarketQuoterFirstAddParam param, HttpServletRequest request) {
        return iTradingMarketService.quoteraddFir(param, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/quotereditFir")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 对手关系 --> 修改一级做市关系")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult quotereditFir(@RequestBody TradingMarketQuoterFirstAddParam param, HttpServletRequest request) {
        return iTradingMarketService.quotereditFir(param, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/quoterisvalid")
    @ApiOperation("交易市场管理-->做市管理 --> 报价商管理 --> 对手关系 --> 修改一级做市关系有效性")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult quoterisvalid(Long memberuserid, Long quoterid, HttpServletRequest request) {
        return iTradingMarketService.quoterisvalid(memberuserid, quoterid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/manualQuoter")
    @ApiOperation("交易市场管理-->做市管理 --> 手工报价 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<TradingManualQuoterResult> manualQuoter(TradingManualQuoterParam param, HttpServletRequest request) {
        return iTradingMarketService.manualQuoter(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/manualQuoterView")
    @ApiOperation("交易市场管理-->做市管理 --> 手工报价 --> 手工报价详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<TradingManualQuoterViewResult> manualQuoterView(Long goodsid, HttpServletRequest request) {
        return iTradingMarketService.manualQuoterView(goodsid, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/newquote")
    @ApiOperation("交易市场管理-->做市管理 --> 手工报价 --> 手工报价")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult newquote(@RequestBody TradingManualNewQuoterParam param, HttpServletRequest request) {
        return iTradingMarketService.newquote(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/selectOrgan")
    @ApiOperation("交易市场管理-->做市管理 --> 二级对手管理 --> 新增初始化")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<OrganSelectResult> selectOrgan(String searchcode, HttpServletRequest request) {
        return iTradingMarketService.selectOrgan(searchcode, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/getMarketing")
    @ApiOperation("交易市场管理-->做市管理 --> 二级对手管理 --> 编译二级做市关系时获取做市会员")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<TradingMarketSecRelationResult> getMarketing(Long memberuserid, HttpServletRequest request) {
        return iTradingMarketService.getMarketing(memberuserid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querySecRelation")
    @ApiOperation("交易市场管理-->做市管理 --> 二级对手管理 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public PageResult<TradingQuerySecRelationResult> querySecRelation(Long memberuserid, Integer pageSize, Integer pageNum, HttpServletRequest request) {
        return iTradingMarketService.querySecRelation(memberuserid, pageSize, pageNum, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/modifySec")
    @ApiOperation("交易市场管理-->做市管理 --> 二级对手管理 --> 新增")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult modifySec(@RequestBody TradigModifySecAddParam param, HttpServletRequest request) {
        return iTradingMarketService.modifySec(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/isvalid2")
    @ApiOperation("交易市场管理-->做市管理 --> 二级对手管理 --> 删除")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult isvalid2(Long memberuserid, Long matchuserid, HttpServletRequest request) {
        return iTradingMarketService.isvalid2(memberuserid, matchuserid, request);
    }
}
