//package com.srs.dormitory.service.impl;
//
//import cn.hutool.core.bean.BeanUtil;
//import com.srs.common.core.domain.AjaxResult;
//import com.srs.common.utils.SecurityUtils;
//import com.srs.comprehensive.domain.SrsStudent;
//import com.srs.comprehensive.mapper.SrsStudentMapper;
//import com.srs.dormitory.domain.DmsApprovalProcess;
//import com.srs.dormitory.domain.DmsOffcampusApplication;
//import com.srs.dormitory.domain.Dto.AddDmsOffcampusApplicationDto;
//import com.srs.dormitory.domain.Dto.ApplicationListDto;
//import com.srs.dormitory.domain.SrsDormitoryStudent;
//import com.srs.dormitory.mapper.DmsApprovalProcessMapper;
//import com.srs.dormitory.mapper.DmsOffcampusApplicationMapper;
//import com.srs.dormitory.service.IDmsApprovalProcessService;
//import com.srs.dormitory.service.IDmsOffcampusApplicationService;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.srs.dormitory.service.ISrsDormitoryStudentService;
//import com.srs.stureg.domain.SrsStuReg;
//import com.srs.stureg.mapper.SrsStuRegMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.List;
//import java.util.Map;
//
///**
// * <p>
// * 外宿申请表 服务实现类
// * </p>
// *
// * @author szz
// * @since 2023年08月03日
// */
//@Service
//public class IDmsOffcampusApplicationServiceImpl extends ServiceImpl<DmsOffcampusApplicationMapper, DmsOffcampusApplication> implements IDmsOffcampusApplicationService {
//
//    @Autowired
//    private ISrsDormitoryStudentService srsDormitoryStudentService;
//    @Autowired
//    private DmsApprovalProcessMapper dmsApprovalProcessMapper;
//    @Autowired
//    private IDmsApprovalProcessService dmsApprovalProcessService;
//    @Autowired
//    private SrsStudentMapper srsStudentMapper;
//    /**
//     * 提交外宿申请表
//     * @param applicationDto 请求参数
//     * @return
//     */
//    @Override
//    public AjaxResult addDmsOffcampusApplication(AddDmsOffcampusApplicationDto applicationDto) {
//        SrsStudent srsStudent = srsStudentMapper.selectSrsStudentByStuNo(applicationDto.getStuNo());
//        if (srsStudent == null) {
//            return AjaxResult.error("学号不存在");
//        }
//        if (applicationDto.getCurrentBedId()!=null&&applicationDto.getCurrentDormId()!=null){
//            SrsDormitoryStudent check = srsDormitoryStudentService.lambdaQuery()
//                    .eq(SrsDormitoryStudent::getStuNo, srsStudent.getStuNo())
//                    .eq(SrsDormitoryStudent::getDormitoryId, applicationDto.getCurrentDormId())
//                    .eq(SrsDormitoryStudent::getBedId, applicationDto.getCurrentBedId())
//                    .one();
//            if (check==null) return AjaxResult.error("床位或宿舍ID错误");
//        }
//        DmsOffcampusApplication application = new DmsOffcampusApplication();
//        BeanUtil.copyProperties(applicationDto,application);
//        application.setStuNo(srsStudent.getStuNo());
//        application.setCreateBy(SecurityUtils.getUsername());
//        boolean saveApplication = save(application);
//        if (!saveApplication) return AjaxResult.error();
//        return AjaxResult.success();
//    }
//
//    /**
//     * 查看外宿申请表详情
//     * @param id 外宿申请表ID
//     * @return
//     */
//    @Override
//    public AjaxResult getDmsOffcampusApplication(Long id) {
////        Map<String, Object> info = baseMapper.getDmsOffcampusApplication(id);
////        if (info == null) return AjaxResult.error("id不存在");
////        List<Map<String, Object>> approvalList = dmsApprovalProcessMapper.selectApprovalList(id,5);
////        info.put("approvalList",approvalList);
////        return AjaxResult.success(info);
//        return  null;
//    }
//
//    /**
//     * 查看外宿申请表列表
//     * @param applicationListDto 请求参数
//     * @return
//     */
//    @Override
//    public List<Map<String, Object>> getDmsOffcampusApplicationList(ApplicationListDto applicationListDto) {
//        return baseMapper.getDmsOffcampusApplicationList(applicationListDto);
//    }
//
//    /**
//     * 批量删除外宿申请表
//     * @param ids 外宿申请表Id列表
//     * @return
//     */
//    @Transactional
//    @Override
//    public AjaxResult batchDeleteDmsOffcampusApplication(List<Long> ids) {
////        boolean removeApproval = dmsApprovalProcessService.lambdaUpdate()
////                .eq(DmsApprovalProcess::getApplicationType, 5)
////                .in(DmsApprovalProcess::getApplicationId, ids)
////                .remove();
////        if (!removeApproval) throw new RuntimeException("删除审核流程失败");
////        boolean removeApplication = removeBatchByIds(ids);
////        if (!removeApplication) throw new RuntimeException("删除申请表失败");
//        return AjaxResult.success();
//    }
//}
