Browse Source

原框架拓展接口 第三方注册租户

home 2 years ago
parent
commit
daf51426ab
33 changed files with 912 additions and 69 deletions
  1. 19 0
      hx-service-api/foreign-trade-superman-api/pom.xml
  2. 1 0
      hx-service-api/pom.xml
  3. 7 0
      hx-service/blade-ex/src/main/java/com/fjhx/controller/TenantController.java
  4. 30 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserAppMapper.java
  5. 5 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserAppMapper.xml
  6. 30 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserDeptMapper.java
  7. 5 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserDeptMapper.xml
  8. 29 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserMapper.java
  9. 5 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserMapper.xml
  10. 29 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOauthMapper.java
  11. 5 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOauthMapper.xml
  12. 29 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOtherMapper.java
  13. 5 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOtherMapper.xml
  14. 30 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserWebMapper.java
  15. 5 0
      hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserWebMapper.xml
  16. 48 0
      hx-service/blade-ex/src/main/java/com/fjhx/params/TenantVo.java
  17. 5 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/ITenantService.java
  18. 30 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/IUserDeptService.java
  19. 30 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/IUserOauthService.java
  20. 33 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/IUserSearchService.java
  21. 29 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/IUserService.java
  22. 191 66
      hx-service/blade-ex/src/main/java/com/fjhx/service/impl/TenantServiceImpl.java
  23. 33 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserDeptServiceImpl.java
  24. 35 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserOauthServiceImpl.java
  25. 35 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserSearchServiceImpl.java
  26. 36 0
      hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserServiceImpl.java
  27. 95 0
      hx-service/blade-ex/src/main/java/com/fjhx/utils/JwtUtil.java
  28. 26 0
      hx-service/foreign-trade-superman/pom.xml
  29. 18 0
      hx-service/foreign-trade-superman/src/main/java/com/fjhx/ForeignTradeSupermanApplication.java
  30. 9 0
      hx-service/foreign-trade-superman/src/main/resources/application-dev.yml
  31. 12 0
      hx-service/foreign-trade-superman/src/main/resources/application-prod.yml
  32. 11 0
      hx-service/foreign-trade-superman/src/main/resources/application-test.yml
  33. 2 3
      hx-service/pom.xml

+ 19 - 0
hx-service-api/foreign-trade-superman-api/pom.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hx-service-api</artifactId>
+        <groupId>com.fjhx</groupId>
+        <version>3.2.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>foreign-trade-superman-api</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>

+ 1 - 0
hx-service-api/pom.xml

@@ -30,6 +30,7 @@
         <module>storage-restructure-api</module>
         <module>service-flow-api</module>
         <module>basics-api</module>
+        <module>foreign-trade-superman-api</module>
     </modules>
 
     <dependencyManagement>

+ 7 - 0
hx-service/blade-ex/src/main/java/com/fjhx/controller/TenantController.java

@@ -64,4 +64,11 @@ public class TenantController extends BladeController {
         return R.success(page);
     }
 
+    @PostMapping("/thirdPartyCreate")
+    public R thirdPartyCreate(@RequestBody Condition condition) {
+        tenantService.thirdPartyCreate(condition.getStr("token"));
+        return R.success();
+    }
+
+
 }

+ 30 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserAppMapper.java

@@ -0,0 +1,30 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.system.user.entity.UserApp;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface UserAppMapper extends BaseMapper<UserApp> {
+
+
+}

+ 5 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserAppMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.UserAppMapper">
+
+</mapper>

+ 30 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserDeptMapper.java

@@ -0,0 +1,30 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.system.user.entity.UserDept;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface UserDeptMapper extends BaseMapper<UserDept> {
+
+
+}

+ 5 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserDeptMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.UserDeptMapper">
+
+</mapper>

+ 29 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserMapper.java

@@ -0,0 +1,29 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.system.user.entity.User;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface UserMapper extends BaseMapper<User> {
+
+}

+ 5 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.UserMapper">
+
+</mapper>

