...
|
...
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import com.example.client.domain.CFamilyRelationStudent;
|
|
|
import com.example.client.domain.CPersonalInformation;
|
|
|
import com.example.client.domain.CUser;
|
|
|
import com.example.client.domain.bo.CFamilyRelationStudentBo;
|
|
|
import com.example.client.domain.bo.MyAuthentication;
|
|
|
import com.example.client.domain.vo.CFamilyRelationStudentVo;
|
|
|
import com.example.client.domin.UserContext;
|
...
|
...
|
@@ -15,11 +16,14 @@ import com.example.client.mapper.CPersonalInformationMapper; |
|
|
import com.example.client.mapper.CUserMapper;
|
|
|
import com.example.client.service.FamilyService;
|
|
|
import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -36,6 +40,9 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap |
|
|
@Autowired
|
|
|
private CUserMapper cUserMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private CFamilyRelationStudentMapper cFamilyRelationStudentMapper;
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult bindingFamily(MyAuthentication myAuthentication ,Long userId) {
|
|
|
|
...
|
...
|
@@ -65,4 +72,181 @@ public class FamilyServiceImpl extends ServicePlusImpl<CFamilyRelationStudentMap |
|
|
cUserMapper.updateById(cUser);
|
|
|
return AjaxResult.success(true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看所有家庭关联
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult selectFamilies() {
|
|
|
|
|
|
Long uId = UserContext.currentUserId();
|
|
|
|
|
|
CUser cUser = cUserMapper.selectById(uId);
|
|
|
|
|
|
//判断 等于 1 为老师
|
|
|
if (cUser.getIdentityType()==1){
|
|
|
|
|
|
//根据用户Id查询家庭关系表
|
|
|
List<CFamilyRelationStudent> families= cFamilyRelationStudentMapper.getAllFamilies(uId);
|
|
|
|
|
|
//判断 等于 null
|
|
|
if (families.isEmpty()){
|
|
|
|
|
|
return AjaxResult.success("您还没有添加呢");
|
|
|
|
|
|
//不等于 null
|
|
|
}else {
|
|
|
|
|
|
//创建返回值集合
|
|
|
List<CFamilyRelationStudentVo> familiesVos = new ArrayList<>();
|
|
|
|
|
|
//遍历查询到的家庭关系表信息 并 添加信息到返回值集合
|
|
|
for (CFamilyRelationStudent family : families) {
|
|
|
|
|
|
CFamilyRelationStudentVo familyVo = new CFamilyRelationStudentVo();
|
|
|
BeanUtils.copyProperties(family,familyVo);
|
|
|
|
|
|
familiesVos.add(familyVo);
|
|
|
}
|
|
|
|
|
|
return AjaxResult.success(familiesVos);
|
|
|
}
|
|
|
//等于 2 学生
|
|
|
}else if (cUser.getIdentityType()==2){
|
|
|
|
|
|
//根据登录人Id查询家庭关系表
|
|
|
List<CFamilyRelationStudent> families= cFamilyRelationStudentMapper.getAllFamilies(uId);
|
|
|
|
|
|
//判断 等于null
|
|
|
if (families.isEmpty()){
|
|
|
|
|
|
return AjaxResult.success("你还没有绑定家长");
|
|
|
|
|
|
//不等于 null
|
|
|
}else {
|
|
|
|
|
|
//创建返回值集合
|
|
|
List<CFamilyRelationStudentVo> familiesVos = new ArrayList<>();
|
|
|
|
|
|
//循环遍历查询到的家庭关系表的信息 并 添加信息到返回值集合
|
|
|
for (CFamilyRelationStudent family : families) {
|
|
|
|
|
|
CFamilyRelationStudentVo familyVo = new CFamilyRelationStudentVo();
|
|
|
BeanUtils.copyProperties(family,familyVo);
|
|
|
|
|
|
//判断 等于null 添加关系人的用户名
|
|
|
if (family.getName()==null){
|
|
|
|
|
|
CUser cUser1 = cUserMapper.selectById(family.getUserId());
|
|
|
familyVo.setName(cUser1.getUserName());
|
|
|
}
|
|
|
|
|
|
|
|
|
familiesVos.add(familyVo);
|
|
|
|
|
|
}
|
|
|
|
|
|
return AjaxResult.success(familiesVos);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return AjaxResult.error("错误");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取要修改的家庭关系信息
|
|
|
* @param familyId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult getFamilyInfo(Long familyId) {
|
|
|
|
|
|
//根据家庭关系表的ID查询家庭关系表
|
|
|
CFamilyRelationStudent family = cFamilyRelationStudentMapper.selectById(familyId);
|
|
|
|
|
|
//创建返回值 并 添加数据
|
|
|
CFamilyRelationStudentVo familyVo = new CFamilyRelationStudentVo();
|
|
|
BeanUtils.copyProperties(family,familyVo);
|
|
|
|
|
|
//判断 等于null 没有名字
|
|
|
if (family.getName()==null){
|
|
|
|
|
|
//添加家长的 用户名
|
|
|
CUser cUserFamily = cUserMapper.selectById(family.getUserId());
|
|
|
familyVo.setName(cUserFamily.getUserName());
|
|
|
}
|
|
|
|
|
|
return AjaxResult.success(familyVo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改家庭关系信息
|
|
|
* @param bo
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public AjaxResult updateFamily(CFamilyRelationStudentBo bo) {
|
|
|
|
|
|
CFamilyRelationStudent family = new CFamilyRelationStudent();
|
|
|
BeanUtils.copyProperties(bo,family);
|
|
|
|
|
|
cFamilyRelationStudentMapper.updateById(family);
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除家庭关系信息
|
|
|
* @param familyId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult deleteFamily(Long familyId) {
|
|
|
|
|
|
//根据登录人ID查询用户表
|
|
|
Long uId = UserContext.currentUserId();
|
|
|
CUser cUser = cUserMapper.selectById(uId);
|
|
|
|
|
|
//判断 等于2 身份为学生
|
|
|
if (cUser.getIdentityType()==2){
|
|
|
|
|
|
return AjaxResult.success("你没有删除权限");
|
|
|
}
|
|
|
|
|
|
//删除家庭关系信息
|
|
|
cFamilyRelationStudentMapper.deleteById(familyId);
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加家庭关系信息
|
|
|
* @param bo
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult saveFamily(CFamilyRelationStudentBo bo) {
|
|
|
|
|
|
//根据登录人ID查询用户表
|
|
|
Long uId = UserContext.currentUserId();
|
|
|
CUser cUser = cUserMapper.selectById(uId);
|
|
|
|
|
|
//判断 等于2 身份为学生
|
|
|
if (cUser.getIdentityType()==2){
|
|
|
|
|
|
return AjaxResult.success("你没有添加权限");
|
|
|
}
|
|
|
|
|
|
//添加信息到数据库
|
|
|
CFamilyRelationStudent family = new CFamilyRelationStudent();
|
|
|
BeanUtils.copyProperties(bo,family);
|
|
|
family.setCreatorTime(LocalDateTime.now());
|
|
|
|
|
|
cFamilyRelationStudentMapper.insert(family);
|
|
|
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
} |
...
|
...
|
|