package com.muchinfo.mtp3century.controller;

import com.muchinfo.mtp3century.service.ITradingWarehouseSetService;
import com.muchinfo.mtp3century.utils.AjaxResult;
import com.muchinfo.mtp3common.vo.PageResult;
import com.muchinfo.mtp3pojos.entity.Market;
import com.muchinfo.mtp3pojos.entity.Marketrunstepdetail;
import com.muchinfo.mtp3pojos.entity.Riskratiotype;
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;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/warehouseSet")
@Api(value = "交易市场API", description = "交易市场管理-->仓单市场管理")
public class TradingWarehouseSetController {

    @Resource
    private ITradingWarehouseSetService iTradingWarehouseSetService;

    @RequestMapping(method = RequestMethod.GET, value = "/querySpotFulfillment")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 现货、交收履约模板 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<SpotFulfillmentResult> querySpotFulfillment(Integer type, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        return iTradingWarehouseSetService.querySpotFulfillment(pageNum, pageSize, request, type);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/spotFulfillmentView")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 现货、交收履约模板 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<SpotFulfillmentViewResult> spotFulfillmentView(Long autoid, HttpServletRequest request) {
        return iTradingWarehouseSetService.spotFulfillmentView(autoid, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/spotFulfillmentDel")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 现货、交收履履约模板 --> 修改、新增(此页面对templatetype需要特殊处理)")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult spotFulfillmentDel(@RequestBody SpotFulfillmentDelParam param, HttpServletRequest request) {
        return iTradingWarehouseSetService.spotFulfillmentDel(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/marketrunsectiion")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 运行时段管理 --> 初始化下拉列表")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<Market> marketrunsectiion(HttpServletRequest request) {
        return iTradingWarehouseSetService.marketrunsectiion(request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querymarketrunsectiion")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 运行时段管理 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<MarketRunSectiionResult> querymarketrunsectiion(Integer pageNum, Integer pageSize, Integer trademarkettype, HttpServletRequest request) {
        return iTradingWarehouseSetService.querymarketrunsectiion(pageNum, pageSize, trademarkettype, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryMarketRunSectiionById")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 运行时段管理 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<Map<Integer, List<Marketrunstepdetail>>> queryMarketRunSectiionById(Long markerid, HttpServletRequest request) {
        return iTradingWarehouseSetService.queryMarketRunSectiionById(markerid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/marketRunSectiionCopy")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 运行时段管理 --> 复制")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult marketRunSectiionCopy(HttpServletRequest request, Long source, Long target) {
        return iTradingWarehouseSetService.marketRunSectiionCopy(request, source, target);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/editSave")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 运行时段管理 --> 修改保存")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult editSave(HttpServletRequest request, @RequestBody MarketRunSectiionParam param) {
        return iTradingWarehouseSetService.editSave(request, param);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryMarketCalendar")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 节假日管理 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<MarketCalendarResult> queryMarketCalendar(Integer pageNum, Integer pageSize, String marketName, Integer trademarkettype, HttpServletRequest request) {
        return iTradingWarehouseSetService.queryMarketCalendar(pageNum, pageSize, request, marketName, trademarkettype);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/updateSave")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 节假日管理 --> 修改保存")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult updateSave(HttpServletRequest request, @RequestBody MarketCalendarDelParam param) {
        return iTradingWarehouseSetService.updateSave(request, param);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryMarketCalendarDetail")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 节假日管理 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<MarketCalendarDetailResult> queryMarketCalendarDetail(Long markerid, String year, HttpServletRequest request) {
        return iTradingWarehouseSetService.queryMarketCalendarDetail(markerid, year, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/marketCalendarAdd")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 节假日管理 --> 新增")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult marketCalendarAdd(HttpServletRequest request, @RequestBody MarketCalendarAddParam param) {

        return iTradingWarehouseSetService.marketCalendarAdd(request, param);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querymarketmanage")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 交易服务设置 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<MarketManageResult> querymarketmanage(MarketManageParam param, HttpServletRequest request) {
        return iTradingWarehouseSetService.querymarketmanage(param, request);
    }


    @RequestMapping(method = RequestMethod.GET, value = "/marketmanagedetail")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 交易服务设置 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<MarketManageDetailResult> marketmanagedetail(Long marketid, HttpServletRequest request) {
        return iTradingWarehouseSetService.marketmanagedetail(marketid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/deletemarketmanage")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 交易服务设置 --> 注销")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult deletemarketmanage(Long marketid, HttpServletRequest request) {
        return iTradingWarehouseSetService.deletemarketmanage(marketid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/areaRoleInit")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 交易服务设置 --> 权限配置初始化")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<AreaRoleInitResult> areaRoleInit(Long marketid, HttpServletRequest request) {
        return iTradingWarehouseSetService.areaRoleInit(marketid, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/saveMemberRight")
    @ApiOperation("交易市场管理--> 仓单市场管理/合约市场管理 --> 交易服务设置 --> 权限配置保存")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult saveMemberRight(HttpServletRequest request, @RequestBody AreaRoleInitResult param) {
        return iTradingWarehouseSetService.saveMemberRight(request, param);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querysettlementperiod")
    @ApiOperation("交易市场管理--> 合约市场管理 --> 交收时段管理 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<Map<Integer, List<Marketrunstepdetail>>> querysettlementperiod(Long markerid, HttpServletRequest request) {
        return iTradingWarehouseSetService.queryMarketRunSectiionById(markerid, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/settlementperiodsave")
    @ApiOperation("交易市场管理--> 合约市场管理 --> 交收时段管理 --> 修改保存")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult settlementperiodsave(HttpServletRequest request, @RequestBody MarketRunSectiionParam param) {
        return iTradingWarehouseSetService.editSave(request, param);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryRiskRatio")
    @ApiOperation("交易市场管理--> 合约市场管理 --> 风险率类型设置 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<Riskratiotype> queryRiskRatio(Integer pageNum, Integer pageSize, HttpServletRequest request) {
        return iTradingWarehouseSetService.queryRiskRatio(pageNum, pageSize, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/riskRatiodetail")
    @ApiOperation("交易市场管理--> 合约市场管理 --> 风险率类型设置 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<RiskRatioDetailResult> riskRatiodetail(Integer customertype, Integer riskcontrolmode, HttpServletRequest request) {
        return iTradingWarehouseSetService.riskRatiodetail(customertype, riskcontrolmode, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/riskRatioUpdate")
    @ApiOperation("交易市场管理--> 合约市场管理 --> 风险率类型设置 --> 修改保存")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult riskRatioUpdate(HttpServletRequest request, @RequestBody Riskratiotype param) {
        return iTradingWarehouseSetService.riskRatioUpdate(request, param);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/riskRatioAddInit")
    @ApiOperation("交易市场管理--> 合约市场管理 --> 风险率类型设置 --> 新增初始化")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<RiskRatioAddInitResult> riskRatioAddInit(HttpServletRequest request) {
        return iTradingWarehouseSetService.riskRatioAddInit(request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/riskRatioAdd")
    @ApiOperation("交易市场管理--> 合约市场管理 --> 风险率类型设置 --> 新增")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult riskRatioAdd(HttpServletRequest request, @RequestBody Riskratiotype param) {
        return iTradingWarehouseSetService.riskRatioAdd(request, param);
    }
}
