| | |
| | | import com.highdatas.mdm.entity.TRole;
|
| | | import com.highdatas.mdm.entity.TUser;
|
| | | import com.highdatas.mdm.entity.TUserGroup;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.boot.context.properties.ConfigurationProperties;
|
| | | import org.springframework.http.HttpMethod;
|
| | |
| | |
|
| | | @ConfigurationProperties(prefix = "user")
|
| | | @Component
|
| | | @Slf4j
|
| | | public class UserRoleClient {
|
| | |
|
| | | @Value("${user.url}")
|
| | |
| | | Map<String, String> params = new LinkedHashMap<>();
|
| | | params.put("userId",userId);
|
| | | String s = HttpUtils.HttpRestClient(url, HttpMethod.POST, params, MediaType.APPLICATION_JSON);
|
| | | log.info(s);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | | return null;
|
| | | }else {
|
| | | JSONObject data = result.getJSONObject(Constant.Data);
|
| | | data = data.getJSONObject(Constant.userDO);
|
| | | TUser user = JSON.toJavaObject(data, TUser.class);
|
| | | if (user == null){
|
| | | return null;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public List<TUser> listUserRoleGroup() {
|
| | | try {
|
| | | String url = this.url + prefix + "user/listUserRoleGroup";
|
| | | String s = HttpUtils.HttpRestClientByObjectParams(url, HttpMethod.POST, null, null,null,MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | | return null;
|
| | | }
|
| | | JSONArray jsonArray = result.getJSONArray(Constant.Data);
|
| | | List<TUser> tUsers = JSONObject.parseArray(jsonArray.toJSONString(), TUser.class);
|
| | | return tUsers;
|
| | | }catch (Exception e){
|
| | | e.printStackTrace();
|
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public boolean deleteRoleByGroupId(List<String> roleIds, String groupId) {
|
| | | try {
|
| | |
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | public List<String> getUserListByRole(String roleId) {
|
| | | try {
|
| | | String url = this.url + prefix + "userRole/selectUserMap";
|
| | | Map<String, Object> params = new LinkedHashMap<>();
|
| | | params.put("roleId", roleId);
|
| | | String s = HttpUtils.HttpRestClientByObjectParams(url, HttpMethod.POST, params, null,null,MediaType.APPLICATION_JSON);
|
| | | JSONObject result = (JSONObject) JSON.parse(s);
|
| | | String sucess = result.getString(Constant.Success);
|
| | | if (StringUtils.isEmpty(sucess) || !Boolean.valueOf(sucess)) {
|
| | | return null;
|
| | | }
|
| | | List<String> array = result.getObject(Constant.Data, List.class);
|
| | |
|
| | | return array;
|
| | | }catch (Exception e){
|
| | | e.printStackTrace();
|
| | | return null;
|
| | | }
|
| | | }
|
| | | }
|