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

import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.utils.MyBeanUtils;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;
import com.jeeplus.common.web.BaseController;
import com.jeeplus.modules.act.entity.Act;
import com.jeeplus.modules.act.service.ActTaskService;
import com.jeeplus.modules.exampleeconomics.entity.ExampleEconomics;
import com.jeeplus.modules.exampleeconomics.service.ExampleEconomicsService;
import com.jeeplus.modules.exampleexpend.entity.ExampleExpend;
import com.jeeplus.modules.exampleexpend.service.ExampleExpendService;
import com.jeeplus.modules.exampleproject.entity.ExampleProject;
import com.jeeplus.modules.exampleproject.service.ExampleProjectService;
import com.jeeplus.modules.examplesingle.entity.ExampleSingle;
import com.jeeplus.modules.examplesingle.service.ExampleSingleService;
import com.jeeplus.modules.sys.entity.Office;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.workexample.entity.WorkExample;
import com.jeeplus.modules.workexample.service.WorkExampleService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.apache.shiro.authz.annotation.Logical;
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.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;
import java.util.List;
import java.util.Map;

/**
 * 案例Controller
 * @author ssrh
 * @version 2018-08-27
 */
@Controller
@RequestMapping(value = "${adminPath}/workexample/workExamples")
public class WorkExamplesController extends BaseController {

	@Autowired
	private WorkExampleService workExampleService;
	@Autowired
	private HttpServletRequest request;
	@Autowired
	private ActTaskService actTaskService;
	@Autowired
	private ExampleSingleService exampleSingleService;
	@Autowired
	private ExampleProjectService exampleProjectService;
	@Autowired
	private ExampleExpendService exampleExpendService;
	@Autowired
	private ExampleEconomicsService exampleEconomicsService;

	@ModelAttribute
	public WorkExample get(@RequestParam(required=false) String id) {
		WorkExample entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = workExampleService.get(id);
		}
		if (entity == null){
			entity = new WorkExample();
		}
		return entity;
	}
	
	/**
	 * 案例列表页面
	 */
	@RequiresPermissions("workexample:workExample:list")
	@RequestMapping(value = {"list", ""})
	public String list(WorkExample workExample, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<WorkExample> page = workExampleService.findPage(new Page<WorkExample>(request, response), workExample); 
		model.addAttribute("page", page);
		return "modules/workexample/workExampleLists";
	}

}