package com.eactive.eai.rms.onl.manage.serviceinfo.addb2b;

import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * <pre>
 *     1. 기능 : 에러코드 관리 화면의 컨트롤러
 * </pre>
 *
 * @author :
 * @version : $Revision: 1.24 $
 * @since : rms 1.0
 */

@Controller
public class AddB2bController extends OnlBaseAnnotationController {

	@Autowired
	@Qualifier("addB2bManService")
	private AddB2bManService service;

	@GetMapping(value = "/onl/admin/service/addB2bMan.view")
	public String view() {
		return "/onl/admin/service/addB2bMan";
	}

	@GetMapping(value = "/onl/admin/service/addB2bMan.view", params = "cmd=DETAIL")
	public String viewDetail() {
		return "/onl/admin/service/addB2bManDetail";
	}

//   @RequestMapping(value= "/onl/admin/service/addB2bMan.view")
//   private String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd) throws Exception {
//      if (cmd == null || "LIST".equals(cmd.toUpperCase())){
//         cmd = "";
//      }else {
//         cmd = CamelCaseUtil.converCamelCase(cmd);
//      }
//      String path = request.getServletPath();
//      return path.split("[.]")[0]+cmd;
//   }

	@RequestMapping(value = "/onl/admin/service/addB2bMan.json", params = "cmd=LIST")
	private ResponseEntity<List<AddB2bUI>> selectList(AddB2bSearchUI addB2bSearchUI) throws Exception {

		List<AddB2bUI> resultList = service.selectList(addB2bSearchUI);

		return ResponseEntity.ok(resultList);

	}

	@RequestMapping(value = "/onl/admin/service/addB2bMan.json", params = "cmd=UPDATE_B2BPRPTY")
	private ResponseEntity<String> insert(AddB2bUI addB2bUI) throws Exception {

		service.update(addB2bUI);

		return ResponseEntity.ok("update success");

	}

}