package com.persagy.proxy.calculation.controller;

import com.persagy.proxy.calculation.model.AdmManualRelCalRequest;
import com.persagy.proxy.calculation.model.AdmManualRelationCalcDel;
import com.persagy.proxy.calculation.model.AdmRelationAddRequest;
import com.persagy.proxy.adm.request.AdmCreateResponse;
import com.persagy.proxy.adm.request.AdmResponse;
import com.persagy.proxy.calculation.service.AdmManualRelCalService;
import com.persagy.proxy.adm.utils.AdmContextUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
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;

/***
 * Description:手动计算输入类
 * @author : lijie
 * @date :2021/8/31 11:37
 * Update By lijie 2021/8/31 11:37
 */
@RestController
@RequestMapping("/rel-manual-calc/")
@RequiredArgsConstructor
public class AdmManualRelCalController {

    private final AdmManualRelCalService relationCalcService;
    
    /***
     * Description: 添加关系
     * @param request : 请求参数
     * @return : com.persagy.proxy.adm.request.AdmCreateResponse  
     * @author : lijie
     * @date :2021/8/31 12:10
     * Update By lijie 2021/8/31 12:10
     */
    @PostMapping(value = "add")
    public AdmCreateResponse addRelations(@RequestBody AdmRelationAddRequest request) throws Exception {
        return relationCalcService.addRels(AdmContextUtil.toDmpContext(), request);
    }
    /***
     * Description: 删除关系
     * @param admManualRelationCalcDel : 请求参数
     * @return : com.persagy.proxy.adm.request.AdmCreateResponse
     * @author : lijie
     * @date :2021/8/31 12:10
     * Update By lijie 2021/8/31 12:10
     */
    @PostMapping(value = "del")
    public AdmCreateResponse delRelations(@Validated @RequestBody AdmManualRelationCalcDel admManualRelationCalcDel) throws Exception {
        return relationCalcService.delRels(AdmContextUtil.toDmpContext(), admManualRelationCalcDel);
    }
    /***
     * Description: 查询关系数据
     * @param admManualRelCalRequest : 请求参数
     * @return : com.persagy.proxy.adm.request.AdmCreateResponse
     * @author : lijie
     * @date :2021/8/31 12:10
     * Update By lijie 2021/8/31 12:10
     */
    @PostMapping(value = "query")
    public AdmResponse query(@Validated @RequestBody AdmManualRelCalRequest admManualRelCalRequest) throws Exception {
        return relationCalcService.query(AdmContextUtil.toDmpContext(), admManualRelCalRequest);
    }




}
