package com.eactive.eai.rms.common.acl.menu;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.SortDefault;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import com.eactive.eai.rms.common.acl.menu.ui.MenuUI;
import com.eactive.eai.rms.common.acl.menu.ui.MenuUISearch;
import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.vo.GridResponse;

@Controller
public class MenuDbTableController extends BaseAnnotationController {

	@Autowired
	private MenuManService menuManService;

	@GetMapping(value = "/common/acl/menu/menuDBTableMan.view")
	public void view() {
		// view
	}

	@GetMapping(value = "/common/acl/menu/menuDBTableMan.view", params = "cmd=LIST")
	public String viewList() {
		return "/common/acl/menu/menuDBTableMan";
	}

	@PostMapping(value = "/common/acl/menu/menuDBTableMan.json", params = "cmd=LIST")
	public ResponseEntity<GridResponse<MenuUI>> selectTree(
			@SortDefault(sort = { "menuId", "sortOrder" }) Pageable pageable, MenuUISearch menuUISearch) {
		Page<MenuUI> page = menuManService.selectDbList(pageable, menuUISearch);
		return ResponseEntity.ok(new GridResponse<>(page));
	}
}
