package com.srs.web.controller.comprehensive;

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.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.comprehensive.domain.TeacherEvaluationStatus;
import com.srs.comprehensive.service.ITeacherEvaluationStatusService;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.core.page.TableDataInfo;

/**
 * 辅导员综合评价状态Controller
 *
 * @author srs
 * @date 2024-01-20
 */
@RestController
@RequestMapping("/comprehensive/teacherEvaluationStatus")
public class TeacherEvaluationStatusController extends BaseController {
    @Autowired
    private ITeacherEvaluationStatusService teacherEvaluationStatusService;

    /**
     * 查询辅导员综合评价状态列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:teacherEvaluationStatus:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeacherEvaluationStatus teacherEvaluationStatus) {
        startPage();
        List<TeacherEvaluationStatus> list = teacherEvaluationStatusService.selectTeacherEvaluationStatusList(teacherEvaluationStatus);
        return getDataTable(list);
    }

    /**
     * 导出辅导员综合评价状态列表
     */
//    @PreAuthorize("@ss.hasPermi('comprehensive:teacherEvaluationStatus:export')")
    @Log(title = "辅导员综合评价状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeacherEvaluationStatus teacherEvaluationStatus) {
        List<TeacherEvaluationStatus> list = teacherEvaluationStatusService.selectTeacherEvaluationStatusList(teacherEvaluationStatus);
       for (TeacherEvaluationStatus entity : list){
           if(entity.getIsCompleted()){
               entity.setCompleted("是");
           }else{
               entity.setCompleted("否");
           }
           if(entity.getScoreImported()){
               entity.setIsScoreImported("是");
           }else{
               entity.setIsScoreImported("否");
           }
       }
        ExcelUtil<TeacherEvaluationStatus> util = new ExcelUtil<TeacherEvaluationStatus>(TeacherEvaluationStatus.class);
        util.exportExcel(response, list, "辅导员综合评价状态数据");
    }

    /**
     * 获取辅导员综合评价状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:teacherEvaluationStatus:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(teacherEvaluationStatusService.selectTeacherEvaluationStatusById(id));
    }

    /**
     * 新增辅导员综合评价状态
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:teacherEvaluationStatus:add')")
    @Log(title = "辅导员综合评价状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeacherEvaluationStatus teacherEvaluationStatus) {
        return toAjax(teacherEvaluationStatusService.insertTeacherEvaluationStatus(teacherEvaluationStatus));
    }

    /**
     * 修改辅导员综合评价状态
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:teacherEvaluationStatus:edit')")
    @Log(title = "辅导员综合评价状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeacherEvaluationStatus teacherEvaluationStatus) {
        return toAjax(teacherEvaluationStatusService.updateTeacherEvaluationStatus(teacherEvaluationStatus));
    }

    /**
     * 删除辅导员综合评价状态
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:teacherEvaluationStatus:remove')")
    @Log(title = "辅导员综合评价状态", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(teacherEvaluationStatusService.deleteTeacherEvaluationStatusByIds(ids));
    }

    /**
     * 查询辅导员待办事项数量
     */
    @GetMapping("/todoCount")
    public AjaxResult getTodoCount(Long teacherId, Long stuYearId) {
        Integer count = teacherEvaluationStatusService.selectTodoCountByTeacherAndYear(teacherId, stuYearId);
        return success(count);
    }

    /**
     * 查询综合评价成绩导入状态
     */
    @GetMapping("/scoreImportStatus")
    public AjaxResult getScoreImportStatus(Long teacherId, Long stuYearId) {
        Boolean status = teacherEvaluationStatusService.selectScoreImportStatusByTeacherAndYear(teacherId, stuYearId);
        return success(status);
    }

    /**
     * 获取所有辅导员基本信息
     */
    @GetMapping("/allTeachers")
    public AjaxResult getAllTeachers() {
        List<TeacherEvaluationStatus> list = teacherEvaluationStatusService.selectAllTeachers();
        return success(list);
    }

    /**
     * 根据条件查询辅导员综合评价状态
     */
    @GetMapping("/condition")
    public TableDataInfo getByCondition(Long deptId, String teacherName, String employeeId, Long stuYearId) {
        startPage();
        List<TeacherEvaluationStatus> list = teacherEvaluationStatusService.selectTeacherEvaluationStatusByCondition(
                deptId, teacherName, employeeId, stuYearId);
        return getDataTable(list);
    }

    /**
     * 获取学院列表
     */
    @GetMapping("/deptList")
    public AjaxResult getDeptList() {
        List<java.util.Map<String, Object>> list = teacherEvaluationStatusService.selectDeptNameList();
        return success(list);
    }
}
