|
@@ -0,0 +1,156 @@
|
|
|
+package org.dromara.system.service.impl;
|
|
|
+
|
|
|
+import org.dromara.common.core.domain.model.LoginUser;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+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.springframework.stereotype.Service;
|
|
|
+import org.dromara.system.domain.bo.StudentInfoBo;
|
|
|
+import org.dromara.system.domain.vo.StudentInfoVo;
|
|
|
+import org.dromara.system.domain.StudentInfo;
|
|
|
+import org.dromara.system.mapper.StudentInfoMapper;
|
|
|
+import org.dromara.system.service.IStudentInfoService;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 学生档案信息Service业务层处理
|
|
|
+ *
|
|
|
+ * @author Lion Li
|
|
|
+ * @date 2023-08-16
|
|
|
+ */
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class StudentInfoServiceImpl implements IStudentInfoService {
|
|
|
+
|
|
|
+ private final StudentInfoMapper baseMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询学生档案信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public StudentInfoVo queryById(Long id){
|
|
|
+ return baseMapper.selectVoById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询学生档案信息列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<StudentInfoVo> queryPageList(StudentInfoBo bo, PageQuery pageQuery) {
|
|
|
+
|
|
|
+ LoginUser user = LoginHelper.getLoginUser();
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ String role = "";
|
|
|
+ if (params != null && params.size() > 0) {
|
|
|
+ role = (String) params.get("role");
|
|
|
+ }
|
|
|
+ if("parents".equals(role)){
|
|
|
+ bo.setParentsId(user.getUserId());
|
|
|
+ }
|
|
|
+ //return baseMapper.selectStudentInfoList(pageQuery,bo);
|
|
|
+
|
|
|
+ LambdaQueryWrapper<StudentInfo> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<StudentInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询学生档案信息列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<StudentInfoVo> queryList(StudentInfoBo bo) {
|
|
|
+ LambdaQueryWrapper<StudentInfo> lqw = buildQueryWrapper(bo);
|
|
|
+ return baseMapper.selectVoList(lqw);
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<StudentInfo> buildQueryWrapper(StudentInfoBo bo) {
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ LambdaQueryWrapper<StudentInfo> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(bo.getStudentId() != null, StudentInfo::getStudentId, bo.getStudentId());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getName()), StudentInfo::getName, bo.getName());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getSex()), StudentInfo::getSex, bo.getSex());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getAge()), StudentInfo::getAge, bo.getAge());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getFamilyName()), StudentInfo::getFamilyName, bo.getFamilyName());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getSchool()), StudentInfo::getSchool, bo.getSchool());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getStudentNumber()), StudentInfo::getStudentNumber, bo.getStudentNumber());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIdCard()), StudentInfo::getIdCard, bo.getIdCard());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIsNearsightedness()), StudentInfo::getIsNearsightedness, bo.getIsNearsightedness());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getDegreeMyopia()), StudentInfo::getDegreeMyopia, bo.getDegreeMyopia());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIsFarsightedness()), StudentInfo::getIsFarsightedness, bo.getIsFarsightedness());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getFarsightedness()), StudentInfo::getFarsightedness, bo.getFarsightedness());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getHeight()), StudentInfo::getHeight, bo.getHeight());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getWeight()), StudentInfo::getWeight, bo.getWeight());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getBloodType()), StudentInfo::getBloodType, bo.getBloodType());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getPoliticalStatus()), StudentInfo::getPoliticalStatus, bo.getPoliticalStatus());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getHealth()), StudentInfo::getHealth, bo.getHealth());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getMind()), StudentInfo::getMind, bo.getMind());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIdentificationPhoto()), StudentInfo::getIdentificationPhoto, bo.getIdentificationPhoto());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getEntrancePermit()), StudentInfo::getEntrancePermit, bo.getEntrancePermit());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getEmergencyContact()), StudentInfo::getEmergencyContact, bo.getEmergencyContact());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getEmergencyContactTelephone()), StudentInfo::getEmergencyContactTelephone, bo.getEmergencyContactTelephone());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getFatherName()), StudentInfo::getFatherName, bo.getFatherName());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getFatherTelephone()), StudentInfo::getFatherTelephone, bo.getFatherTelephone());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getMotherName()), StudentInfo::getMotherName, bo.getMotherName());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getMotherTelephone()), StudentInfo::getMotherTelephone, bo.getMotherTelephone());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getAddress()), StudentInfo::getAddress, bo.getAddress());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getLongitude()), StudentInfo::getLongitude, bo.getLongitude());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getLatitude()), StudentInfo::getLatitude, bo.getLatitude());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIsMedicalHistory()), StudentInfo::getIsMedicalHistory, bo.getIsMedicalHistory());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getMedicalDescription()), StudentInfo::getMedicalDescription, bo.getMedicalDescription());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getPsychologicalDescription()), StudentInfo::getPsychologicalDescription, bo.getPsychologicalDescription());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIsLset()), StudentInfo::getIsLset, bo.getIsLset());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getIsPoverty()), StudentInfo::getIsPoverty, bo.getIsPoverty());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增学生档案信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(StudentInfoBo bo) {
|
|
|
+ StudentInfo add = MapstructUtils.convert(bo, StudentInfo.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insert(add) > 0;
|
|
|
+ if (flag) {
|
|
|
+ bo.setId(add.getId());
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改学生档案信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(StudentInfoBo bo) {
|
|
|
+ StudentInfo update = MapstructUtils.convert(bo, StudentInfo.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(StudentInfo entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除学生档案信息
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
+ }
|
|
|
+}
|