package com.samsung.embo.kpi.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
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;

import com.samsung.authentication.Account;
import com.samsung.embo.kpi.KpiService;
import com.samsung.role.RoleService;
import com.samsung.user.entity.User;

import io.swagger.v3.oas.annotations.Operation;

@RestController
@RequestMapping("/embo/kpi/")
public class KpiController {

	private final KpiService kpiService;

	public KpiController(KpiService kpiService, RoleService roleService) {
		this.kpiService = kpiService;

	}

	@Operation(summary = "moduleInfo 조회")
	@PostMapping(value = "main.do", params = "method=getModuleList")
	public Map<String, Object> getModuleList(@RequestBody Map<String, Object> params) throws Exception {

		User user = Account.currentUser();
		params.put("user", user);

		Map<String, Object> result = new HashMap<String, Object>();
		result.put("user", user);
		result.put("result", kpiService.selectModule(params));
		return result;
	}

	@Operation(summary = "myKpi 조회")
	@GetMapping(value = "main.do", params = "method=getKpiList")
	public List<Map<String, Object>> getKpiList() throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("userId", Account.currentUser().getUserId());
		return kpiService.selectKpi(params);
	}


	@Operation(summary = "target 조회")
	@GetMapping(value = "main.do", params = "method=getTargetList")
	public List<Map<String, Object>> getTargetList() throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();
		User user = Account.currentUser();
		params.put("user", user.getUserId());
		return kpiService.selectTarget(params);
	}

}
