package com.hp.web.controller.teach;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hp.common.annotation.Log;
import com.hp.common.enums.BusinessType;
import com.hp.teach.domain.TeachExamStatistics;
import com.hp.teach.service.ITeachExamStatisticsService;
import com.hp.framework.web.base.BaseController;
import com.hp.common.page.TableDataInfo;
import com.hp.common.base.AjaxResult;
import com.hp.common.utils.poi.ExcelUtil;

/**
 * 考试统计 信息操作处理
 * 
 * @author hp
 * @date 2019-03-06
 */
@Controller
@RequestMapping("/teach/teachExamStatistics")
public class TeachExamStatisticsController extends BaseController
{
    private String prefix = "teach/teachExamStatistics";
	
	@Autowired
	private ITeachExamStatisticsService teachExamStatisticsService;
	
	@RequiresPermissions("teach:teachExamStatistics:view")
	@GetMapping()
	public String teachExamStatistics()
	{
	    return prefix + "/teachExamStatistics";
	}
	
	/**
	 * 查询考试统计列表
	 */
	@RequiresPermissions("teach:teachExamStatistics:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TeachExamStatistics teachExamStatistics)
	{
		startPage();
        List<TeachExamStatistics> list = teachExamStatisticsService.selectTeachExamStatisticsList(teachExamStatistics);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出考试统计列表
	 */
	@RequiresPermissions("teach:teachExamStatistics:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TeachExamStatistics teachExamStatistics)
    {
    	List<TeachExamStatistics> list = teachExamStatisticsService.selectTeachExamStatisticsList(teachExamStatistics);
        ExcelUtil<TeachExamStatistics> util = new ExcelUtil<TeachExamStatistics>(TeachExamStatistics.class);
        return util.exportExcel(list, "teachExamStatistics");
    }
	
	/**
	 * 新增考试统计
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存考试统计
	 */
	@RequiresPermissions("teach:teachExamStatistics:add")
	@Log(title = "考试统计", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TeachExamStatistics teachExamStatistics)
	{		
		return toAjax(teachExamStatisticsService.insertTeachExamStatistics(teachExamStatistics));
	}

	/**
	 * 修改考试统计
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		TeachExamStatistics teachExamStatistics = teachExamStatisticsService.selectTeachExamStatisticsById(id);
		mmap.put("teachExamStatistics", teachExamStatistics);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存考试统计
	 */
	@RequiresPermissions("teach:teachExamStatistics:edit")
	@Log(title = "考试统计", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TeachExamStatistics teachExamStatistics)
	{		
		return toAjax(teachExamStatisticsService.updateTeachExamStatistics(teachExamStatistics));
	}
	
	/**
	 * 删除考试统计
	 */
	@RequiresPermissions("teach:teachExamStatistics:remove")
	@Log(title = "考试统计", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(teachExamStatisticsService.deleteTeachExamStatisticsByIds(ids));
	}
	
}
