62e526f9e3b8bcdf6b825351c5f8f23e59b38440.svn-base 2.93 KB
/**
 * Copyright &copy; 2015-2018 <a href="#">J-Site</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.ycsl.web.task;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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.servlet.mvc.support.RedirectAttributes;

import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.ycsl.entity.task.YcslTask;
import com.thinkgem.jeesite.modules.ycsl.service.task.YcslTaskService;

/**
 * 一窗受理登簿任务调度信息Controller
 * @author lw
 * @version 2020-07-15
 */
@Controller
@RequestMapping(value = "${adminPath}/ycsl/task/ycslTask")
public class YcslTaskController extends BaseController {

	@Autowired
	private YcslTaskService ycslTaskService;
	
	@ModelAttribute
	public YcslTask get(@RequestParam(required=false) String id) {
		YcslTask entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = ycslTaskService.get(id);
		}
		if (entity == null){
			entity = new YcslTask();
		}
		return entity;
	}
	
	@RequiresPermissions("ycsl:task:ycslTask:view")
	@RequestMapping(value = {"list", ""})
	public String list(YcslTask ycslTask, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<YcslTask> page = ycslTaskService.findPage(new Page<YcslTask>(request, response), ycslTask); 
		model.addAttribute("page", page);
		return "modules/ycsl/task/ycslTaskList";
	}

	@RequiresPermissions("ycsl:task:ycslTask:view")
	@RequestMapping(value = "form")
	public String form(YcslTask ycslTask, Model model) {
		model.addAttribute("ycslTask", ycslTask);
		return "modules/ycsl/task/ycslTaskForm";
	}

	@RequiresPermissions("ycsl:task:ycslTask:edit")
	@RequestMapping(value = "save")
	public String save(YcslTask ycslTask, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, ycslTask)){
			return form(ycslTask, model);
		}
		ycslTaskService.save(ycslTask);
		addMessage(redirectAttributes, "保存一窗受理登簿任务调度成功");
		return "redirect:"+Global.getAdminPath()+"/ycsl/task/ycslTask/?repage";
	}
	
	@RequiresPermissions("ycsl:task:ycslTask:edit")
	@RequestMapping(value = "delete")
	public String delete(YcslTask ycslTask, RedirectAttributes redirectAttributes) {
		ycslTaskService.delete(ycslTask);
		addMessage(redirectAttributes, "删除一窗受理登簿任务调度成功");
		return "redirect:"+Global.getAdminPath()+"/ycsl/task/ycslTask/?repage";
	}

}