package com.ruoyi.service.impl;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
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.utils.MapUtils;
|
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 java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
/**
|
* <p>
|
* 服务实现类
|
* </p>
|
*
|
* @author ojq
|
* @since 2023-03-14
|
*/
|
@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) {
|
|
LambdaQueryWrapper<ZInfoUser> lqw = buildCondition(zInfoUser);
|
|
Page<ZInfoUser> zInfoUserPage = new Page<>(pageNum,pageSize);
|
Page<ZInfoUser> pageResult = page(zInfoUserPage, lqw);
|
|
HashMap<String, Object> data = MapUtils.getResult(pageResult);
|
return AjaxResult.success(data);
|
|
}
|
|
private LambdaQueryWrapper<ZInfoUser> buildCondition(ZInfoUser zInfoUser) {
|
|
LambdaQueryWrapper<ZInfoUser> lqw = new LambdaQueryWrapper<>();
|
lqw.eq(zInfoUser.getUserId()!=null,ZInfoUser::getUserId,zInfoUser.getUserId());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getAlwaysAddress()),ZInfoUser::getAlwaysAddress,zInfoUser.getAlwaysAddress());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getAlwaysPolice()),ZInfoUser::getAlwaysPolice,zInfoUser.getAlwaysPolice());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getIdNum()),ZInfoUser::getIdNum,zInfoUser.getIdNum());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getLocationAddress()),ZInfoUser::getLocationAddress,zInfoUser.getLocationAddress());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getLocationPolice()),ZInfoUser::getLocationPolice,zInfoUser.getLocationPolice());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getNation()),ZInfoUser::getNation,zInfoUser.getNation());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getNationality()),ZInfoUser::getNationality,zInfoUser.getNationality());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getNickName()),ZInfoUser::getNickName,zInfoUser.getNickName());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getOldName()),ZInfoUser::getOldName,zInfoUser.getOldName());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getPhoneNumber()),ZInfoUser::getPhoneNumber,zInfoUser.getPhoneNumber());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getPoliticalOutlook()),ZInfoUser::getPoliticalOutlook,zInfoUser.getPoliticalOutlook());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getPosition()),ZInfoUser::getPosition,zInfoUser.getPosition());
|
lqw.like(StringUtils.isNotEmpty(zInfoUser.getUnit()),ZInfoUser::getUnit,zInfoUser.getUnit());
|
lqw.like(zInfoUser.getSex()!=null,ZInfoUser::getSex,zInfoUser.getSex());
|
lqw.like(zInfoUser.getMaritalStatus()!=null,ZInfoUser::getMaritalStatus,zInfoUser.getMaritalStatus());
|
lqw.like(zInfoUser.getBirth()!=null,ZInfoUser::getBirth,zInfoUser.getBirth());
|
return lqw;
|
|
}
|
|
@Override
|
public List<ZInfoUser> selectByCondition(ZInfoUser zInfoUser) {
|
LambdaQueryWrapper<ZInfoUser> lambdaQueryWrapper = buildCondition(zInfoUser);
|
List<ZInfoUser> list = list(lambdaQueryWrapper);
|
log.info("返回的数据为:{}",list);
|
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());
|
otherUserList.add(userRelationDto);
|
return relation;
|
}
|
).collect(Collectors.toList());
|
|
return AjaxResult.success(otherUserList);
|
}
|
}
|