|
@@ -12,10 +12,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
+import org.dromara.system.domain.FormalParentsStudent;
|
|
|
import org.dromara.system.domain.FormalTeacherClass;
|
|
|
+import org.dromara.system.domain.bo.FormalParentsStudentBo;
|
|
|
import org.dromara.system.domain.bo.FormalTeacherClassBo;
|
|
|
+import org.dromara.system.domain.vo.FormalParentsStudentVo;
|
|
|
import org.dromara.system.domain.vo.FormalTeacherClassVo;
|
|
|
+import org.dromara.system.domain.vo.RegisterParentsVo;
|
|
|
+import org.dromara.system.mapper.FormalParentsStudentMapper;
|
|
|
import org.dromara.system.mapper.FormalTeacherClassMapper;
|
|
|
+import org.dromara.system.mapper.RegisterParentsMapper;
|
|
|
+import org.dromara.system.service.IFormalParentsStudentService;
|
|
|
import org.dromara.system.service.IFormalTeacherClassService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.system.domain.bo.RegisterParentsStudentBo;
|
|
@@ -23,6 +30,7 @@ import org.dromara.system.domain.vo.RegisterParentsStudentVo;
|
|
|
import org.dromara.system.domain.RegisterParentsStudent;
|
|
|
import org.dromara.system.mapper.RegisterParentsStudentMapper;
|
|
|
import org.dromara.system.service.IRegisterParentsStudentService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -41,6 +49,12 @@ public class RegisterParentsStudentServiceImpl implements IRegisterParentsStuden
|
|
|
|
|
|
private final RegisterParentsStudentMapper baseMapper;
|
|
|
|
|
|
+ private final RegisterParentsMapper registerParentsMapper;
|
|
|
+
|
|
|
+ private final IFormalParentsStudentService formalParentsStudentService;
|
|
|
+
|
|
|
+ private final FormalParentsStudentMapper formalParentsStudentMapper;
|
|
|
+
|
|
|
private final IFormalTeacherClassService formalTeacherClassService;
|
|
|
|
|
|
private final FormalTeacherClassMapper formalTeacherClassMapper;
|
|
@@ -60,25 +74,32 @@ public class RegisterParentsStudentServiceImpl implements IRegisterParentsStuden
|
|
|
public TableDataInfo<RegisterParentsStudentVo> queryPageList(RegisterParentsStudentBo bo, PageQuery pageQuery) {
|
|
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
- List<RoleDTO> roles = loginUser.getRoles();
|
|
|
- boolean bl = false;
|
|
|
- for (RoleDTO role : roles) {
|
|
|
- if("teacher".equals(role.getRoleKey())){
|
|
|
- bl = true;
|
|
|
- break;
|
|
|
- }
|
|
|
+
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ String ro = "";
|
|
|
+ if (params != null && params.size() > 0) {
|
|
|
+ ro = (String) params.get("role");
|
|
|
}
|
|
|
- //角色是老师
|
|
|
- if(bl){
|
|
|
- //查询老师班级
|
|
|
- FormalTeacherClassBo formalTeacherClass = new FormalTeacherClassBo();
|
|
|
- formalTeacherClass.setTeacherId(loginUser.getUserId());
|
|
|
- List<FormalTeacherClassVo> formalTeacherClassList = formalTeacherClassMapper.queryMapperList(formalTeacherClass);
|
|
|
- List<Long> classIds = formalTeacherClassList.stream().map(FormalTeacherClassVo::getClassId).collect(Collectors.toList());
|
|
|
- bo.setClassIds(classIds);
|
|
|
+ if(StringUtils.isEmpty(ro)){
|
|
|
+ List<RoleDTO> roles = loginUser.getRoles();
|
|
|
+ boolean bl = false;
|
|
|
+ for (RoleDTO role : roles) {
|
|
|
+ if("teacher".equals(role.getRoleKey())){
|
|
|
+ bl = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //角色是老师
|
|
|
+ if(bl){
|
|
|
+ //查询老师班级
|
|
|
+ FormalTeacherClassBo formalTeacherClass = new FormalTeacherClassBo();
|
|
|
+ formalTeacherClass.setTeacherId(loginUser.getUserId());
|
|
|
+ List<FormalTeacherClassVo> formalTeacherClassList = formalTeacherClassMapper.queryMapperList(formalTeacherClass);
|
|
|
+ List<Long> classIds = formalTeacherClassList.stream().map(FormalTeacherClassVo::getClassId).collect(Collectors.toList());
|
|
|
+ bo.setClassIds(classIds);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
LambdaQueryWrapper<RegisterParentsStudent> lqw = buildQueryWrapper(bo);
|
|
|
Page<RegisterParentsStudentVo> result = baseMapper.selectVoMapperPage(pageQuery.build(), lqw);
|
|
|
return TableDataInfo.build(result);
|
|
@@ -118,6 +139,14 @@ public class RegisterParentsStudentServiceImpl implements IRegisterParentsStuden
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean insertByBo(RegisterParentsStudentBo bo) {
|
|
|
+ //查询注册前家长信息
|
|
|
+ LoginUser user = LoginHelper.getLoginUser();
|
|
|
+ RegisterParentsVo registerParentsVo = registerParentsMapper.selectRegisterParentsByPhonenumber(user.getUsername());
|
|
|
+ bo.setParentsId(registerParentsVo.getId());
|
|
|
+ bo.setParentsName(registerParentsVo.getUserName());
|
|
|
+ bo.setParentsPhone(registerParentsVo.getUserPhone());
|
|
|
+ bo.setCreateTime(DateUtils.getNowDate());
|
|
|
+ bo.setUpdateTime(DateUtils.getNowDate());
|
|
|
bo.setCreateTime(DateUtils.getNowDate());
|
|
|
RegisterParentsStudent add = MapstructUtils.convert(bo, RegisterParentsStudent.class);
|
|
|
validEntityBeforeSave(add);
|
|
@@ -132,10 +161,11 @@ public class RegisterParentsStudentServiceImpl implements IRegisterParentsStuden
|
|
|
* 修改注册-家长-学生
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public Boolean updateByBo(RegisterParentsStudentBo bo) {
|
|
|
+ //删除学生
|
|
|
bo.setUpdateTime(DateUtils.getNowDate());
|
|
|
bo.setIsPass("1");
|
|
|
-
|
|
|
RegisterParentsStudent update = MapstructUtils.convert(bo, RegisterParentsStudent.class);
|
|
|
validEntityBeforeSave(update);
|
|
|
return baseMapper.updateMapperById(update) > 0;
|
|
@@ -158,4 +188,12 @@ public class RegisterParentsStudentServiceImpl implements IRegisterParentsStuden
|
|
|
}
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidById(RegisterParentsStudentBo bo, boolean b) {
|
|
|
+ //
|
|
|
+ LoginUser user = LoginHelper.getLoginUser();
|
|
|
+ formalParentsStudentMapper.updateIsDelByStudent(user.getUserId(),bo.getClassId(),bo.getStudentName());
|
|
|
+ return baseMapper.deleteByIdMapper(bo.getId())>0;
|
|
|
+ }
|
|
|
}
|