package com.eactive.eai.rms.onl.apim.portalproperty;

import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.onl.manage.comm.property.PropertyGroupUI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
public class PortalPropertyController extends OnlBaseAnnotationController {

	private PortalPropertyManService propertyManService;

	@Autowired
	public PortalPropertyController(PortalPropertyManService propertyManService) {
		this.propertyManService = propertyManService; 
	}
	
	@GetMapping(value = "/onl/apim/portalproperty/propertyMan.view")
	public void view() {
		// view
	}

	@PostMapping(value = "/onl/apim/portalproperty/propertyMan.json", params = "cmd=DETAIL")
	public ResponseEntity<PropertyGroupUI> selectDetail() {
		String prptyGroupName = "Portal";
		PropertyGroupUI propertyGroupUI = propertyManService.selectDetail(prptyGroupName);
		return ResponseEntity.ok(propertyGroupUI);
	}

	@PostMapping(value = "/onl/apim/portalproperty/propertyMan.json", params = "cmd=UPDATE")
	public ResponseEntity<Void> update(PropertyGroupUI propertyGroupForm) throws Exception {
		propertyManService.update(propertyGroupForm);
		return ResponseEntity.ok().build();
	}

}