/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.sg.audit.record.web;

import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
//import com.jeeplus.modules.sg.audit.information.entity.Information;
import com.jeeplus.modules.sg.audit.information.service.InformationService;
//import com.jeeplus.modules.sg.audit.material.entity.Material;
//import com.jeeplus.modules.sg.audit.material.service.MaterialService;
import com.jeeplus.modules.sg.audit.record.entity.Record;
import com.jeeplus.modules.sg.audit.record.service.RecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 项目管理列表Controller
 * @author
 * @version
 */
@Controller
@RequestMapping(value = "${adminPath}/sg/record")
public class RecordController extends BaseController {

	@Autowired
	private InformationService informationService;
	@Autowired
	private RecordService recordService;

	@ModelAttribute
	public Record get(@RequestParam(required=false) String id) {
		Record entity = null;
		if (StringUtils.isNotBlank(id)){
			recordService.get(id);
		}
		if (entity == null){
			entity = new Record();
		}
		return entity;
	}

	/**
	 * 项目管理列表页
	 */
	@RequiresPermissions("modules:sg:record:record:list")
	@RequestMapping(value = {"list", ""})
	public String list(Record record, Model model) {
		model.addAttribute("recordList", record);
		return "modules/sg/audit/record/recordList";
	}

		/**
	 * 项目管理列表数据
	 */
	@ResponseBody
	@RequiresPermissions("modules:sg:record:record:list")
	@RequestMapping(value = "data")
	public Map<String, Object> data(Record record, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<Record> page = recordService.findPage(new Page<Record>(request, response), record);
		return getBootstrapData(page);
	}


}


