From 3cd5c749ca237103a5014e902ce21b7148b9b6e3 Mon Sep 17 00:00:00 2001
From: Jinquan_Ou <Jinquan@gdut.com>
Date: 星期六, 08 四月 2023 12:46:39 +0800
Subject: [PATCH] aaa
---
zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java | 88 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java
index 3895d1b..9fa02f2 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java
@@ -6,17 +6,28 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.MapUtils;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.ZfEvent;
+import com.ruoyi.domain.ZfRelation;
+import com.ruoyi.domain.dto.UserRelationDto;
import com.ruoyi.mapper.ZInfoUserMapper;
import com.ruoyi.service.ZInfoUserService;
+import com.ruoyi.service.ZfRelationService;
import lombok.extern.slf4j.Slf4j;
+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.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.stream.Collectors;
/**
* <p>
@@ -29,6 +40,9 @@
@Service
@Slf4j
public class ZInfoUserServiceImpl extends ServiceImpl<ZInfoUserMapper, ZInfoUser> implements ZInfoUserService {
+
+ @Autowired
+ private ZfRelationService zfRelationService;
@Override
public AjaxResult selectInfoList(ZInfoUser zInfoUser, Integer pageNum, Integer pageSize) {
@@ -75,4 +89,78 @@
return list;
}
+
+ @Override
+ public AjaxResult searchMyRelation(Long userId) {
+
+ LambdaQueryWrapper<ZfRelation> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZfRelation::getMyId,userId);
+ List<ZfRelation> relationList = zfRelationService.list(lqw);
+
+ ArrayList<UserRelationDto> otherUserList = new ArrayList<>();
+
+ relationList.stream().map(
+ (relation)->{
+ Long otherId = relation.getOtherId();
+ ZInfoUser otherUser = getById(otherId);
+ UserRelationDto userRelationDto = new UserRelationDto();
+ BeanUtils.copyProperties(otherUser,userRelationDto);
+ userRelationDto.setRelation(relation.getRelation());
+ userRelationDto.setId(relation.getId());
+ otherUserList.add(userRelationDto);
+ return relation;
+ }
+ ).collect(Collectors.toList());
+
+ return AjaxResult.success(otherUserList);
+ }
+
+ /**
+ * 妫�鏌ヤ紶鍏ュ鏂圭殑id鏄惁瀛樺湪
+ * @param zfRelation
+ */
+ private void checkRelation(ZfRelation zfRelation){
+
+ LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZInfoUser::getUserId, zfRelation.getOtherId());
+
+ ZInfoUser zInfoUser2 = getOne(lqw);
+ if (zInfoUser2==null){
+ throw new RuntimeException("瀵规柟鐨刬d涓嶅瓨鍦�");
+ }
+ }
+
+ @Override
+ @Transactional
+ public AjaxResult addRelation(ZfRelation zfRelation) {
+ checkRelation(zfRelation);
+
+ //鑾峰彇鑷繁鐨刬d骞朵紶鍏�
+ SysUser user = SecurityUtils.getLoginUser().getUser();
+ Long userId = user.getUserId();
+ zfRelation.setMyId(userId);
+
+ zfRelationService.save(zfRelation);
+ return AjaxResult.success();
+ }
+
+ @Override
+ @Transactional
+ public AjaxResult updateRelation(ZfRelation zfRelation) {
+ checkRelation(zfRelation);
+ zfRelationService.updateById(zfRelation);
+ return AjaxResult.success();
+ }
+
+ @Override
+ public AjaxResult deleteRelation(Long[] ids) {
+ boolean flag = zfRelationService.removeByIds(Arrays.asList(ids));
+ if (flag){
+ return AjaxResult.success();
+ }else {
+ return AjaxResult.error();
+ }
+ }
+
+
}
--
Gitblit v1.9.1