package com.bonus.gs.sub.evaluate.evaluate.controller;

import com.bonus.gs.sub.evaluate.evaluate.beans.EvaluateBean;
import com.bonus.gs.sub.evaluate.evaluate.service.EvaluateService;
import com.bonus.gs.sub.evaluate.manager.controller.BaseController;
import com.bonus.gs.sub.evaluate.manager.entity.ResourcesBean;
import com.bonus.gs.sub.evaluate.manager.utils.AjaxRes;
import com.bonus.gs.sub.evaluate.manager.utils.GlobalConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

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

@Controller
@RequestMapping("/backstage/evaluate/")
public class EvaluateController extends BaseController<EvaluateBean> {
	@Autowired
	private EvaluateService service;


	@RequestMapping("evaluateOrgList")
	public String evaluateOrgList(Model model) {
		return "/evaluate/org/orgList";
	}

	@RequestMapping("addForm")
	public String addForm(Model model) {
		return "/evaluate/org/addForm";
	}

	@RequestMapping(value = "getAllList", method = RequestMethod.POST)
	@ResponseBody
	public AjaxRes getAllList(ResourcesBean o) {
		AjaxRes ar = getAjaxRes();
		try {
			List<ResourcesBean> r = service.getAllList(o);
			Map<String, Object> p = new HashMap<String, Object>();
			p.put("list", r);
			ar.setSucceed(p);
		} catch (Exception e) {
			logger.error(e.toString(), e);
			ar.setFailMsg(GlobalConst.DATA_FAIL);
		}
		return ar;
	}



}