+ 29 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOauthMapper.java

@@ -0,0 +1,29 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.system.user.entity.UserOauth;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface UserOauthMapper extends BaseMapper<UserOauth> {
+
+}

+ 5 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOauthMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.UserOauthMapper">
+
+</mapper>

+ 29 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOtherMapper.java

@@ -0,0 +1,29 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.system.user.entity.UserOther;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface UserOtherMapper extends BaseMapper<UserOther> {
+
+}

+ 5 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserOtherMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.UserOtherMapper">
+
+</mapper>

+ 30 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserWebMapper.java

@@ -0,0 +1,30 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springblade.system.user.entity.UserWeb;
+
+/**
+ * Mapper 接口
+ *
+ * @author Chill
+ */
+public interface UserWebMapper extends BaseMapper<UserWeb> {
+
+
+}

+ 5 - 0
hx-service/blade-ex/src/main/java/com/fjhx/mapper/UserWebMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.UserWebMapper">
+
+</mapper>

+ 48 - 0
hx-service/blade-ex/src/main/java/com/fjhx/params/TenantVo.java

@@ -0,0 +1,48 @@
+package com.fjhx.params;
+
+import lombok.Data;
+
+@Data
+public class TenantVo {
+
+    /**
+     * 租户id
+     */
+    private String tenantId;
+
+    /**
+     * 租户名称
+     */
+    private String tenantName;
+
+    /**
+     * 联系人
+     */
+    private String linkman;
+
+    /**
+     * 联系电话
+     */
+    private String contactNumber;
+
+    /**
+     * 昵称
+     */
+    private String name;
+
+    /**
+     * 真名
+     */
+    private String realName;
+
+    /**
+     * 账号
+     */
+    private String account;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+}

+ 5 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/ITenantService.java

@@ -40,4 +40,9 @@ public interface ITenantService extends BaseService<Tenant> {
      */
     Page<Map<String, Object>> getPage(Condition condition);
 
+    /**
+     * 第三方创建租户
+     */
+    void thirdPartyCreate(String token);
+
 }

+ 30 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/IUserDeptService.java

@@ -0,0 +1,30 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.system.user.entity.UserDept;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface IUserDeptService extends IService<UserDept> {
+
+}

+ 30 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/IUserOauthService.java

@@ -0,0 +1,30 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springblade.system.user.entity.UserOauth;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface IUserOauthService extends IService<UserOauth> {
+
+}

+ 33 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/IUserSearchService.java

@@ -0,0 +1,33 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service;
+
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.system.user.entity.User;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 用户查询服务类
+ *
+ * @author Chill
+ */
+public interface IUserSearchService extends BaseService<User> {
+
+}

+ 29 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/IUserService.java

@@ -0,0 +1,29 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service;
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.system.user.entity.User;
+
+/**
+ * 服务类
+ *
+ * @author Chill
+ */
+public interface IUserService extends BaseService<User> {
+
+}

+ 191 - 66
hx-service/blade-ex/src/main/java/com/fjhx/service/impl/TenantServiceImpl.java

@@ -16,29 +16,32 @@
  */
 package com.fjhx.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.RandomUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.base.Condition;
 import com.fjhx.mapper.TenantMapper;
+import com.fjhx.params.TenantVo;
 import com.fjhx.service.*;
 import com.fjhx.utils.Assert;
+import com.fjhx.utils.JwtUtil;
 import lombok.AllArgsConstructor;
 import org.springblade.core.cache.utils.CacheUtil;
-import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseEntity;
 import org.springblade.core.mp.base.BaseServiceImpl;
-import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.constant.BladeConstant;
+import org.springblade.core.tool.utils.DigestUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.system.cache.ParamCache;
 import org.springblade.system.entity.*;
 import org.springblade.system.user.entity.User;
+import org.springblade.system.user.entity.UserDept;
 import org.springblade.system.user.enums.UserEnum;
