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

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.web.BaseController;
import com.jeeplus.modules.sys.entity.Role;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.workbidingproject.entity.WorkBidingProject;
import com.jeeplus.modules.workbidingproject.service.WorkBidingProjectService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 招标项目Controller
 * @author
 * @version
 */
@Controller
@RequestMapping(value = "${adminPath}/workbidingprojectrd/workBidingProjectrd")
public class WorkBidingProjectRdController extends BaseController {

	@Autowired
	private WorkBidingProjectService workBidingProjectService;

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

	/**
	 * 招标项目信息列表页面
	 */
	@RequiresPermissions("workbidingprojectrd:workBidingProjectrd:list")
	@RequestMapping(value = {"list", ""})
	public String list(WorkBidingProject workBidingProject, HttpServletRequest request, HttpServletResponse response, Model model) {
		if(!UserUtils.getSelectRoleInfo()){
			String id = UserUtils.getUser().getId();
			workBidingProject.setQueryCon(id);
		}
		Page<WorkBidingProject> page = workBidingProjectService.findPage(new Page<WorkBidingProject>(request, response), workBidingProject);
		model.addAttribute("page", page);
		return "modules/workaftermath/workBidingProjectRdList";
	}

	/**
	 * 查看，增加，编辑招标项目信息表单页面
	 */
	//@RequiresPermissions(value={"workbidingproject:workBidingProject:view","workbidingproject:workBidingProject:add","workbidingproject:workBidingProject:edit"},logical=Logical.OR)
	@RequestMapping(value = "form")
	public String form(WorkBidingProject workBidingProject, Model model) {
		model.addAttribute("workBidingProject", workBidingProject);
		return "modules/workbidingproject/workBidingProjectForm";
	}
}