package com.persagy.dmp.rwd.digital.controller;

import com.persagy.dmp.common.context.AppContext;
import com.persagy.dmp.common.model.response.CommonResult;
import com.persagy.dmp.common.utils.ResultHelper;
import com.persagy.dmp.rwd.digital.dao.ObjectRelationMapper;
import com.persagy.dmp.rwd.digital.domain.CalculatingDTO;
import com.persagy.dmp.rwd.digital.service.calstrategy.CoordinateCalculateServiceImpl;
import com.persagy.dmp.rwd.digital.service.calstrategy.FlThroughFlRelCalculateServiceImpl;
import com.persagy.dmp.rwd.digital.service.calstrategy.ShThroughShRelCalculateServiceImpl;
import com.persagy.dmp.rwd.digital.service.calstrategy.SpaceConnectionRelCalculateServiceImpl;
import lombok.RequiredArgsConstructor;
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;

@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {

    private final ObjectRelationMapper objectRelationMapper;
    private final CoordinateCalculateServiceImpl coordinateCalculateService;
    private final FlThroughFlRelCalculateServiceImpl flThroughFlRelCalculateService;
    private final ShThroughShRelCalculateServiceImpl shThroughShRelCalculateService;
    private final SpaceConnectionRelCalculateServiceImpl spaceConnectionRelCalculateService;

    @PostMapping("/testCal")
    public CommonResult<Void> testCal(@RequestBody CalculatingDTO calculatingDTO){
        calculatingDTO.setAccountId(AppContext.getContext().getAccountId());
        calculatingDTO.setAppId(AppContext.getContext().getAppId());
        calculatingDTO.setGraphCode(AppContext.getContext().getGroupCode());
        calculatingDTO.setProjectId(AppContext.getContext().getProjectId());
        objectRelationMapper.insertObjectRelationByRelChain(calculatingDTO);
        return ResultHelper.success();
    }
    @PostMapping("/testGeoCal")
    public CommonResult<Void> testGeoCal(@RequestBody CalculatingDTO calculatingDTO){
        calculatingDTO.setAccountId(AppContext.getContext().getAccountId());
        calculatingDTO.setAppId(AppContext.getContext().getAppId());
        calculatingDTO.setGroupCode(AppContext.getContext().getGroupCode());
        calculatingDTO.setProjectId(AppContext.getContext().getProjectId());
        //coordinateCalculateService.calculateRelation(calculatingDTO.getRelationCalRule(),calculatingDTO);
        //flThroughFlRelCalculateService.calculateRelation(calculatingDTO.getRelationCalRule(),calculatingDTO);
        //shThroughShRelCalculateService.calculateRelation(calculatingDTO.getRelationCalRule(),calculatingDTO);
        spaceConnectionRelCalculateService.calculateRelation(calculatingDTO.getRelationCalRule(),calculatingDTO);
        return ResultHelper.success();
    }



}
