|
@@ -1,6 +1,7 @@
|
|
|
package com.huaxu.service;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.huaxu.common.ToolUtil;
|
|
|
import com.huaxu.dao.OrgMapper;
|
|
@@ -16,12 +17,18 @@ import com.huaxu.util.ByteArrayUtils;
|
|
|
import com.huaxu.util.RedisUtil;
|
|
|
import com.huaxu.util.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import javax.annotation.Resource;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -45,6 +52,8 @@ public class UserService extends ServiceImpl<UserMapper,UserEntity> {
|
|
|
private OrgMapper orgMapper;
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
|
+ @Value("${add_iot_user_url}")
|
|
|
+ private String addIotUserUrl;
|
|
|
|
|
|
/**
|
|
|
* 自定义分页查询,含关联实体对像
|
|
@@ -135,6 +144,7 @@ public class UserService extends ServiceImpl<UserMapper,UserEntity> {
|
|
|
* 保存
|
|
|
*/
|
|
|
public boolean addUser(UserEntity user) {
|
|
|
+ user.setUniqId(UUID.randomUUID().toString());
|
|
|
if (this.save(user)) {
|
|
|
Long pkId = user.getId();
|
|
|
//添加用户标签
|
|
@@ -163,9 +173,30 @@ public class UserService extends ServiceImpl<UserMapper,UserEntity> {
|
|
|
userRoleEntity.setUserId(pkId);
|
|
|
userRoleService.addUserRole(userRoleEntity);
|
|
|
}
|
|
|
+ addIotUser(user);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
+ }
|
|
|
+ private void addIotUser(UserEntity userEntity){
|
|
|
+ try {
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ JSONObject args=new JSONObject();
|
|
|
+ args.put("username",userEntity.getUsername());
|
|
|
+ args.put("mobilePhone",userEntity.getPhone());
|
|
|
+ args.put("tenantId",userEntity.getTenantId());
|
|
|
+ args.put("uniqId",userEntity.getUniqId());
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ HttpEntity<String> formEntity = new HttpEntity<>(args.toJSONString(), headers);
|
|
|
+
|
|
|
+ RestTemplate restTemplate=new RestTemplate();
|
|
|
+ restTemplate.postForEntity(addIotUserUrl, formEntity,String.class);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("添加物联网用户失败",e);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|