package easydo.technology.controller;

import easydo.technology.service.GLDMasterService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/gldMaster")
public class GLDMasterController {
    @Resource
    GLDMasterService gldMasterService;
    @Value("${GLD.APPROVE.mgtGroupId}")
    String mgtGroupId;
    @Value("${GLD.APPROVE.formId}")
    String formId;
    @Value("${tenantId_gld_master}")
    String tenantId;
    @Value("${GLD.host}")
    String host;

    @RequestMapping("/getToken")
    public Object getToken() throws Exception {
        Map<String, Object> result = new HashMap<>();
        String token = gldMasterService.getGetToken();
        result.put("mgtGroupId", mgtGroupId);
        result.put("formId", formId);
        result.put("tenantId", tenantId);
        result.put("token", token);
        result.put("host", host);
        return new ResponseEntity<>(result, HttpStatus.OK);
    }

    @GetMapping("/removeToken")
    public Object removeToken() throws Exception {
        gldMasterService.removeToken();
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
