package com.admin.web.controller.major;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.admin.common.annotation.Log;
import com.admin.common.core.controller.BaseController;
import com.admin.common.core.domain.AjaxResult;
import com.admin.common.enums.BusinessType;
import com.admin.major.domain.ScheduleArrange;
import com.admin.major.service.IScheduleArrangeService;
import com.admin.common.utils.poi.ExcelUtil;
import com.admin.common.core.page.TableDataInfo;

/**
 * 日程安排Controller
 * 
 * @author zewei
 * @date 2022-03-28
 */
@RestController
@RequestMapping("/major/arrange")
public class ScheduleArrangeController extends BaseController
{
    @Autowired
    private IScheduleArrangeService scheduleArrangeService;

    /**
     * 查询日程安排列表
     */
    @PreAuthorize("@ss.hasPermi('major:arrange:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScheduleArrange scheduleArrange)
    {
        startPage();
        List<ScheduleArrange> list = scheduleArrangeService.selectScheduleArrangeList(scheduleArrange);
        return getDataTable(list);
    }

    /**
     * 导出日程安排列表
     */
    @PreAuthorize("@ss.hasPermi('major:arrange:export')")
    @Log(title = "日程安排", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScheduleArrange scheduleArrange)
    {
        List<ScheduleArrange> list = scheduleArrangeService.selectScheduleArrangeList(scheduleArrange);
        ExcelUtil<ScheduleArrange> util = new ExcelUtil<ScheduleArrange>(ScheduleArrange.class);
        util.exportExcel(response, list, "日程安排数据");
    }

    /**
     * 获取日程安排详细信息
     */
    @PreAuthorize("@ss.hasPermi('major:arrange:query')")
    @GetMapping(value = "/{scheduleId}")
    public AjaxResult getInfo(@PathVariable("scheduleId") Long scheduleId)
    {
        return AjaxResult.success(scheduleArrangeService.selectScheduleArrangeByScheduleId(scheduleId));
    }

    /**
     * 新增日程安排
     */
    @PreAuthorize("@ss.hasPermi('major:arrange:add')")
    @Log(title = "日程安排", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScheduleArrange scheduleArrange)
    {
        return toAjax(scheduleArrangeService.insertScheduleArrange(scheduleArrange));
    }

    /**
     * 修改日程安排
     */
    @PreAuthorize("@ss.hasPermi('major:arrange:edit')")
    @Log(title = "日程安排", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScheduleArrange scheduleArrange)
    {
        return toAjax(scheduleArrangeService.updateScheduleArrange(scheduleArrange));
    }

    /**
     * 删除日程安排
     */
    @PreAuthorize("@ss.hasPermi('major:arrange:remove')")
    @Log(title = "日程安排", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scheduleIds}")
    public AjaxResult remove(@PathVariable Long[] scheduleIds)
    {
        return toAjax(scheduleArrangeService.deleteScheduleArrangeByScheduleIds(scheduleIds));
    }
}