-import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -61,8 +64,10 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
     private final IPostService postService;
     private final IRoleMenuService roleMenuService;
     private final IDictBizService dictBizService;
-    private final IUserClient userClient;
     private final IMenuService menuService;
+    private final IUserService userService;
+    private final IUserDeptService userDeptService;
+
 
     private final ExRegionService exRegionService;
 
@@ -72,6 +77,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
         if (Func.isEmpty(tenant.getId())) {
 
             String tenantId = tenant.getTenantId();
+            Assert.notEmpty(tenantId, "租户id不能为空");
             Long count = count(Wrappers.<Tenant>lambdaQuery().eq(Tenant::getTenantId, tenant));
             Assert.eqZero(count, "租户id已存在");
             tenant.setTenantId(tenantId);
@@ -81,78 +87,26 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
             // tenant.setAccountNumber(accountNumber);
 
             // 新建租户对应的默认角色
-            Role role = new Role();
-            role.setTenantId(tenantId);
-            role.setParentId(BladeConstant.TOP_PARENT_ID);
-            role.setRoleName("管理员");
-            role.setRoleAlias("admin");
-            role.setSort(2);
-            role.setIsDeleted(BladeConstant.DB_NOT_DELETED);
-            roleService.save(role);
+            Long roleId = createRole(tenantId);
 
             // 新建租户对应的角色菜单权限
-            LinkedList<Menu> userMenus = new LinkedList<>();
-            // 获取参数配置的默认菜单集合,逗号隔开
-            List<String> menuCodes = Func.toStrList(ParamCache.getValue(ACCOUNT_MENU_CODE_KEY));
-            List<Menu> menus = getMenus((menuCodes.size() > 0 ? menuCodes : MENU_CODES), userMenus);
-            List<RoleMenu> roleMenus = new ArrayList<>();
-            menus.forEach(menu -> {
-                RoleMenu roleMenu = new RoleMenu();
-                roleMenu.setMenuId(menu.getId());
-                roleMenu.setRoleId(role.getId());
-                roleMenus.add(roleMenu);
-            });
-            roleMenuService.saveBatch(roleMenus);
+            createRoleMenus(roleId);
 
             // 新建租户对应的默认部门
-            Dept dept = new Dept();
-            dept.setTenantId(tenantId);
-            dept.setParentId(BladeConstant.TOP_PARENT_ID);
-            dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
-            dept.setDeptName(tenant.getTenantName());
-            dept.setFullName(tenant.getTenantName());
-            dept.setDeptCategory(1);
-            dept.setSort(2);
-            dept.setIsDeleted(BladeConstant.DB_NOT_DELETED);
-            deptService.save(dept);
+            Long deptId = createDept(tenantId, tenant.getTenantName());
 
             // 新建租户对应的默认岗位
-            Post post = new Post();
-            post.setTenantId(tenantId);
-            post.setCategory(1);
-            post.setPostCode("ceo");
-            post.setPostName("首席执行官");
-            post.setSort(1);
-            postService.save(post);
+            Long postId = createPost(tenantId);
 
             // 新建租户对应的默认业务字典
-            LinkedList<DictBiz> dictBizs = new LinkedList<>();
-            List<DictBiz> dictBizList = getDictBizs(tenantId, dictBizs);
-            dictBizService.saveBatch(dictBizList);
+            createDictBizList(tenantId);
 
             // 新建租户对应的默认管理用户
-            User user = new User();
-            user.setTenantId(tenantId);
-            user.setName("admin");
-            user.setRealName("admin");
-            user.setAccount("admin");
-            // 获取参数配置的密码
-            String password = Func.toStr(ParamCache.getValue(PASSWORD_KEY), DEFAULT_PASSWORD);
-            user.setPassword(password);
-            user.setRoleId(String.valueOf(role.getId()));
-            user.setDeptId(String.valueOf(dept.getId()));
-            user.setPostId(String.valueOf(post.getId()));
-            user.setBirthday(new Date());
-            user.setSex(1);
-            user.setUserType(UserEnum.WEB.getCategory());
-            user.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+            createUser(tenantId, "admin", "admin", "admin",
+                    Func.toStr(ParamCache.getValue(PASSWORD_KEY), DEFAULT_PASSWORD), roleId, deptId, postId);
 
-            saveOrUpdate(tenant);
+            save(tenant);
 
-            R<Boolean> result = userClient.saveUser(user);
-            if (!result.isSuccess()) {
-                throw new ServiceException(result.getMsg());
-            }
 
         } else {
             CacheUtil.clear(SYS_CACHE, tenant.getTenantId());
@@ -185,8 +139,7 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
                 .between(ObjectUtil.isNotEmpty(expireBeginTime), Tenant::getExpireTime, expireBeginTime, expireEndTime)
                 .eq(ObjectUtil.isNotEmpty(countryId), Tenant::getCountryId, countryId)
                 .eq(ObjectUtil.isNotEmpty(provinceId), Tenant::getProvinceId, provinceId)
-                .eq(ObjectUtil.isNotEmpty(cityId), Tenant::getCityId, cityId)
-        ;
+                .eq(ObjectUtil.isNotEmpty(cityId), Tenant::getCityId, cityId);
 
 
         Page<Map<String, Object>> page = pageMaps(condition.getPage(), wrapper);
@@ -214,6 +167,178 @@ public class TenantServiceImpl extends BaseServiceImpl<TenantMapper, Tenant> imp
         return page;
     }
 
