package com.srs.web.controller.comprehensive;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.srs.common.annotation.Anonymous;
import com.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.core.page.TableDataInfo;
import com.srs.common.enums.BusinessType;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.comprehensive.domain.CphTerm;
import com.srs.comprehensive.domain.Dto.CphApplySHXS;
import com.srs.comprehensive.domain.Dto.CphApplyXyjxj;
import com.srs.comprehensive.domain.Dto.CphApplyYxgb;
import com.srs.comprehensive.domain.Dto.CphCancel;
import com.srs.comprehensive.domain.Vo.*;
import com.srs.dormitory.domain.Vo.DomInfo;
import com.srs.flowable.domain.vo.FlowQueryVo;
import com.srs.flowable.service.IFlowTaskService;
import com.srs.system.domain.SysDeptMap;
import com.srs.system.service.ISysDeptMapService;
import com.srs.system.service.ISysPostService;
import com.srs.system.service.ISysRoleService;
import com.srs.web.controller.common.RoleBool;
import liquibase.pro.packaged.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
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 io.swagger.annotations.*;
import com.srs.comprehensive.domain.CphGoodApply;
import com.srs.comprehensive.service.ICphGoodApplyService;

import static com.srs.common.core.domain.AjaxResult.success;
import static com.srs.common.utils.PageUtils.startPage;
import static com.srs.dormitory.utils.PageUtil.getDataTable;

/**
 * 评优申请Controller
 *
 * @author srs
 * @date 2023-09-12
 */
@RestController
@RequestMapping("/comprehensive/goodapply")
@Api(value = "评优申请管理", tags = "评优申请管理")
public class CphGoodApplyController extends BaseController {
    @Autowired
    private ICphGoodApplyService cphGoodApplyService;

    @Autowired
    ISysPostService _postService;

    @Autowired
    ISysRoleService _roleService;

    @Autowired
    ISysDeptMapService _deptMap;

    @Autowired
    private IFlowTaskService flowTaskService;

