package com.zhongzheng.controller.inform;

import java.util.List;
import java.util.Arrays;

import com.zhongzheng.modules.course.vo.CourseUserEducationTypeVo;
import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
import lombok.RequiredArgsConstructor;
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.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.inform.vo.InformRemindVo;
import com.zhongzheng.modules.inform.bo.InformRemindQueryBo;
import com.zhongzheng.modules.inform.bo.InformRemindAddBo;
import com.zhongzheng.modules.inform.bo.InformRemindEditBo;
import com.zhongzheng.modules.inform.service.IInformRemindService;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 提醒设置Controller
 * 
 * @author ruoyi
 * @date 2021-11-25
 */
@Api(value = "提醒设置控制器", tags = {"提醒设置管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/remind")
public class InformRemindController extends BaseController {

    private final IInformRemindService iInformRemindService;

    /**
     * 查询提醒设置列表
     */
    @ApiOperation("查询提醒设置列表")
    @PreAuthorize("@ss.hasPermi('system:remind:list')")
    @GetMapping("/list")
    public TableDataInfo<InformRemindVo> list(InformRemindQueryBo bo) {
        startPage();
        List<InformRemindVo> list = iInformRemindService.queryList(bo);
        return getDataTable(list);
    }


    /**
     * 获取提醒设置详细信息
     */
    @ApiOperation("获取提醒设置详细信息")
    @PreAuthorize("@ss.hasPermi('system:remind:query')")
    @GetMapping("/{id}")
    public AjaxResult<InformRemindVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iInformRemindService.queryById(id));
    }

    /**
     * 新增提醒设置
     */
    @ApiOperation("新增提醒设置")
    @PreAuthorize("@ss.hasPermi('system:remind:add')")
    @Log(title = "提醒设置", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody InformRemindAddBo bo) {
        return toAjax(iInformRemindService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改提醒设置
     */
    @ApiOperation("修改提醒设置")
    @PreAuthorize("@ss.hasPermi('system:remind:edit')")
    @Log(title = "提醒设置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody InformRemindEditBo bo) {
        return toAjax(iInformRemindService.updateByEditBo(bo) ? 1 : 0);
    }


    /**
     * 查询业务层次下的学员
     */
    @ApiOperation("查询业务层次")
    @PreAuthorize("@ss.hasPermi('system:grade:list')")
    @GetMapping("/listGradeService")
    public TableDataInfo<CourseUserEducationTypeVo> listGradeService(ClassGradeQueryBo bo) {
        startPage();
        List<CourseUserEducationTypeVo> list = iInformRemindService.listGradeService(bo);
        return getDataTable(list);
    }

}