+    @Override
+    public void thirdPartyCreate(String token) {
+        TenantVo tenantVo = JwtUtil.parseToken(token, TenantVo.class);
+
+        String tenantId = tenantVo.getTenantId();
+        Assert.notEmpty(tenantId, "租户id不能为空");
+
+        String tenantName = tenantVo.getTenantName();
+        Assert.notEmpty(tenantName, "租户名称不能为空");
+
+        String account = tenantVo.getAccount();
+        Assert.notEmpty(account, "用户账号不能为空");
+
+        Tenant tenant = BeanUtil.toBean(tenantVo, Tenant.class);
+        Long count = count(Wrappers.<Tenant>lambdaQuery().eq(Tenant::getTenantId, tenant));
+        Assert.eqZero(count, "租户id已存在");
+
+        tenant.setLinkman(tenant.getLinkman() == null ? tenantName : tenant.getLinkman());
+
+        tenantVo.setName(tenantVo.getName() == null ? tenantName : tenantVo.getName());
+        tenantVo.setRealName(tenantVo.getRealName() == null ? tenantName : tenantVo.getRealName());
+        tenantVo.setPassword(tenantVo.getPassword() == null ? RandomUtil.randomString(6) : tenantVo.getPassword());
+
+        // 指定账号额度20
+        tenant.setAccountNumber(20);
+
+        // 新建租户对应的默认角色
+        Long roleId = createRole(tenantId);
+
+        // 新建租户对应的角色菜单权限
+        createRoleMenus(roleId);
+
+        // 新建租户对应的默认部门
+        Long deptId = createDept(tenantId, tenant.getTenantName());
+
+        // 新建租户对应的默认岗位
+        Long postId = createPost(tenantId);
+
+        // 新建租户对应的默认业务字典
+        createDictBizList(tenantId);
+
+        createUser(tenantId, tenantVo.getName(), tenantVo.getRealName(), account,
+                tenantVo.getPassword(), roleId, deptId, postId);
+
+        save(tenant);
+
+    }
+
+    /**
+     * 新建租户对应的默认角色
+     *
+     * @param tenantId 租户id
+     * @return 角色id
+     */
+    private Long createRole(String tenantId) {
+        Role role = new Role();
+        role.setTenantId(tenantId);
+        role.setParentId(BladeConstant.TOP_PARENT_ID);
+        role.setRoleName("管理员");
+        role.setRoleAlias("admin");
+        role.setSort(2);
+        role.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+        roleService.save(role);
+        return role.getId();
+    }
+
+    /**
+     * 新建租户对应的角色菜单权限
+     *
+     * @param roleId 角色id
+     */
+    private void createRoleMenus(Long roleId) {
+        LinkedList<Menu> userMenus = new LinkedList<>();
+        // 获取参数配置的默认菜单集合,逗号隔开
+        List<String> menuCodes = Func.toStrList(ParamCache.getValue(ACCOUNT_MENU_CODE_KEY));
+        List<Menu> menus = getMenus((menuCodes.size() > 0 ? menuCodes : MENU_CODES), userMenus);
+        List<RoleMenu> roleMenus = new ArrayList<>();
+        menus.forEach(menu -> {
+            RoleMenu roleMenu = new RoleMenu();
+            roleMenu.setMenuId(menu.getId());
+            roleMenu.setRoleId(roleId);
+            roleMenus.add(roleMenu);
+        });
+        roleMenuService.saveBatch(roleMenus);
+    }
+
+
+    /**
+     * 新建租户对应的默认部门
+     *
+     * @param tenantId   租户id
+     * @param tenantName 租户名称
+     * @return 部门id
+     */
+    private Long createDept(String tenantId, String tenantName) {
+        Dept dept = new Dept();
+        dept.setTenantId(tenantId);
+        dept.setParentId(BladeConstant.TOP_PARENT_ID);
+        dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID));
+        dept.setDeptName(tenantName);
+        dept.setFullName(tenantName);
+        dept.setDeptCategory(1);
+        dept.setSort(2);
+        dept.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+        deptService.save(dept);
+        return dept.getId();
+    }
+
+    /**
+     * 新建租户对应的默认岗位
+     *
+     * @param tenantId 租户id
+     * @return 岗位id
+     */
+    private Long createPost(String tenantId) {
+        Post post = new Post();
+        post.setTenantId(tenantId);
+        post.setCategory(1);
+        post.setPostCode("ceo");
+        post.setPostName("首席执行官");
+        post.setSort(1);
+        postService.save(post);
+        return post.getId();
+    }
+
+    /**
+     * createDictBizs
+     *
+     * @param tenantId 租户id
+     */
+    private void createDictBizList(String tenantId) {
+        // 新建租户对应的默认业务字典
+        List<DictBiz> dictBizList = getDictBizs(tenantId, new LinkedList<>());
+        dictBizService.saveBatch(dictBizList);
+    }
+
+    /**
+     * 新建租户对应的默认管理用户
+     *
+     * @param tenantId 租户id
+     * @param name     昵称
+     * @param realName 真名
+     * @param account  账号
+     * @param password 密码
+     * @param roleId   角色id
+     * @param deptId   部门id
+     * @param postId   岗位id
+     */
+    private void createUser(String tenantId, String name, String realName, String account, String password,
+                            Long roleId, Long deptId, Long postId) {
+        User user = new User();
+        user.setTenantId(tenantId);
+        user.setName(name);
+        user.setRealName(realName);
+        user.setAccount(account);
+        user.setPassword(DigestUtil.encrypt(password));
+        user.setRoleId(String.valueOf(roleId));
+        user.setDeptId(String.valueOf(deptId));
+        user.setPostId(String.valueOf(postId));
+        user.setBirthday(new Date());
+        user.setSex(1);
+        user.setUserType(UserEnum.WEB.getCategory());
+        user.setIsDeleted(BladeConstant.DB_NOT_DELETED);
+        userService.save(user);
+
+        UserDept userDept = new UserDept();
+        userDept.setUserId(user.getId());
+        userDept.setDeptId(deptId);
+        userDeptService.save(userDept);
+    }
+
+
     private List<Menu> getMenus(List<String> codes, LinkedList<Menu> menus) {
         codes.forEach(code -> {
             Menu menu = menuService.getOne(Wrappers.<Menu>query().lambda().eq(Menu::getCode, code).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED));

+ 33 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserDeptServiceImpl.java

@@ -0,0 +1,33 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.mapper.UserDeptMapper;
+import com.fjhx.service.IUserDeptService;
+import org.springblade.system.user.entity.UserDept;
+import org.springframework.stereotype.Service;
+
+/**
+ * 服务实现类
+ *
+ * @author Chill
+ */
+@Service
+public class UserDeptServiceImpl extends ServiceImpl<UserDeptMapper, UserDept> implements IUserDeptService {
+
+}

+ 35 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserOauthServiceImpl.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.mapper.UserOauthMapper;
+import com.fjhx.service.IUserOauthService;
+import lombok.AllArgsConstructor;
+import org.springblade.system.user.entity.UserOauth;
+import org.springframework.stereotype.Service;
+
+/**
+ * 服务实现类
+ *
+ * @author Chill
+ */
+@Service
+@AllArgsConstructor
+public class UserOauthServiceImpl extends ServiceImpl<UserOauthMapper, UserOauth> implements IUserOauthService {
+
+}

+ 35 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserSearchServiceImpl.java

@@ -0,0 +1,35 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service.impl;
+
+import com.fjhx.mapper.UserMapper;
+import com.fjhx.service.IUserSearchService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.system.user.entity.User;
+import org.springframework.stereotype.Service;
+
+/**
+ * 用户查询服务实现类
+ *
+ * @author Chill
+ */
+@Service
+@AllArgsConstructor
+public class UserSearchServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserSearchService {
+
+}

+ 36 - 0
hx-service/blade-ex/src/main/java/com/fjhx/service/impl/UserServiceImpl.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package com.fjhx.service.impl;
+
+import com.fjhx.mapper.UserMapper;
+import com.fjhx.service.IUserService;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.system.user.entity.User;
+import org.springframework.stereotype.Service;
+
+/**
+ * 服务实现类
+ *
+ * @author Chill
+ */
+@Service
+@AllArgsConstructor
+public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserService {
+
+
+}

+ 95 - 0
hx-service/blade-ex/src/main/java/com/fjhx/utils/JwtUtil.java

@@ -0,0 +1,95 @@
+package com.fjhx.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import io.jsonwebtoken.*;
+import io.jsonwebtoken.security.SignatureException;
+import org.springblade.core.log.exception.ServiceException;
+
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.security.Key;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+public class JwtUtil {
+
+    private static final String SECRET = "sbajhdbasjk342@ldhbasilheiuqwhei$Fu123y28db@iaSARFSRFAXSksZSXb%dkaSADaSSAsb";
+    private static final Key signingKey = new SecretKeySpec(SECRET.getBytes(StandardCharsets.UTF_8),
+            SignatureAlgorithm.HS256.getJcaName());
+
+    public static void main(String[] args) {
+
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("test", "dasdsaasd");
+        map.put("test2", "213124asda");
+        String test = generateToken(map);
+
+        System.out.println(test);
+        System.out.println(test.length());
+
+        Map<String, Object> map1 = parseToken(test, Map.class);
+        System.out.println(map1);
+    }
+
+    /**
+     * 生成token
+     *
+     * @param obj 加密对象
+     * @return token
+     */
+    public static String generateToken(Object obj) {
+        // 这里其实就是new一个JwtBuilder,设置jwt的body
+        JwtBuilder jwtBuilder = Jwts.builder()
+                // 设置JwtId:是JWT的唯一标识,根据业务需要,这个可以设置为一个不重复的值,主要用来作为一次性token,从而回避重放攻击。
+                .setId(IdWorker.getIdStr())
+                // 设置发送内容
+                .setSubject(JSONObject.toJSONString(obj))
+                // 签发时间
+                .setIssuedAt(new Date())
+                // 设置过期时间
+                .setExpiration(getExpiration())
+                // 签名
+                .signWith(signingKey);
+
+        // 根据对象生成 令牌token
+        return jwtBuilder.compact();
+    }
+
+    /**
+     * 解析token
+     *
+     * @param token  token
+     * @param tClass 反序列化对象
+     */
+    public static <T> T parseToken(String token, Class<T> tClass) {
+        try {
+            Claims claims = Jwts.parserBuilder().setSigningKey(signingKey).build().parseClaimsJws(token).getBody();
+            return JSONObject.parseObject(claims.getSubject(), tClass);
+        } catch (ExpiredJwtException expiredJwtException) {
+            throw new ServiceException("token已过期");
+        } catch (SignatureException signatureException) {
+            throw new ServiceException("密钥错误");
+        } catch (MalformedJwtException malformedJwtException) {
+            throw new ServiceException("密钥算法,或者密钥转换错误,或者token不正确");
+        } catch (MissingClaimException missingClaimException) {
+            throw new ServiceException("密钥缺少校验数据");
+        } catch (JwtException jwtException) {
+            throw new ServiceException("密钥解析错误");
+        }
+    }
+
+    /**
+     * 设置过期时间
+     * <p>
+     * 30秒后过期
+     */
+    static private Date getExpiration() {
+        return new Date(System.currentTimeMillis() + 30 * 1000);
+    }
+
+}
+
+
+

+ 26 - 0
hx-service/foreign-trade-superman/pom.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hx-service</artifactId>
+        <groupId>com.fjhx</groupId>
+        <version>3.2.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>foreign-trade-superman</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>foreign-trade-superman-api</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

+ 18 - 0
hx-service/foreign-trade-superman/src/main/java/com/fjhx/ForeignTradeSupermanApplication.java

@@ -0,0 +1,18 @@
+package com.fjhx;
+
+import org.springblade.core.cloud.client.BladeCloudApplication;
+import org.springblade.core.launch.BladeApplication;
+
+/**
+ * 基础架构拓展接口
+ */
+@BladeCloudApplication
+public class ForeignTradeSupermanApplication {
+
+    private static final String APP_NAME = "foreign-trade-superman";
+
+    public static void main(String[] args) {
+        BladeApplication.run(APP_NAME, ForeignTradeSupermanApplication.class, args);
+    }
+
+}

+ 9 - 0
hx-service/foreign-trade-superman/src/main/resources/application-dev.yml

@@ -0,0 +1,9 @@
+# 服务器端口
+server:
+  port: 8202
+
+spring:
+  datasource:
+    url: ${blade.datasource.dev.url}
+    username: ${blade.datasource.dev.username}
+    password: ${blade.datasource.dev.password}

+ 12 - 0
hx-service/foreign-trade-superman/src/main/resources/application-prod.yml

@@ -0,0 +1,12 @@
+# 服务器端口
+server:
+  port: 8202
+
+# 数据源配置
+spring:
+  # 数据库
+  datasource:
+    url: ${blade.datasource.blade_ex.prod.url}
+    username: ${blade.datasource.blade_ex.prod.username}
+    password: ${blade.datasource.blade_ex.prod.password}
+

+ 11 - 0
hx-service/foreign-trade-superman/src/main/resources/application-test.yml

@@ -0,0 +1,11 @@
+# 服务器端口
+server:
+  port: 8202
+
+# 数据源配置
+spring:
+  # 数据库
+  datasource:
+    url: ${blade.datasource.blade_ex.test.url}
+    username: ${blade.datasource.blade_ex.test.username}
+    password: ${blade.datasource.blade_ex.test.password}

+ 2 - 3
hx-service/pom.xml

@@ -27,6 +27,7 @@
         <module>storage-restructure</module>
         <module>basics</module>
         <module>blade-ex</module>
+        <module>foreign-trade-superman</module>
     </modules>
 
     <dependencyManagement>
@@ -128,12 +129,10 @@
 
             <dependency>
                 <groupId>com.fjhx</groupId>
-                <artifactId>bladex-ex-api</artifactId>
+                <artifactId>foreign-trade-superman-api</artifactId>
                 <version>${hx.version}</version>
             </dependency>
 
-
-
         </dependencies>
     </dependencyManagement>