| | |
| | | import com.highdatas.mdm.entity.TUser;
|
| | | import com.highdatas.mdm.entity.TUserGroup;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.HttpMethod;
|
| | |
| | | import org.springframework.stereotype.Component;
|
| | | import org.springframework.util.StringUtils;
|
| | |
|
| | | import java.util.HashMap;
|
| | | import java.util.LinkedHashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.*;
|
| | |
|
| | | @ConfigurationProperties(prefix = "user")
|
| | | @Component
|
| | |
| | | String url;
|
| | |
|
| | | String prefix ;
|
| | | @Autowired
|
| | | RedisClient redisClient;
|
| | |
|
| | | public UserRoleClient() {
|
| | | this.prefix = "/api/datacvg/";
|
| | | }
|
| | |
|
| | | public TUser getTUserById(String userId) {
|
| | | Object redisValObj = redisClient.getRedisValObj(RedisClient.getRealRedisKey(userId));
|
| | | if (redisValObj != null) {
|
| | | JSONObject object = (JSONObject) redisValObj;
|
| | | TUser user = JSONObject.parseObject(object.toJSONString(), TUser.class);
|
| | | return user;
|
| | | }
|
| | | String url = this.url + prefix + "user/selectUser";
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | |
| | | if (user == null){
|
| | | return null;
|
| | | }
|
| | | redisClient.putRedisValObj(RedisClient.getRealRedisKey(userId), user);
|
| | | return user;
|
| | | }
|
| | | }
|
| | |
|
| | | public TRole getRoleByRoleId(String roleId) {
|
| | | Object redisValObj = redisClient.getRedisValObj(RedisClient.getRealRedisKey(roleId));
|
| | | if (redisValObj != null) {
|
| | | JSONObject object = (JSONObject) redisValObj;
|
| | | TRole user = JSONObject.parseObject(object.toJSONString(), TRole.class);
|
| | | return user;
|
| | | }
|
| | | try {
|
| | | String url = this.url + prefix + "role/selectRole";
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | |
| | | if (role == null){
|
| | | return null;
|
| | | }
|
| | | redisClient.putRedisValObj(RedisClient.getRealRedisKey(roleId), role);
|
| | | return role;
|
| | | }
|
| | | }catch (Exception e){
|
| | |
| | | }
|
| | |
|
| | | public List<TUserGroup> getUserGroupByUserId(String userId) {
|
| | |
|
| | | String key = RedisClient.getRealRedisKey(userId + "-getUserGroupByUserId");
|
| | | List<Object> redisList = redisClient.getRedisList(key);
|
| | | if (redisList != null && !redisList.isEmpty()) {
|
| | | List<TUserGroup> result = new ArrayList<>();
|
| | | for (Object o : redisList) {
|
| | | JSONObject object = (JSONObject) o;
|
| | | TUserGroup menu = JSONObject.parseObject(object.toJSONString(), TUserGroup.class);
|
| | | result.add(menu);
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | String url = this.url + prefix + "group/userGroupInfo";
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | |
| | | if (tUserGroups == null || tUserGroups.isEmpty()) {
|
| | | return null;
|
| | | }
|
| | | redisClient.putRedisList(key, (tUserGroups));
|
| | | return tUserGroups;
|
| | | }
|
| | | }
|
| | |
|
| | | public List<TRole> getTRoleListByUserId(String userId) {
|
| | |
|
| | | String key = RedisClient.getRealRedisKey(userId + "-getTRoleListByUserId");
|
| | | List<Object> redisList = redisClient.getRedisList(key);
|
| | | if (redisList != null && !redisList.isEmpty()) {
|
| | | List<TRole> result = new ArrayList<>();
|
| | | for (Object o : redisList) {
|
| | | JSONObject object = (JSONObject) o;
|
| | | TRole menu = JSONObject.parseObject(object.toJSONString(), TRole.class);
|
| | | result.add(menu);
|
| | | }
|
| | | return result;
|
| | | }
|
| | | String url = this.url + prefix + "userRole/selectUserRoleList";
|
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | |
| | | if (tRoles == null || tRoles.isEmpty()) {
|
| | | return null;
|
| | | }
|
| | | redisClient.putRedisList(key, tRoles);
|
| | | return tRoles;
|
| | | }
|
| | | }
|
| | |
|
| | | public List<TRole> getRoleListByGroupId(String groupId) {
|
| | | String key = RedisClient.getRealRedisKey(groupId + "-getTRoleListByUserId");
|
| | | List<Object> redisList = redisClient.getRedisList(key);
|
| | | if (redisList != null && !redisList.isEmpty()) {
|
| | | List<TRole> result = new ArrayList<>();
|
| | | for (Object o : redisList) {
|
| | | JSONObject object = (JSONObject) o;
|
| | | TRole menu = JSONObject.parseObject(object.toJSONString(), TRole.class);
|
| | | result.add(menu);
|
| | | }
|
| | | return result;
|
| | | }
|
| | | try {
|
| | | String url = this.url + prefix + "group/groupRoleInfo";
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | |
| | | if (role == null || role.isEmpty()){
|
| | | return null;
|
| | | }
|
| | | redisClient.putRedisList(key, role);
|
| | | return role;
|
| | | }
|
| | | }catch (Exception e){
|
| | |
| | | }
|
| | |
|
| | | public List<String> getUserListByRole(String roleId) {
|
| | | String key = RedisClient.getRealRedisKey(roleId + "-getUserListByRole");
|
| | | List<Object> redisList = redisClient.getRedisList(key);
|
| | | if (redisList != null && !redisList.isEmpty()) {
|
| | | List<String> result = new ArrayList<>();
|
| | | for (Object o : redisList) {
|
| | | result.add(o.toString());
|
| | | }
|
| | | return result;
|
| | | }
|
| | | try {
|
| | | String url = this.url + prefix + "userRole/selectUserMap";
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | |
| | | }
|
| | | List<String> array = result.getObject(Constant.Data, List.class);
|
| | |
|
| | | redisClient.putRedisList(key,array);
|
| | | return array;
|
| | | }catch (Exception e){
|
| | | e.printStackTrace();
|