|
@@ -1,26 +1,39 @@
|
|
package cn.cslg.pas.service;
|
|
package cn.cslg.pas.service;
|
|
|
|
|
|
import cn.cslg.pas.common.model.BaseEntity;
|
|
import cn.cslg.pas.common.model.BaseEntity;
|
|
|
|
+import cn.cslg.pas.common.model.vo.TenantVo;
|
|
|
|
+import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
|
|
|
|
+import cn.cslg.pas.domain.Client;
|
|
import cn.cslg.pas.domain.Department;
|
|
import cn.cslg.pas.domain.Department;
|
|
import cn.cslg.pas.common.model.vo.UserVO;
|
|
import cn.cslg.pas.common.model.vo.UserVO;
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
import cn.cslg.pas.common.utils.DateUtils;
|
|
import cn.cslg.pas.common.utils.DateUtils;
|
|
import cn.cslg.pas.common.utils.Response;
|
|
import cn.cslg.pas.common.utils.Response;
|
|
import cn.cslg.pas.common.utils.StringUtils;
|
|
import cn.cslg.pas.common.utils.StringUtils;
|
|
|
|
+import cn.cslg.pas.domain.Project;
|
|
import cn.cslg.pas.domain.User;
|
|
import cn.cslg.pas.domain.User;
|
|
import cn.cslg.pas.mapper.UserMapper;
|
|
import cn.cslg.pas.mapper.UserMapper;
|
|
import cn.hutool.crypto.SecureUtil;
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
+import okhttp3.FormBody;
|
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
|
+import okhttp3.Request;
|
|
|
|
+import okhttp3.RequestBody;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -38,6 +51,10 @@ public class UserService extends ServiceImpl<UserMapper, User> {
|
|
private final DepartmentService departmentService;
|
|
private final DepartmentService departmentService;
|
|
private final CacheUtils cacheUtils;
|
|
private final CacheUtils cacheUtils;
|
|
private final ProjectUserService projectUserService;
|
|
private final ProjectUserService projectUserService;
|
|
|
|
+ private final ProjectService projectService;
|
|
|
|
+ private final ClientService clientService;
|
|
|
|
+ @Value("${authorUrl}")
|
|
|
|
+ private String url;
|
|
|
|
|
|
public User getByUsername(String username) {
|
|
public User getByUsername(String username) {
|
|
return this.getOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, username));
|
|
return this.getOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, username));
|
|
@@ -61,31 +78,66 @@ public class UserService extends ServiceImpl<UserMapper, User> {
|
|
return this.list(queryWrapper);
|
|
return this.list(queryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
- public IPage<User> getPageList(UserVO params) {
|
|
|
|
- LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
- if (StringUtils.isNotEmpty(params.getName())) {
|
|
|
|
- queryWrapper.like(User::getName, params.getName());
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotEmpty(params.getUsername())) {
|
|
|
|
- queryWrapper.like(User::getUsername, params.getUsername());
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotEmpty(params.getProjectId())) {
|
|
|
|
- List<Integer> userIds = projectUserService.getProjectUserIdByProjectId(Integer.parseInt(params.getProjectId()));
|
|
|
|
- if (userIds.size() != 0) {
|
|
|
|
- queryWrapper.notIn(User::getId, userIds);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- IPage<User> pageList = this.page(new Page<>(params.getCurrent(), params.getSize()), queryWrapper);
|
|
|
|
- List<Department> departmentList = departmentService.getDepartmentByIds(pageList.getRecords().stream().map(User::getDeptId).collect(Collectors.toList()));
|
|
|
|
- pageList.getRecords().forEach(item -> {
|
|
|
|
- item.setPassword(null);
|
|
|
|
- Department department = departmentList.stream().filter(dept -> dept.getId().equals(item.getDeptId())).findFirst().orElse(null);
|
|
|
|
- if (department != null) {
|
|
|
|
- item.setDeptName(department.getName());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- return pageList;
|
|
|
|
|
|
+ public String getPageList(UserVO params) throws IOException {
|
|
|
|
+ //查询数据规则
|
|
|
|
+ //设定formdata类型参数
|
|
|
|
+ Project project = projectService.getProjectById(params.getProjectId());
|
|
|
|
+ int tentId = project.getTenantId();
|
|
|
|
+ List<Client> clients = clientService.getClientBytenant(tentId);
|
|
|
|
+ List<String> tenantNames = new ArrayList<>();
|
|
|
|
+ clients.forEach(item->{ tenantNames.add(item.getName());});
|
|
|
|
+ String names = JSON.toJSONString (tenantNames);
|
|
|
|
+ String name ="";
|
|
|
|
+ name = params.getName()==null? name:params.getName();
|
|
|
|
+ RequestBody requestBody = new FormBody.Builder()
|
|
|
|
+ .add("tenantId", tentId+"" )
|
|
|
|
+ .add("tenantNames",names)
|
|
|
|
+ .add("tenantName",name)
|
|
|
|
+ .add("current",params.getCurrent().toString())
|
|
|
|
+ .add("size",params.getSize().toString())
|
|
|
|
+ .build();
|
|
|
|
+ //建立连接
|
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
+ .url(url + "/permission/api/system/getTenantMessage")
|
|
|
|
+ .post(requestBody)
|
|
|
|
+ .addHeader("Cookie", LoginUtils.getToken())
|
|
|
|
+ .build();
|
|
|
|
+ //获得请求返回
|
|
|
|
+ String resBody = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
|
+
|
|
|
|
+return resBody;
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ public String getPersonnelList(UserVO params) throws IOException {
|
|
|
|
+ //查询数据规则
|
|
|
|
+ //设定formdata类型参数
|
|
|
|
+ List<Client> clients = clientService.getClientBytenant(params.getTenantId());
|
|
|
|
+ List<String> tenantNames = new ArrayList<>();
|
|
|
|
+ clients.forEach(item->{ tenantNames.add(item.getName());});
|
|
|
|
+ String name ="";
|
|
|
|
+ name = params.getName()==null? name:params.getName();
|
|
|
|
+ RequestBody requestBody = new FormBody.Builder()
|
|
|
|
+ .add("tenantId", params.getTenantId()+"" )
|
|
|
|
+ .add("personnelName",name)
|
|
|
|
+ .add("current",params.getCurrent().toString())
|
|
|
|
+ .add("size",params.getSize().toString())
|
|
|
|
+ .build();
|
|
|
|
+ //建立连接
|
|
|
|
+ OkHttpClient okHttpClient = new OkHttpClient();
|
|
|
|
+ Request request = new Request.Builder()
|
|
|
|
+ .url(url + "/permission/api/system/getPersonneltMessage")
|
|
|
|
+ .post(requestBody)
|
|
|
|
+ .addHeader("Cookie", LoginUtils.getToken())
|
|
|
|
+ .build();
|
|
|
|
+ //获得请求返回
|
|
|
|
+ String resBody = Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
|
|
|
|
+
|
|
|
|
+ return resBody;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
public String add(User user) {
|
|
public String add(User user) {
|
|
User temp = this.getByUsername(user.getUsername());
|
|
User temp = this.getByUsername(user.getUsername());
|