|
|
|
@ -1,13 +1,26 @@
|
|
|
|
|
package com.hnac.hzinfo.inspect.obj.services.impl; |
|
|
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.obj.mapper.ObjectUserMapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.entity.ObjectUserEntity; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.mapper.ObjectUserMapper; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.services.ObjectUserService; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.vo.ObjectUserListQuery; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.hnac.hzinfo.inspect.obj.vo.ObjectUserListVO; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.constant.BladeConstant; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 服务实现类 |
|
|
|
@ -15,10 +28,51 @@ import java.util.List;
|
|
|
|
|
* @author Chill |
|
|
|
|
*/ |
|
|
|
|
@Service |
|
|
|
|
@RequiredArgsConstructor |
|
|
|
|
public class ObjectUserServiceImpl extends ServiceImpl<ObjectUserMapper, ObjectUserEntity> implements ObjectUserService { |
|
|
|
|
|
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<ObjectUserListQuery> getPageList(ObjectUserListQuery user){ |
|
|
|
|
return this.baseMapper.getPageList(user); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询列表 |
|
|
|
|
* @param content |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public List<ObjectUserListVO> users(ObjectUserListQuery content) { |
|
|
|
|
if(!AuthUtil.getTenantId().equals(BladeConstant.ADMIN_TENANT_ID)){ |
|
|
|
|
content.setTenantId(AuthUtil.getTenantId()); |
|
|
|
|
} |
|
|
|
|
List<ObjectUserListQuery> objectUsers = this.getPageList(content); |
|
|
|
|
if(objectUsers.isEmpty()){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
R<List<User>> users = userClient.userListByCodeAndNameAndAccount(AuthUtil.getTenantId(),content.getUserCode(),content.getUserName(),content.getLoginName()); |
|
|
|
|
if(!users.isSuccess() || CollectionUtil.isEmpty(users.getData())){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
Map<Long,User> userMap = users.getData().stream().collect(Collectors.toMap(User::getId, Function.identity())); |
|
|
|
|
return objectUsers.stream().map(objectUser->{ |
|
|
|
|
ObjectUserListVO builder = new ObjectUserListVO(); |
|
|
|
|
builder.setId(objectUser.getId()); |
|
|
|
|
builder.setObjCode(objectUser.getObjCode()); |
|
|
|
|
builder.setObjName(objectUser.getObjName()); |
|
|
|
|
builder.setTempCode(objectUser.getTempCode()); |
|
|
|
|
builder.setTempName(objectUser.getTempName()); |
|
|
|
|
User user = userMap.get(objectUser.getUserId()); |
|
|
|
|
if(ObjectUtil.isNotEmpty(user)){ |
|
|
|
|
builder.setUserCode(user.getCode()); |
|
|
|
|
builder.setUserName(user.getRealName()); |
|
|
|
|
builder.setLoginName(user.getAccount()); |
|
|
|
|
builder.setUserId(user.getId()); |
|
|
|
|
} |
|
|
|
|
return builder; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|