作者 mxy

家庭关系 增,删,改,查

package com.example.client.controller;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.domain.bo.CFamilyRelationStudentBo;
import com.example.client.service.FamilyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created with IDEA
* author: MaDongXu
* Date:2021/9/16
* Time:15:07
* */
@Slf4j
@Api(tags = "家庭关系")
@Validated
@RestController
@RequestMapping("/tree/family")
public class FamilyController {
@Autowired
private FamilyService familyService;
@ApiOperation("查看家庭关系")
@PostMapping("/selectFamily")
public AjaxResult selectFamilies(){
return familyService.selectFamilies();
}
@ApiImplicitParam(name = "familyId",value = "家庭关系表的Id",dataType = "Long",required = true,paramType = "query")
@ApiOperation("获取要修改的家庭关系")
@PostMapping("/getFamilyInfo")
public AjaxResult getFamilyInfo(Long familyId){
log.info("<<<接收到的参数<<<::"+familyId);
return familyService.getFamilyInfo(familyId);
}
@ApiOperation("修改家庭关系信息")
@PostMapping("/updateFamily")
public AjaxResult updateFamily(@RequestBody CFamilyRelationStudentBo bo){
log.info("<<<接收的参数<<<::"+bo);
return familyService.updateFamily(bo);
}
@ApiImplicitParam(name = "familyId",value = "家庭关系表Id",dataType = "Long",required = true,paramType = "query")
@ApiOperation("删除家庭关系信息")
@PostMapping("/deleteFamily")
public AjaxResult deleteFamily(Long familyId){
log.info("<<<接收到的参数<<<::"+familyId);
return familyService.deleteFamily(familyId);
}
@ApiOperation("添加家庭关系信息")
@PostMapping("/saveFamily")
public AjaxResult saveFamily(@RequestBody CFamilyRelationStudentBo bo){
log.info("<<<接收到的参数<<<::"+bo);
return familyService.saveFamily(bo);
}
}
... ...
... ... @@ -4,6 +4,8 @@ package com.example.client.mapper;
import cn.bronet.admin.common.core.mybatisplus.core.BaseMapperPlus;
import com.example.client.domain.CFamilyRelationStudent;
import java.util.List;
/**
* 家庭关系表Mapper接口
*
... ... @@ -12,4 +14,5 @@ import com.example.client.domain.CFamilyRelationStudent;
*/
public interface CFamilyRelationStudentMapper extends BaseMapperPlus<CFamilyRelationStudent> {
List<CFamilyRelationStudent> getAllFamilies(Long uId);
}
... ...
... ... @@ -15,22 +15,48 @@ import org.springframework.web.multipart.MultipartFile;
*/
public interface ActivityService {
/*发布动态的初始化页面接口*/
/**
* 发布动态的初始化页面接口
* @param type
* @return
*/
AjaxResult sendActivity(Integer type);
/*存储发布动态的接口*/
/**
* 存储发布动态的接口
* @param bo
* @return
*/
AjaxResult saveActivity(CActivityBo bo);
/*删除用户发布的动态*/
/**
* 删除用户发布的动态
* @param activityId
* @return
*/
AjaxResult deleteActivity(Long activityId);
/*查询用户的动态*/
/**
* 查询用户的动态
* @param type
* @param userId
* @return
*/
AjaxResult selectActivities(Integer type,Long userId);
/*首页动态查询*/
/**
* 首页动态查询
* @param typeId
* @param identity
* @return
*/
AjaxResult selectAllActivities(Integer typeId,Integer identity);
/*查看单条数据*/
/**
* 查看单条数据
* @param activityId
* @return
*/
AjaxResult selectActivity(Long activityId);
}
... ...
... ... @@ -5,11 +5,24 @@ import com.example.client.domain.bo.CCommentsBo;
public interface CommentService {
//存储动态的评论
/**
* 存储动态的评论
* @param bo
* @return
*/
AjaxResult saveComment(CCommentsBo bo);
//打开动态的所有评论
/**
* 打开动态的所有评论
* @param activityId
* @return
*/
AjaxResult openComment(Long activityId);
/**
* 删除评论
* @param commentId
* @return
*/
AjaxResult deleteComment(Long commentId);
}
... ...
package com.example.client.service;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.domain.bo.CFamilyRelationStudentBo;
import com.example.client.domain.bo.MyAuthentication;
/**
... ... @@ -10,5 +11,41 @@ import com.example.client.domain.bo.MyAuthentication;
* Time:19:10
*/
public interface FamilyService {
AjaxResult bindingFamily(MyAuthentication myAuthentication ,Long userId);
/**
* 查询所有家庭关系
* @return
*/
AjaxResult selectFamilies();
/**
* 获取要修改的家庭关系信息
* @param familyId
* @return
*/
AjaxResult getFamilyInfo(Long familyId);
/**
* 修改家庭关系信息
* @param bo
* @return
*/
AjaxResult updateFamily(CFamilyRelationStudentBo bo);
/**
* 删除家庭关系信息
* @param familyId
* @return
*/
AjaxResult deleteFamily(Long familyId);
/**
* 添加家庭关系信息
* @param bo
* @return
*/
AjaxResult saveFamily(CFamilyRelationStudentBo bo);
}
... ...
... ... @@ -11,6 +11,10 @@ import com.example.client.domain.bo.CFollowerBo;
* */
public interface FollowerService {
//关注和取消关注
/**
* 关注和取消关注
* @param bo
* @return
*/
AjaxResult follower(CFollowerBo bo);
}
... ...
... ... @@ -11,9 +11,17 @@ import com.example.client.domain.bo.CGetLikeBo;
* */
public interface GetLikeService {
//点赞和取消点赞
/**
* 点赞和取消点赞
* @param bo
* @return
*/
AjaxResult like(CGetLikeBo bo);
//转发
/**
* 转发
* @param activityId
* @return
*/
AjaxResult transmit(Long activityId);
}
... ...
... ... @@ -11,15 +11,28 @@ import lombok.extern.slf4j.Slf4j;
* */
public interface MessageService {
//谁@了我
/**
* 谁@了我
* @return
*/
AjaxResult atMe();
//谁赞了我
/**
* 谁赞了我
* @return
*/
AjaxResult likeMe();
//谁评论了我
/**
* 谁评论了我
* @return
*/
AjaxResult commentMe();
//查看消息
/**
* 查看消息
* @param messageId
* @return
*/
AjaxResult openMessage(Long messageId);
}
... ...
... ... @@ -11,10 +11,17 @@ import com.example.client.domain.bo.CMycollectBo;
* */
public interface MyCollectService {
//收藏
/**
* 收藏
* @param bo
* @return
*/
AjaxResult collect(CMycollectBo bo);
//查询我的收藏
/**
* 查询我的收藏
* @return
*/
AjaxResult getMyCollect();
}
... ...
... ... @@ -303,6 +303,8 @@ public class ActivityServiceImpl extends ServicePlusImpl<CActivityMapper,CActivi
Long userId = UserContext.currentUserId();
CUser cUser1 = cUserMapper.selectById(userId);
LambdaQueryWrapper<CActivity> cActivityWrapper;
//判断首页展示的种类
... ...
... ... @@ -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();
}
}
... ...
... ... @@ -10,7 +10,6 @@ import com.example.client.domin.UserContext;
import com.example.client.mapper.*;
import com.example.client.service.MineService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ...
... ... @@ -14,5 +14,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="company" column="company"/>
</resultMap>
<select id="getAllFamilies" resultMap="CFamilyRelationStudentResult">
SELECT * From c_family_relation_student WHERE subclass_id =#{uid};
</select>
</mapper>
... ...