|
@@ -6,9 +6,11 @@ import com.bosshand.virgo.core.dao.MgrOrganizationDao;
|
|
|
import com.bosshand.virgo.core.dao.MgrUserDao;
|
|
|
import com.bosshand.virgo.core.dao.MgrUserRoleDao;
|
|
|
import com.bosshand.virgo.core.model.Attendance;
|
|
|
+import com.bosshand.virgo.core.model.MgrOrganization;
|
|
|
import com.bosshand.virgo.core.model.MgrUser;
|
|
|
import com.bosshand.virgo.core.model.MgrUserRole;
|
|
|
import com.bosshand.virgo.core.utils.CodeCache;
|
|
|
+import com.bosshand.virgo.core.utils.Utils;
|
|
|
import com.bosshand.virgo.core.utils.WeChatUtil;
|
|
|
import com.bosshand.virgo.util.MD5Utils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -115,8 +117,9 @@ public class UserService {
|
|
|
if (user.getName() == null) {
|
|
|
user.setName(CodeCache.DefaultUserName);
|
|
|
}
|
|
|
- mgrUserDao.insert(user);
|
|
|
- userId = user.getId();
|
|
|
+ //mgrUserDao.insert(user);
|
|
|
+ //userId = user.getId();
|
|
|
+ userId = registerOrganization(user);
|
|
|
// 聊天用户新增
|
|
|
JSONObject js = new JSONObject();
|
|
|
js.put("userId", userId);
|
|
@@ -146,6 +149,28 @@ public class UserService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新加用户注册组织
|
|
|
+ */
|
|
|
+ private long registerOrganization(MgrUser user){
|
|
|
+ MgrOrganization mgrOrganization = new MgrOrganization();
|
|
|
+ mgrOrganization.setName(null);
|
|
|
+ mgrOrganization.setContact(user.getName());
|
|
|
+ mgrOrganization.setContactTel(user.getPhone());
|
|
|
+ mgrOrganization.setOrganizationCode("CZF" + Utils.random(8));
|
|
|
+ mgrOrganizationDao.insert(mgrOrganization);
|
|
|
+
|
|
|
+ user.setLastOrganizationId(mgrOrganization.getId());
|
|
|
+ mgrUserDao.insert(user);
|
|
|
+
|
|
|
+ MgrUserRole userRole = new MgrUserRole();
|
|
|
+ userRole.setAdmin(true);
|
|
|
+ userRole.setOrganizationId(mgrOrganization.getId());
|
|
|
+ userRole.setUserId(user.getId());
|
|
|
+ mgrUserRoleDao.insert(userRole);
|
|
|
+ return user.getId();
|
|
|
+ }
|
|
|
+
|
|
|
public List<MgrUser> getUserByOrganizationId(long organizationId) {
|
|
|
List<MgrUserRole> list = mgrUserRoleDao.getOrganizationId(organizationId);
|
|
|
List<Long> ids = new ArrayList<>();
|