111
Jinquan_Ou
2023-04-08 1836f7863882ceae0e5c246556196be48bd12384
111
8个文件已修改
117 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/ZfRelation.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/dto/UserRelationDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/ZInfoUserService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipmentServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/zhang/ZInfoUserController.java
@@ -11,6 +11,7 @@
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.ZfRelation;
import com.ruoyi.service.ZInfoUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
@@ -146,7 +147,6 @@
    /**
     * 查询家庭主要成员及关系
     */
    @GetMapping("/relation")
    public AjaxResult listMyRelation() {
        SysUser user = SecurityUtils.getLoginUser().getUser();
@@ -154,6 +154,22 @@
        return zInfoUserService.searchMyRelation(userId);
    }
    @PostMapping("/relation")
    public AjaxResult addRelation(@RequestBody ZfRelation zfRelation){
        return zInfoUserService.addRelation(zfRelation);
    }
    @PutMapping("/relation")
    public AjaxResult updateRelation(@RequestBody ZfRelation zfRelation){
        return zInfoUserService.updateRelation(zfRelation);
    }
    @DeleteMapping("/relation/{ids}")
    public AjaxResult deleteRelation(@PathVariable Long[] ids){
        return zInfoUserService.deleteRelation(ids);
    }
}
zhang-content/src/main/java/com/ruoyi/domain/ZfRelation.java
@@ -1,5 +1,7 @@
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.ToString;
@@ -15,8 +17,12 @@
public class ZfRelation implements Serializable {
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    private Long myId;
    private Long otherId;
    private String relation;
}
zhang-content/src/main/java/com/ruoyi/domain/dto/UserRelationDto.java
@@ -17,6 +17,8 @@
    private static final long serialVersionUID = 1L;
    private Long id;
    /**
     * 名字
     */
zhang-content/src/main/java/com/ruoyi/service/ZInfoUserService.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.ZfRelation;
import java.util.List;
@@ -20,4 +21,10 @@
    List<ZInfoUser> selectByCondition(ZInfoUser zInfoUser);
    AjaxResult searchMyRelation(Long userId);
    AjaxResult addRelation(ZfRelation zfRelation);
    AjaxResult updateRelation(ZfRelation zfRelation);
    AjaxResult deleteRelation(Long[] ids);
}
zhang-content/src/main/java/com/ruoyi/service/impl/IZfPropertyServiceImpl.java
@@ -28,6 +28,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@@ -57,13 +58,14 @@
    private LambdaQueryWrapper<ZfProperty> buildCondition(ZfProperty zfProperty) {
        LambdaQueryWrapper<ZfProperty> lqw = new LambdaQueryWrapper<>();
        lqw.like(!StringUtils.isEmpty(zfProperty.getType()),ZfProperty::getType, zfProperty.getType());
        lqw.like(!StringUtils.isEmpty(zfProperty.getTitle()),ZfProperty::getTitle, zfProperty.getTitle());
        lqw.like(!StringUtils.isEmpty(zfProperty.getLocation()),ZfProperty::getLocation, zfProperty.getLocation());
        lqw.like(!StringUtils.isEmpty(zfProperty.getHolder()),ZfProperty::getHolder, zfProperty.getHolder());
        lqw.like(!StringUtils.isEmpty(zfProperty.getAddress()),ZfProperty::getAddress, zfProperty.getAddress());
        lqw.like(!StringUtils.isEmpty(zfProperty.getRemark()),ZfProperty::getRemark, zfProperty.getRemark());
        lqw.like(zfProperty.getCreateTime()!=null,ZfProperty::getCreateTime, zfProperty.getCreateTime());
        lqw.like(!StringUtils.isEmpty(zfProperty.getType()), ZfProperty::getType, zfProperty.getType())
                .like(!StringUtils.isEmpty(zfProperty.getTitle()), ZfProperty::getTitle, zfProperty.getTitle())
                .like(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation())
                .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder())
                .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress())
                .like(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark())
                .like(zfProperty.getCreateTime() != null, ZfProperty::getCreateTime, zfProperty.getCreateTime());
        return lqw;
    }
@@ -71,9 +73,7 @@
        LambdaQueryWrapper<ZfProperty> lqw = buildCondition(zfProperty);
        if (familyIds.contains(",")) {
            String[] familyList = familyIds.split(",");
            for (String familyId : familyList) {
                lqw.or().eq(ZfProperty::getFamilyId,familyId);
            }
            lqw.in(ZfProperty::getFamilyId,familyList);
        }else {
            lqw.eq(ZfProperty::getFamilyId,familyIds);
        }
zhang-content/src/main/java/com/ruoyi/service/impl/ZInfoUserServiceImpl.java
@@ -6,7 +6,9 @@
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;
@@ -19,8 +21,10 @@
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;
@@ -102,6 +106,7 @@
                    UserRelationDto userRelationDto = new UserRelationDto();
                    BeanUtils.copyProperties(otherUser,userRelationDto);
                    userRelationDto.setRelation(relation.getRelation());
                    userRelationDto.setId(relation.getId());
                    otherUserList.add(userRelationDto);
                    return relation;
                }
@@ -109,4 +114,53 @@
        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("对方的id不存在");
        }
    }
    @Override
    @Transactional
    public AjaxResult addRelation(ZfRelation zfRelation) {
        checkRelation(zfRelation);
        //获取自己的id并传入
        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();
        }
    }
}
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipmentServiceImpl.java
@@ -111,9 +111,8 @@
        LambdaQueryWrapper<ZfEquipment> lqw = buildCondition(zfEquipment);
        if (familyIds.contains(",")) {
            String[] familyList = familyIds.split(",");
            for (String familyId : familyList) {
                lqw.or().eq(ZfEquipment::getFamilyId, familyId);
            }
            lqw.in(ZfEquipment::getFamilyId,familyList);
        } else {
            lqw.eq(ZfEquipment::getFamilyId, familyIds);
        }
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEventServiceImpl.java
@@ -13,6 +13,7 @@
import com.ruoyi.domain.ZInfoUser;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.domain.ZfEvent;
import com.ruoyi.domain.ZfProperty;
import com.ruoyi.mapper.ZfEventMapper;
import com.ruoyi.service.ZInfoUserService;
import com.ruoyi.service.ZfEventService;
@@ -130,9 +131,7 @@
        LambdaQueryWrapper<ZfEvent> lqw = buildCondition(zfEvent);
        if (familyIds.contains(",")) {
            String[] familyList = familyIds.split(",");
            for (String familyId : familyList) {
                lqw.or().eq(ZfEvent::getFamilyId,familyId);
            }
            lqw.in(ZfEvent::getFamilyId,familyList);
        }else {
            lqw.eq(ZfEvent::getFamilyId,familyIds);
        }