tangxiangan 10 months ago
parent
commit
e74ff4a669

+ 6 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/controller/DomainController.java

@@ -135,4 +135,10 @@ public class DomainController {
         return new ResultMap<>(CommonConstant.SUCCESS, CommonConstant.RESULT_SUCCESS);
     }
 
+    @PostMapping("/unBind")
+    public ResultMap<String> unBind(@RequestParam String domainId) {
+        domainService.unBind(domainId);
+        return new ResultMap<>(CommonConstant.SUCCESS, CommonConstant.RESULT_SUCCESS);
+    }
+
 }

+ 20 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/controller/VppMemberController.java

@@ -5,13 +5,16 @@ import cn.kdan.pdf.tech.core.constant.AuthConstant;
 import cn.kdan.pdf.tech.core.constant.SSOConstant;
 import cn.kdan.pdf.tech.core.constant.VppLicenseCodeConstant;
 import cn.kdan.pdf.tech.core.constant.VppMemberConstant;
+import cn.kdan.pdf.tech.core.model.Directory;
 import cn.kdan.pdf.tech.core.model.LicenseCodes;
 import cn.kdan.pdf.tech.core.model.VppMember;
 import cn.kdan.pdf.tech.core.params.VppMemberRegisterParam;
 import cn.kdan.pdf.tech.core.params.VppMemberResetPwdParam;
 import cn.kdan.pdf.tech.core.params.VppMemberUpdatePwdParam;
+import cn.kdan.pdf.tech.core.pojo.vo.SSOClientVO;
 import cn.kdan.pdf.tech.core.pojo.vo.SSOMemberLicenseVO;
 import cn.kdan.pdf.tech.core.pojo.vo.VppMemberVO;
+import cn.kdan.pdf.tech.core.service.DirectoryService;
 import cn.kdan.pdf.tech.core.service.VppLicenseCodeService;
 import cn.kdan.pdf.tech.core.service.VppMemberService;
 import constant.CommonConstant;