    @GetMapping("/countBiyeYearDept")
    @ApiOperation("统计学院学年优秀毕业生")
    public AjaxResult countBiyeYearDept() {
        boolean hasRole = RoleBool.isJwc(getUserId(), _postService);
        if (hasRole) {
            List<CphBiyeApplyVo> list = cphGoodApplyService.countBiyeYearDept();
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @PreAuthorize("@ss.hasPermi('home:stu:undo1')")
    @GetMapping("/countOwnUnDo")
    @ApiOperation("统计统计学生自己的一些审核通过的数量")
    public AjaxResult countOwnUnDo() {
        List<String> list = cphGoodApplyService.countStuUnDo(getUsername());
        FlowQueryVo flowQueryVo = new FlowQueryVo();
        flowQueryVo.setPageNum(1);
        flowQueryVo.setPageSize(10);
        AjaxResult ajaxResult = flowTaskService.todoList(flowQueryVo);
        Object total = ajaxResult.get("data");
        Page page = (Page) total;
        list.add("rwgl-" + page.getTotal());
        return AjaxResult.success(list);

    }

    @PreAuthorize("@ss.hasPermi('home:fdy:undo1')")
    @GetMapping("/countFdyUnDo")
    @ApiOperation("统计辅导员一些未审核的数量")
    public AjaxResult countFdyUnDo() {
        boolean hasRole = RoleBool.notStu(getUserId(), _roleService);
        if (hasRole) {
            List<String> list = cphGoodApplyService.countFdyUnDo(getUsername());
            FlowQueryVo flowQueryVo = new FlowQueryVo();
            flowQueryVo.setPageNum(1);
            flowQueryVo.setPageSize(10);
            AjaxResult ajaxResult = flowTaskService.todoList(flowQueryVo);
            Object total = ajaxResult.get("data");
            Page page = (Page) total;
            list.add("rwgl-" + page.getTotal());
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @PreAuthorize("@ss.hasPermi('home:xw:undo1')")
    @GetMapping("/countXwUnDo")
    @ApiOperation("统计学务一些未审核的数量")
    public AjaxResult countXwUnDo() {
        boolean hasRole = RoleBool.notStu(getUserId(), _roleService);
        if (hasRole) {
            Long oldId = getDeptId();
            SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
            Long deptId = null;
            if (dept != null) {
                deptId = dept.getOldDeptId();
            }
            List<String> list = cphGoodApplyService.countXwUnDo(deptId);
            FlowQueryVo flowQueryVo = new FlowQueryVo();
            flowQueryVo.setPageNum(1);
            flowQueryVo.setPageSize(10);
            AjaxResult ajaxResult = flowTaskService.todoList(flowQueryVo);
            Object total = ajaxResult.get("data");
            Page page = (Page) total;
            list.add("rwgl-" + page.getTotal());
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }
    @PreAuthorize("@ss.hasPermi('home:sj:undo1')")
    @GetMapping("/countSjUnDo")
    @ApiOperation("统计书记一些未审核的数量")
    public AjaxResult countSjUnDo() {
        boolean hasRole = RoleBool.notStu(getUserId(), _roleService);
        if (hasRole) {
            Long oldId = getDeptId();
            SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
            Long deptId = null;
            if (dept != null) {
                deptId = dept.getOldDeptId();
            }
            List<String> list = cphGoodApplyService.countSjUnDo(deptId);
            FlowQueryVo flowQueryVo = new FlowQueryVo();
            flowQueryVo.setPageNum(1);
            flowQueryVo.setPageSize(10);
            AjaxResult ajaxResult = flowTaskService.todoList(flowQueryVo);
            Object total = ajaxResult.get("data");
            Page page = (Page) total;
            list.add("rwgl-" + page.getTotal());
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @PreAuthorize("@ss.hasPermi('home:xg:undo1')")
    @GetMapping("/countJwcUnDo")
    @ApiOperation("统计学工一些未审核的数量 统计首页学工常规待办")
    public AjaxResult countJwcUnDo() {
        boolean hasRole = RoleBool.notStu(getUserId(), _roleService);
        if (hasRole) {
            List<String> list = cphGoodApplyService.countJwcUnDo();
            FlowQueryVo flowQueryVo = new FlowQueryVo();
            flowQueryVo.setPageNum(1);
            flowQueryVo.setPageSize(10);
            AjaxResult ajaxResult = flowTaskService.todoList(flowQueryVo);
            Object total = ajaxResult.get("data");
            Page page = (Page) total;
            list.add("rwgl-" + page.getTotal());
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }


    @GetMapping("/xwExport")
    @ApiOperation("学务导出审核名单")
    public AjaxResult xwExport(CphSearch param) {
        boolean hasRole = RoleBool.isXw(getUserId(), _postService);
        if (hasRole) {
            Long oldId = getDeptId();
            SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
            Long deptId = 0L;
            if (dept != null) {
                deptId = dept.getOldDeptId();
            }
            String typeName = param.getTypeName();
            List<CphGoodApplyVo> list;
            CphSearch temp = new CphSearch();
            temp.setMajorId(param.getMajorId());
            temp.setStuYearId(param.getStuYearId());
            temp.setDeptId(deptId);
            switch (typeName) {
                case "XYJXJ":
                    list = cphGoodApplyService.importXyjxj(temp);
                    return AjaxResult.success(list);
                case "SHXS":
                    list = cphGoodApplyService.importShxs(temp);
                    return AjaxResult.success(list);
                case "YXXSGB":
                    list = cphGoodApplyService.importYxbg(temp);
                    return AjaxResult.success(list);
                default:
                    return AjaxResult.error("未知的类型");
            }
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/fdyExport")
    @ApiOperation("辅导员导出审核名单")
    public AjaxResult fdyExport(CphSearch param) {
        boolean hasRole = RoleBool.isFdy(getUserId(), _postService);
        if (hasRole) {
            String typeName = param.getTypeName();
            List<CphGoodApplyVo> list;
            CphSearch temp = new CphSearch();
            temp.setClassId(param.getClassId());
            temp.setStuYearId(param.getStuYearId());
            temp.setTNo(getUsername());
            switch (typeName) {
                case "XYJXJ":
                    list = cphGoodApplyService.importXyjxj(temp);
                    return AjaxResult.success(list);
                case "SHXS":
                    list = cphGoodApplyService.importShxs(temp);
                    return AjaxResult.success(list);
                case "YXXSGB":
                    list = cphGoodApplyService.importYxbg(temp);
                    return AjaxResult.success(list);
                default:
                    return AjaxResult.error("未知的类型");
            }
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/importXyjxj")
    @ApiOperation("学工根据学年导出学业奖学金名单")
    public AjaxResult importXyjxj(CphSearch param) {
        boolean hasRole = RoleBool.isJwc(getUserId(), _postService);
        if (hasRole) {
            List<CphGoodApplyVo> list = cphGoodApplyService.importXyjxj(param);
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/importShxs")
    @ApiOperation("学工根据学年导出三好学生名单")
    public AjaxResult importShxs(CphSearch param) {
        boolean hasRole = RoleBool.isJwc(getUserId(), _postService);
        if (hasRole) {
            List<CphGoodApplyVo> list = cphGoodApplyService.importShxs(param);
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/importYxbg")
    @ApiOperation("学工根据学年导出优秀学生干部名单")
    public AjaxResult importYxbg(CphSearch param) {
        boolean hasRole = RoleBool.isJwc(getUserId(), _postService);
        if (hasRole) {
            List<CphGoodApplyVo> list = cphGoodApplyService.importYxbg(param);
            return AjaxResult.success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }


    @GetMapping("/listFdyAudit")
    @ApiOperation("辅导员查询自己的审核")
    public TableDataInfo listFdyAudit(CphSearch param) {
        boolean hasRole = RoleBool.isFdy(getUserId(), _postService);
        if (hasRole) {
            String tNo = getUsername();
            param.setTNo(tNo);
            param.setStatus("1");
            startPage();
            List<CphGoodAuditFdyVo> list = cphGoodApplyService.listFdyAudit(param);
            return getDataTable(list);
        } else {
            List<String> list = new ArrayList<>();
            return getDataTable(list);
        }
    }

    @GetMapping("/listFdyAllAudit")
    @ApiOperation("辅导员查询自己的所有审核记录")
    public TableDataInfo listFdyAllAudit(CphSearch param) {
        boolean hasRole = RoleBool.isFdy(getUserId(), _postService);
        if (hasRole) {
            String tNo = getUsername();
            param.setTNo(tNo);
            startPage();
            List<CphGoodAuditFdyVo> list = cphGoodApplyService.listFdyAudit(param);
            return getDataTable(list);
        } else {
            List<String> list = new ArrayList<>();
            return getDataTable(list);
        }
    }

    @GetMapping("/listXwAudit")
    @ApiOperation("学务查询自己的待审核")
    public TableDataInfo listXwAudit(CphSearch param) {
        boolean hasRole = RoleBool.isXw(getUserId(), _postService);
        if (hasRole) {
            Long oldId = getDeptId();
            SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
            Long deptId = 0L;
            if (dept != null) {
                deptId = dept.getOldDeptId();
            }
            param.setDeptId(deptId);
            param.setStatus("2");
            startPage();
            startPage();
            List<CphGoodAuditFdyVo> list = cphGoodApplyService.listXwAudit(param);
            return getDataTable(list);
        } else {
            List<String> list = new ArrayList<>();
            return getDataTable(list);
        }
    }

    @GetMapping("/listJwcAudit")
    @ApiOperation("学工查询自己的待审核")
    public TableDataInfo listJwcAudit(CphSearch param) {
        boolean hasRole = RoleBool.isJwc(getUserId(), _postService);
        if (hasRole) {
            param.setStatus("3");
            startPage();
            List<CphGoodAuditFdyVo> list = cphGoodApplyService.listXwAudit(param);
            return getDataTable(list);
        } else {
            List<String> list = new ArrayList<>();
            return getDataTable(list);
        }
    }

    @GetMapping("/listDeptAudit")
    @ApiOperation("学院审核记录")
    public TableDataInfo listDeptAudit(CphSearch param) {
        boolean hasRole = RoleBool.isXw(getUserId(), _postService);
        if (hasRole) {
            Long oldId = getDeptId();
            SysDeptMap dept = _deptMap.getOldDeptByNewId(oldId);
            Long deptId = 0L;
            if (dept != null) {
                deptId = dept.getOldDeptId();
            }
            param.setDeptId(deptId);
            startPage();
            List<CphGoodAuditFdyVo> list = cphGoodApplyService.listXwAudit(param);
            return getDataTable(list);
        } else {
            List<String> list = new ArrayList<>();
            return getDataTable(list);
        }
    }

    @GetMapping("/listAllAudit")
    @ApiOperation("所有审核记录")
    public TableDataInfo listAllAudit(CphSearch param) {
        boolean hasRole = RoleBool.isJwc(getUserId(), _postService);
        if (hasRole) {
            startPage();
            List<CphGoodAuditFdyVo> list = cphGoodApplyService.listXwAudit(param);
            return getDataTable(list);
        } else {
            List<String> list = new ArrayList<>();
            return getDataTable(list);
        }
    }


    @GetMapping(value = "/lookDetail/{id}")
    @ApiOperation("审核查看详情")
    public AjaxResult lookDetail(@PathVariable("id") Long id) {
        boolean hasRole = RoleBool.isHigh(getUserId(), _postService);
        if (hasRole) {
            CphGoodApplyVo res = cphGoodApplyService.lookDetail(id);
            return success(res);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/listStuScoreClassRank/{stuNo}")
    @ApiOperation("查询学生成绩班级排名")
    public AjaxResult listStuScoreClassRank(@PathVariable("stuNo") String stuNo) {
        boolean hasRole = RoleBool.isHigh(getUserId(), _postService);
        if (hasRole) {
            List<CphClassRankScore> list = cphGoodApplyService.listOwnScoreClassRank(stuNo);
            return success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/listStuScoreClassRankByTag/{stuNo}")
    @ApiOperation("根据学年标签查询学生指定学年成绩班级排名")
    public AjaxResult listStuScoreClassRank(@PathVariable("stuNo") String stuNo,String tag) {
        boolean hasRole = RoleBool.isHigh(getUserId(), _postService);
        if (hasRole) {
            List<CphClassRankScore> list = cphGoodApplyService.listOwnScoreClassRankByTag(stuNo,tag);//
            return success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/listStuYearCourseScore/{stuNo}")
    @ApiOperation("查询学生学年课程成绩")
    public TableDataInfo listStuYearCourseScore(@PathVariable("stuNo") String stuNo) {
        boolean hasRole = RoleBool.isHigh(getUserId(), _postService);
        if (hasRole) {
            //startPage();
            List<CphCourseNameScore> list = cphGoodApplyService.listOwnYearCourseScore(stuNo);
            return getDataTable(list);
        } else {
            List<String> list = new ArrayList<>();
            return getDataTable(list);
        }
    }


    @GetMapping("/countStuPass/{stuNo}")
    @ApiOperation("统计学生成绩通过情况")
    public AjaxResult countStuPass(@PathVariable("stuNo") String stuNo) {
        boolean hasRole = RoleBool.isHigh(getUserId(), _postService);
        if (hasRole) {
            List<CphCoursePassCount> list = cphGoodApplyService.countOwnPass(stuNo);
            return success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }

    @GetMapping("/countStuIam/{stuNo}")
    @ApiOperation("统计学生思想品德加分扣分情况")
    public AjaxResult countStuIam(@PathVariable("stuNo") String stuNo) {
        boolean hasRole = RoleBool.isHigh(getUserId(), _postService);
        if (hasRole) {
            List<CphIamSitCount> list = cphGoodApplyService.countOwnIam(stuNo);
            return success(list);
        } else {
            return AjaxResult.error(401, "你无权做这些");
        }
    }


    /**
     * 查询可以申请的学业奖学金评优类型
     *
     * @return
     * @author zhy
     * @date 2023-09-12 11:34:10
     **/
    @GetMapping("/listXyjxjCanType")
    @ApiOperation("查询可以申请的学业奖学金评优类型")
    public AjaxResult listXyjxjCanType() {
        List<CphGoodTypeCode> list = cphGoodApplyService.listXyjxjCanType();
        return success(list);
    }

    @GetMapping(value = "/listTermByYear/{id}")
    @ApiOperation("通过学年列出学期")
    public AjaxResult listTermByYear(@PathVariable("id") Long id) {
        List<CphTerm> list = cphGoodApplyService.listTermByYear(id);
        return success(list);
    }

    @PostMapping("/applyXyjxj")
    @ApiOperation("申请学业奖学金")
    public AjaxResult applyXyjxj(@RequestBody CphApplyXyjxj param) {
        return cphGoodApplyService.applyXyjxj(param);
    }

    @PostMapping("/reApply")
    @ApiOperation("重新提交")
    public AjaxResult reApply(@RequestBody CphApplyXyjxj param) {
        return cphGoodApplyService.reApply(param);
    }

    @GetMapping("/listOwnXyjxjApply")
    @ApiOperation("查询我的学业奖学金申请列表")
    public TableDataInfo listOwnXyjxjApply() {
        startPage();
        String stuNo = getUsername();
        List<CphGoodApplyVo> list = cphGoodApplyService.listOwnXyjxjApply(stuNo);
        return getDataTable(list);
    }

    @GetMapping("/listOwnScoreRank")
    @ApiOperation("查询我的成绩班级排名")
    public AjaxResult listOwnScoreClassRank() {
        String stuNo = getUsername();//学号
        List<CphClassRankScore> list = cphGoodApplyService.listOwnScoreClassRank(stuNo);
        return success(list);
    }

    /**
     * 获取某学生指定学年的班级排名,是由前端查询的学年标签对应的学年
     * @param tag
     * @return
     * @author zhy
     * @date 2023-09-12 11:34:10
     **/
    @GetMapping("/listOwnScoreRankByTag")
    @ApiOperation("根据学年标签查询我的成绩班级排名")
    public AjaxResult listOwnScoreClassRankByYear(String tag) {
        String stuNo = getUsername();//学号
        List<CphClassRankScore> list = cphGoodApplyService.listOwnScoreClassRankByTag(stuNo,tag);
        return success(list);
    }

    @GetMapping("/listOwnYearCourseScore")
    @ApiOperation("查询我的学年课程成绩")
    public TableDataInfo listOwnYearCourseScore() {
        String stuNo = getUsername();
        startPage();
        List<CphCourseNameScore> list = cphGoodApplyService.listOwnYearCourseScore(stuNo);
        return getDataTable(list);
    }


    @GetMapping("/countOwnPass")
    @ApiOperation("统计我的成绩通过情况")
    public AjaxResult countOwnPass() {
        String stuNo = getUsername();
        List<CphCoursePassCount> list = cphGoodApplyService.countOwnPass(stuNo);
        return success(list);
    }

    @GetMapping("/countOwnIam")
    @ApiOperation("统计我的思想品德加分扣分情况")
    public AjaxResult countOwnIam() {
        String stuNo = getUsername();
        List<CphIamSitCount> list = cphGoodApplyService.countOwnIam(stuNo);
        return success(list);
    }

    @GetMapping("/getOwnPassCountByCode/{code}")
    @ApiOperation("通过评优code查看我的成绩通过情况")
    public AjaxResult getOwnPassCountByCode(@PathVariable("code") String code) {
        String stuNo = getUsername();
        CphCoursePassCount res = cphGoodApplyService.getOwnPassCountByCode(stuNo, code);
        return success(res);
    }

    @GetMapping("/getOwnIamCountByCode/{code}")
    @ApiOperation("通过评优code查看思想品德情况")
    public AjaxResult getOwnIamCountByCode(@PathVariable("code") String code) {
        String stuNo = getUsername();
        CphIamSitCount res = cphGoodApplyService.getOwnIamCountByCode(stuNo, code);
        return success(res);
    }

    @PostMapping("/cancelOwnApply")
    @ApiOperation("取消自己的提交")
    public AjaxResult cancelOwnApply(@RequestBody CphCancel param) {
        return cphGoodApplyService.cancelOwnApply(param);
    }

    @GetMapping("/getOwnRankByCode/{code}")
    @ApiOperation("通过评优code查看排名百分比")
    public AjaxResult getOwnRankByCode(@PathVariable("code") String code) {
        String stuNo = getUsername();
        CphSearch param = new CphSearch();
        param.setCode(code);
        param.setStuNo(stuNo);
        CphClassRankScore res = cphGoodApplyService.getOwnRankByCode(param);
        return success(res);
    }


    /**
     * 查询评优申请列表
     */
    //@RequiresPermissions("comprehensive:goodapply:list")
    @GetMapping("/list")
    @ApiOperation("查询评优申请列表")
    public TableDataInfo list(CphGoodApply cphGoodApply) {
        startPage();
        List<CphGoodApply> list = cphGoodApplyService.selectCphGoodApplyList(cphGoodApply);
        return getDataTable(list);
    }

    /**
     * 导出评优申请列表
     */
    //@RequiresPermissions("comprehensive:goodapply:export")
    @Log(title = "评优申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出评优申请列表")
    public void export(HttpServletResponse response, CphGoodApply cphGoodApply) {
        List<CphGoodApply> list = cphGoodApplyService.selectCphGoodApplyList(cphGoodApply);
        ExcelUtil<CphGoodApply> util = new ExcelUtil<CphGoodApply>(CphGoodApply.class);
        util.exportExcel(response, list, "评优申请数据");
    }

    /**
     * 获取评优申请详细信息
     */
    //@RequiresPermissions("comprehensive:goodapply:query")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取评优申请详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(cphGoodApplyService.selectCphGoodApplyById(id));
    }

    /**
     * 新增评优申请
     */
    //@RequiresPermissions("comprehensive:goodapply:add")
    @Log(title = "评优申请", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增评优申请")
    public AjaxResult add(@RequestBody CphGoodApply cphGoodApply) {
        return toAjax(cphGoodApplyService.insertCphGoodApply(cphGoodApply));
    }

//    private AjaxResult toAjax(int insertCphGoodApply) {
//    }

    /**
     * 修改评优申请
     */
    //@RequiresPermissions("comprehensive:goodapply:edit")
    @Log(title = "评优申请", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改评优申请")
    public AjaxResult edit(@RequestBody CphGoodApply cphGoodApply) {
        return toAjax(cphGoodApplyService.updateCphGoodApply(cphGoodApply));
    }

    /**
     * 删除评优申请
     */
    //@RequiresPermissions("comprehensive:goodapply:remove")
    @Log(title = "评优申请", businessType = BusinessType.DELETE)
    @PostMapping("/delete/{ids}")
    @ApiOperation("删除评优申请")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(cphGoodApplyService.deleteCphGoodApplyByIds(ids));
    }

    @PostMapping("/applyYxgb")
    @ApiOperation("申请优秀干部")
    public AjaxResult applyYxgb(@RequestBody CphApplyYxgb cphApplyYxgb) {
        return cphGoodApplyService.applyYxgb(cphApplyYxgb);
    }

    //验证是否可以申请
    @PostMapping("/verifyApplySHXS")
    @ApiOperation("验证三好学生")
    public AjaxResult verifyApplySHXS() {
        if (cphGoodApplyService.verifyApplySHXS()) {
            return success();
        }
        return error();
    }

    //申请三好学生
    @PostMapping("/applySHXS")
    @ApiOperation("申请三好学生")
    public AjaxResult applySHXS(@RequestBody CphApplySHXS cphApplySHXS) {
        if (cphGoodApplyService.applySHXS(cphApplySHXS)) {
            return success();
        }
        return error();
    }

    //查询我的申请信息
    @GetMapping("/selectApplySHXS")
    @ApiOperation("查询我的申请三好学生记录")
    public TableDataInfo getXSCJSSS() {
        startPage();
        List<Map<String, Object>> grades = cphGoodApplyService.getGrades();
        return getDataTable(grades);
    }

    @GetMapping("/selectApplyYxgb")
    @ApiOperation("查询我的申请优秀班干部记录")
    public AjaxResult getApplyYxgb() {
        return cphGoodApplyService.getApplyYxgb();
    }

    @ApiOperation("删除优秀干部申请记录")
    @PostMapping("/delete/Yxgb")
    public AjaxResult deleteYxgb(@RequestBody List<Long> ids) {
        return cphGoodApplyService.deleteYxgb(ids);
    }

    @ApiOperation("验证优秀干部")
    @GetMapping("/verifyApplyYXGB")
    public AjaxResult verifyApplyYXGB() {
        return cphGoodApplyService.verifyApplyYXGB();
    }

    @ApiOperation("重新提交优秀干部申请")
    @PostMapping("/reApplyYXGB")
    public AjaxResult reApplyYXGB(@RequestBody CphApplyYxgb cphApplyYxgb) {
        return cphGoodApplyService.reApplyYxgb(cphApplyYxgb);
    }

}
