|
|
package cn.bronet.admin.demo.service.impl;
|
|
|
|
|
|
import cn.bronet.admin.common.core.domain.AjaxResult;
|
|
|
import cn.bronet.admin.common.utils.ServletUtils;
|
|
|
import cn.bronet.admin.demo.domain.CUser;
|
|
|
import cn.bronet.admin.demo.domain.vo.TestDemoVo;
|
|
|
import cn.bronet.admin.demo.mapper.CRegisterSchoolMapper;
|
|
|
import cn.bronet.admin.demo.mapper.CUserMapper;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.bronet.admin.common.utils.PageUtils;
|
|
|
import cn.bronet.admin.common.core.page.PagePlus;
|
|
|
import cn.bronet.admin.common.core.page.TableDataInfo;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import javassist.runtime.Desc;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import cn.bronet.admin.common.core.mybatisplus.core.ServicePlusImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
...
|
...
|
@@ -15,6 +26,8 @@ import cn.bronet.admin.demo.domain.CGrade; |
|
|
import cn.bronet.admin.demo.mapper.CGradeMapper;
|
|
|
import cn.bronet.admin.demo.service.ICGradeService;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Collection;
|
...
|
...
|
@@ -25,9 +38,20 @@ import java.util.Collection; |
|
|
* @author ruoyi
|
|
|
* @date 2021-09-09
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class CGradeServiceImpl extends ServicePlusImpl<CGradeMapper, CGrade, CGradeVo> implements ICGradeService {
|
|
|
|
|
|
@Autowired
|
|
|
private CUserMapper cUserMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private CGradeMapper cGradeMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private CRegisterSchoolMapper cRegisterSchoolMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public CGradeVo queryById(Long id){
|
|
|
return getVoById(id);
|
...
|
...
|
@@ -35,6 +59,9 @@ public class CGradeServiceImpl extends ServicePlusImpl<CGradeMapper, CGrade, CGr |
|
|
|
|
|
@Override
|
|
|
public TableDataInfo<CGradeVo> queryPageList(CGradeBo bo) {
|
|
|
|
|
|
|
|
|
|
|
|
PagePlus<CGrade, CGradeVo> result = pageVo(PageUtils.buildPagePlus(), buildQueryWrapper(bo));
|
|
|
return PageUtils.buildDataInfo(result);
|
|
|
}
|
...
|
...
|
@@ -51,6 +78,7 @@ public class CGradeServiceImpl extends ServicePlusImpl<CGradeMapper, CGrade, CGr |
|
|
lqw.eq(bo.getSchoolId() != null, CGrade::getSchoolId, bo.getSchoolId());
|
|
|
lqw.eq(bo.getGradeType() != null, CGrade::getGradeType, bo.getGradeType());
|
|
|
lqw.eq(bo.getParentId() != null, CGrade::getParentId, bo.getParentId());
|
|
|
lqw.eq(bo.getState() !=null,CGrade::getState,bo.getState());
|
|
|
return lqw;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -84,4 +112,167 @@ public class CGradeServiceImpl extends ServicePlusImpl<CGradeMapper, CGrade, CGr |
|
|
}
|
|
|
return removeByIds(ids);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询此学校下所有年级
|
|
|
* @return
|
|
|
* @author mdx
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult getAllGrades(CGradeBo bo) {
|
|
|
|
|
|
|
|
|
// TODO: 2021/9/23 获取登录人的ID
|
|
|
Long uId=119911L;
|
|
|
CUser cUser = cUserMapper.selectById(uId);
|
|
|
Long school = cRegisterSchoolMapper.selectByUserId(uId);
|
|
|
|
|
|
// TODO: 2021/9/23 分页查询
|
|
|
bo.setSchoolId(school);
|
|
|
|
|
|
Page<CGradeVo> pageList = baseMapper.customPageList(PageUtils.buildPage(), buildQueryWrapper(bo));
|
|
|
|
|
|
return AjaxResult.success(pageList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加年级
|
|
|
* @param bo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult saveGrade(CGradeBo bo) {
|
|
|
|
|
|
//获取登录用户的Id
|
|
|
Long uId=111111L;
|
|
|
Long schoolId = cRegisterSchoolMapper.selectByUserId(uId);
|
|
|
|
|
|
//创建需要添加到数据库的参数
|
|
|
CGrade grade = new CGrade();
|
|
|
grade.setGradeName(bo.getGradeName())
|
|
|
.setGradeType(bo.getGradeType())
|
|
|
.setCreateTime(LocalDateTime.now())
|
|
|
.setState(bo.getState())
|
|
|
.setSchoolId(schoolId);
|
|
|
|
|
|
|
|
|
cGradeMapper.insert(grade);
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询此学校下正常状态的年级
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult getGrades() {
|
|
|
|
|
|
//获取登录人的Id
|
|
|
Long uId =119911L;
|
|
|
CUser cUser = cUserMapper.selectById(uId);
|
|
|
Long schoolId = cRegisterSchoolMapper.selectByUserId(uId);
|
|
|
|
|
|
//创建数据库查询条件
|
|
|
LambdaQueryWrapper<CGrade> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(CGrade::getState,0)
|
|
|
.eq(CGrade::getSchoolId,schoolId)
|
|
|
.eq(CGrade::getGradeType,1);
|
|
|
|
|
|
List<CGrade> cGrades = cGradeMapper.selectList(wrapper);
|
|
|
//创建返回值
|
|
|
List<CGradeVo> vos = new ArrayList<>();
|
|
|
|
|
|
//循环遍历获得的数据
|
|
|
for (CGrade cGrade : cGrades) {
|
|
|
|
|
|
//数据添加到返回值中
|
|
|
CGradeVo vo = new CGradeVo();
|
|
|
BeanUtils.copyProperties(cGrade,vo);
|
|
|
|
|
|
vos.add(vo);
|
|
|
}
|
|
|
|
|
|
log.info("<<<返回的参数<<<::"+vos);
|
|
|
|
|
|
return AjaxResult.success(vos);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加班级
|
|
|
* @param bo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult saveClasses(CGradeBo bo) {
|
|
|
|
|
|
//获取登录人ID
|
|
|
Long uId=119911L;
|
|
|
Long schoolId = cRegisterSchoolMapper.selectByUserId(uId);
|
|
|
|
|
|
//创建存储信息
|
|
|
CGrade grade = new CGrade();
|
|
|
BeanUtils.copyProperties(bo,grade);
|
|
|
grade.setSchoolId(schoolId);
|
|
|
|
|
|
cGradeMapper.insert(grade);
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询此学校下所有班级
|
|
|
* @param bo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult getAllClasses(CGradeBo bo) {
|
|
|
|
|
|
Long uId=119911L;
|
|
|
Long schoolId = cRegisterSchoolMapper.selectByUserId(uId);
|
|
|
|
|
|
bo.setSchoolId(schoolId);
|
|
|
bo.setGradeType(2);
|
|
|
|
|
|
Page<CGradeVo> pageList = baseMapper.customPageList(PageUtils.buildPage(), buildQueryWrapper(bo));
|
|
|
|
|
|
log.info("<<<返回的参数<<<::"+pageList);
|
|
|
|
|
|
return AjaxResult.success(pageList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询此学校下正常状态的班级
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult getClasses(Long gradeParentId) {
|
|
|
|
|
|
//获取登录人用户
|
|
|
Long uId=119911L;
|
|
|
CUser cUser = cUserMapper.selectById(uId);
|
|
|
Long schoolId = cRegisterSchoolMapper.selectByUserId(uId);
|
|
|
|
|
|
LambdaQueryWrapper<CGrade> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(CGrade::getParentId,gradeParentId)
|
|
|
.eq(CGrade::getSchoolId,schoolId)
|
|
|
.eq(CGrade::getGradeType,2)
|
|
|
.eq(CGrade::getState,0);
|
|
|
|
|
|
List<CGrade> cGrades = cGradeMapper.selectList(wrapper);
|
|
|
List<CGradeVo> vos = new ArrayList<>();
|
|
|
|
|
|
for (CGrade cGrade : cGrades) {
|
|
|
|
|
|
CGradeVo vo = new CGradeVo();
|
|
|
BeanUtils.copyProperties(cGrade,vo);
|
|
|
|
|
|
vos.add(vo);
|
|
|
}
|
|
|
|
|
|
log.info("<<<返回的参数<<<::"+vos);
|
|
|
|
|
|
return AjaxResult.success(vos);
|
|
|
}
|
|
|
} |
...
|
...
|
|