@@ -36,6 +39,8 @@ public class VppMemberController {
     private VppMemberService vppMemberService;
     @Resource
     private VppLicenseCodeService licenseCodeService;
+    @Resource
+    private DirectoryService directoryService;
 
     /**
      * 用户注册
@@ -134,4 +139,19 @@ public class VppMemberController {
         return new ResultMap<>(CommonConstant.SUCCESS, VppLicenseCodeConstant.SUCCESS_MSG_ASSIGN, ssoMemberLicenseVO);
     }
 
+    @GetMapping("/getSSOInfo")
+    public ResultMap<SSOClientVO> getSSOInfo(@RequestParam("email") String email) {
+        VppMember member = vppMemberService.getByAccountSSO(email);
+        if (ObjectUtils.isEmpty(member)) {
+            throw new BackendRuntimeException(SSOConstant.EXCEPTION_MSG_MEMBER_NOT_EXIST);
+        }
+        if (member.getValidFlag().equals(ValidStatusEnum.REVOKED.value())) {
+            throw new BackendRuntimeException(SSOConstant.EXCEPTION_MSG_MEMBER_REVOKED);
+        }
+        Directory directory = directoryService.getById(member.getDirectoryId());
+        SSOClientVO vo = new SSOClientVO();
+        BeanUtils.copyProperties(directory, vo);
+        return new ResultMap<>(CommonConstant.SUCCESS, VppLicenseCodeConstant.SUCCESS_MSG_ASSIGN, vo);
+    }
+
 }

+ 19 - 1
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/model/VppMember.java

@@ -44,6 +44,8 @@ public class VppMember implements Serializable {
 
     private String isSso;
 
+    private String directoryId;
+
     private static final long serialVersionUID = 1L;
 
     public String getId() {
@@ -306,6 +308,19 @@ public class VppMember implements Serializable {
         this.isSso = isSso;
     }
 
+    public String getDirectoryId() {
+        return directoryId;
+    }
+
+    public VppMember withDirectoryId(String directoryId) {
+        this.setDirectoryId(directoryId);
+        return this;
+    }
+
+    public void setDirectoryId(String directoryId) {
+        this.directoryId = directoryId;
+    }
+
     @Override
     public boolean equals(Object that) {
         if (this == that) {
@@ -337,7 +352,8 @@ public class VppMember implements Serializable {
             && (this.getRole() == null ? other.getRole() == null : this.getRole().equals(other.getRole()))
             && (this.getJob() == null ? other.getJob() == null : this.getJob().equals(other.getJob()))
             && (this.getArea() == null ? other.getArea() == null : this.getArea().equals(other.getArea()))
-            && (this.getIsSso() == null ? other.getIsSso() == null : this.getIsSso().equals(other.getIsSso()));
+            && (this.getIsSso() == null ? other.getIsSso() == null : this.getIsSso().equals(other.getIsSso()))
+            && (this.getDirectoryId() == null ? other.getDirectoryId() == null : this.getDirectoryId().equals(other.getDirectoryId()));
     }
 
     @Override
@@ -364,6 +380,7 @@ public class VppMember implements Serializable {
         result = prime * result + ((getJob() == null) ? 0 : getJob().hashCode());
         result = prime * result + ((getArea() == null) ? 0 : getArea().hashCode());
         result = prime * result + ((getIsSso() == null) ? 0 : getIsSso().hashCode());
+        result = prime * result + ((getDirectoryId() == null) ? 0 : getDirectoryId().hashCode());
         return result;
     }
 
@@ -393,6 +410,7 @@ public class VppMember implements Serializable {
         sb.append(", job=").append(job);
         sb.append(", area=").append(area);
         sb.append(", isSso=").append(isSso);
+        sb.append(", directoryId=").append(directoryId);
         sb.append(", serialVersionUID=").append(serialVersionUID);
         sb.append("]");
         return sb.toString();

+ 75 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/model/VppMemberExample.java

@@ -1425,6 +1425,76 @@ public class VppMemberExample {
             return (Criteria) this;
         }
 
+        public Criteria andDirectoryIdIsNull() {
+            addCriterion("directory_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdIsNotNull() {
+            addCriterion("directory_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdEqualTo(String value) {
+            addCriterion("directory_id =", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdNotEqualTo(String value) {
+            addCriterion("directory_id <>", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdGreaterThan(String value) {
+            addCriterion("directory_id >", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdGreaterThanOrEqualTo(String value) {
+            addCriterion("directory_id >=", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdLessThan(String value) {
+            addCriterion("directory_id <", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdLessThanOrEqualTo(String value) {
+            addCriterion("directory_id <=", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdLike(String value) {
+            addCriterion("directory_id like", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdNotLike(String value) {
+            addCriterion("directory_id not like", value, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdIn(List<String> values) {
+            addCriterion("directory_id in", values, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdNotIn(List<String> values) {
+            addCriterion("directory_id not in", values, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdBetween(String value1, String value2) {
+            addCriterion("directory_id between", value1, value2, "directoryId");
+            return (Criteria) this;
+        }
+
+        public Criteria andDirectoryIdNotBetween(String value1, String value2) {
+            addCriterion("directory_id not between", value1, value2, "directoryId");
+            return (Criteria) this;
+        }
+
         public Criteria andIdLikeInsensitive(String value) {
             addCriterion("upper(id) like", value.toUpperCase(), "id");
             return (Criteria) this;
@@ -1484,6 +1554,11 @@ public class VppMemberExample {
             addCriterion("upper(is_sso) like", value.toUpperCase(), "isSso");
             return (Criteria) this;
         }
+
+        public Criteria andDirectoryIdLikeInsensitive(String value) {
+            addCriterion("upper(directory_id) like", value.toUpperCase(), "directoryId");
+            return (Criteria) this;
+        }
     }
 
     public static class Criteria extends GeneratedCriteria {

+ 20 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/pojo/vo/SSOClientVO.java

@@ -0,0 +1,20 @@
+package cn.kdan.pdf.tech.core.pojo.vo;
+
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author tangxiangan
+ */
+@Data
+public class SSOClientVO {
+
+    private String clientSecrets;
+
+    private String tenantId;
+
+    private String applicationId;
+
+}

+ 5 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/service/DomainService.java

@@ -54,4 +54,9 @@ public interface DomainService {
      */
     void bindDomain(String domainId, String directoryId);
 
+    /**
+     * 解绑域名
+     * @param domainId 域名id
+     */
+    void unBind(String domainId);
 }

+ 9 - 0
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/service/impl/DomainServiceImpl.java

@@ -108,6 +108,15 @@ public class DomainServiceImpl implements DomainService {
         domainMapper.updateByPrimaryKeySelective(domain);
     }
 
+    @Override
+    public void unBind(String domainId) {
+        Domain domain = getById(domainId);
+        domain.setDirectoryId("");
+        domain.setUpdateTime(new Date());
+        domain.setUsed(DomainUsedEnum.AVAILABLE.code());
+        domainMapper.updateByPrimaryKeySelective(domain);
+    }
+
     private void checkExist(String domain) {
         DomainExample domainExample = new DomainExample();
         domainExample.createCriteria().andDomainEqualTo(domain).andValidFlagEqualTo(ValidStatusEnum.VALID.value());

+ 6 - 4
pdf-tech-core/src/main/java/cn/kdan/pdf/tech/core/service/impl/SyncServiceImpl.java

@@ -143,7 +143,7 @@ public class SyncServiceImpl implements SyncService {
         List<User> users = userResponse.getValue();
         List<String> microsoftEmails = users.stream().map(User::getUserPrincipalName).collect(Collectors.toList());
 
-        handleUsersData(users, microsoftEmails, companyId, teamId);
+        handleUsersData(users, microsoftEmails, companyId, teamId, directory.getDirectoryId());
     }
 
     private void endLog(String syncId) {
@@ -196,7 +196,7 @@ public class SyncServiceImpl implements SyncService {
 
         List<String> microsoftEmails = users.stream().map(User::getUserPrincipalName).collect(Collectors.toList());
 
-        handleUsersData(users, microsoftEmails, companyId, teamId);
+        handleUsersData(users, microsoftEmails, companyId, teamId, directory.getDirectoryId());
     }
 
     /**
@@ -206,8 +206,9 @@ public class SyncServiceImpl implements SyncService {
      * @param microsoftEmails microsoftEmails
      * @param companyId       companyId
      * @param teamId          teamId
+     * @param directoryId
      */
-    private void handleUsersData(List<User> users, List<String> microsoftEmails, String companyId, String teamId) {
+    private void handleUsersData(List<User> users, List<String> microsoftEmails, String companyId, String teamId, String directoryId) {
         for (User user : users) {
             String email = user.getUserPrincipalName();
             String name = user.getDisplayName();
@@ -225,7 +226,8 @@ public class SyncServiceImpl implements SyncService {
                         .withSubscriberType(0)
                         .withRole(RoleEnum.TEAM_MEMBER.code())
                         .withIsSso(SyncUserEnum.SSO.value())
-                        .withCompanyId(companyId);
+                        .withCompanyId(companyId)
+                        .withDirectoryId(directoryId);
                 vppMemberService.insert(newMember);
 
                 VppRTeamMemberRole vppRTeamMemberRole = new VppRTeamMemberRole()

+ 4 - 4
pdf-tech-core/src/main/resources/generatorConfig.xml

@@ -71,9 +71,9 @@
 <!--        <table tableName="orders"/>-->
 <!--        <table tableName="vpp_r_team_member_role"/>-->
 <!--        <table tableName="vpp_company"/>-->
-        <table tableName="directory"/>
-        <table tableName="schedule_setting"/>
-        <table tableName="domain"/>
-        <table tableName="directory_sync"/>
+<!--        <table tableName="directory"/>-->
+<!--        <table tableName="schedule_setting"/>-->
+<!--        <table tableName="domain"/>-->
+<!--        <table tableName="directory_sync"/>-->
     </context>
 </generatorConfiguration>

+ 22 - 5
pdf-tech-core/src/main/resources/sqlmap/VppMemberMapper.xml

@@ -22,6 +22,7 @@
     <result column="job" jdbcType="VARCHAR" property="job" />
     <result column="area" jdbcType="VARCHAR" property="area" />
     <result column="is_sso" jdbcType="VARCHAR" property="isSso" />
+    <result column="directory_id" jdbcType="VARCHAR" property="directoryId" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <where>
@@ -84,7 +85,7 @@
   <sql id="Base_Column_List">
     id, email, full_name, subscriber_type, created_at, updated_at, subscribed, digest_password, 
     phone, valid_flag, industry, company_id, last_popularize_at, last_presented_coupon_at, 
-    mailable, reset_token, "role", job, area, is_sso
+    mailable, reset_token, "role", job, area, is_sso, directory_id
   </sql>
   <select id="selectByExample" parameterType="cn.kdan.pdf.tech.core.model.VppMemberExample" resultMap="BaseResultMap">
     select
@@ -123,14 +124,16 @@
       valid_flag, industry, company_id, 
       last_popularize_at, last_presented_coupon_at, 
       mailable, reset_token, "role", 
-      job, area, is_sso)
+      job, area, is_sso, directory_id
+      )
     values (#{id,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{fullName,jdbcType=VARCHAR}, 
       #{subscriberType,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, 
       #{subscribed,jdbcType=INTEGER}, #{digestPassword,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, 
       #{validFlag,jdbcType=VARCHAR}, #{industry,jdbcType=VARCHAR}, #{companyId,jdbcType=VARCHAR}, 
       #{lastPopularizeAt,jdbcType=INTEGER}, #{lastPresentedCouponAt,jdbcType=TIMESTAMP}, 
       #{mailable,jdbcType=INTEGER}, #{resetToken,jdbcType=INTEGER}, #{role,jdbcType=VARCHAR}, 
-      #{job,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR}, #{isSso,jdbcType=VARCHAR})
+      #{job,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR}, #{isSso,jdbcType=VARCHAR}, #{directoryId,jdbcType=VARCHAR}
+      )
   </insert>
   <insert id="insertSelective" parameterType="cn.kdan.pdf.tech.core.model.VppMember">
     insert into vpp_member
@@ -195,6 +198,9 @@
       <if test="isSso != null">
         is_sso,
       </if>
+      <if test="directoryId != null">
+        directory_id,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -257,6 +263,9 @@
       <if test="isSso != null">
         #{isSso,jdbcType=VARCHAR},
       </if>
+      <if test="directoryId != null">
+        #{directoryId,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="cn.kdan.pdf.tech.core.model.VppMemberExample" resultType="java.lang.Long">
@@ -328,6 +337,9 @@
       <if test="row.isSso != null">
         is_sso = #{row.isSso,jdbcType=VARCHAR},
       </if>
+      <if test="row.directoryId != null">
+        directory_id = #{row.directoryId,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="example != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -354,7 +366,8 @@
       "role" = #{row.role,jdbcType=VARCHAR},
       job = #{row.job,jdbcType=VARCHAR},
       area = #{row.area,jdbcType=VARCHAR},
-      is_sso = #{row.isSso,jdbcType=VARCHAR}
+      is_sso = #{row.isSso,jdbcType=VARCHAR},
+      directory_id = #{row.directoryId,jdbcType=VARCHAR}
     <if test="example != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -419,6 +432,9 @@
       <if test="isSso != null">
         is_sso = #{isSso,jdbcType=VARCHAR},
       </if>
+      <if test="directoryId != null">
+        directory_id = #{directoryId,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -442,7 +458,8 @@
       "role" = #{role,jdbcType=VARCHAR},
       job = #{job,jdbcType=VARCHAR},
       area = #{area,jdbcType=VARCHAR},
-      is_sso = #{isSso,jdbcType=VARCHAR}
+      is_sso = #{isSso,jdbcType=VARCHAR},
+      directory_id = #{directoryId,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
   <select id="selectByExampleWithRowbounds" parameterType="cn.kdan.pdf.tech.core.model.VppMemberExample" resultMap="BaseResultMap">