Przeglądaj źródła

用户模块 用户注销逻辑(待补充增加注销用户记录),修改cancelMember实体类

songfuqiang 1 rok temu
rodzic
commit
bd6a79a28a

+ 2 - 2
backend-core/src/main/java/cn/kdan/pdf/backend/core/mapper/CancelMemberMapper.java

@@ -11,7 +11,7 @@ public interface CancelMemberMapper {
 
     int deleteByExample(CancelMemberExample example);
 
-    int deleteByPrimaryKey(Integer id);
+    int deleteByPrimaryKey(String id);
 
     int insert(CancelMember record);
 
@@ -21,7 +21,7 @@ public interface CancelMemberMapper {
 
     List<CancelMember> selectByExample(CancelMemberExample example);
 
-    CancelMember selectByPrimaryKey(Integer id);
+    CancelMember selectByPrimaryKey(String id);
 
     int updateByExampleSelective(@Param("record") CancelMember record, @Param("example") CancelMemberExample example);
 

+ 22 - 4
backend-core/src/main/java/cn/kdan/pdf/backend/core/model/CancelMember.java

@@ -4,10 +4,12 @@ import java.io.Serializable;
 import java.util.Date;
 
 public class CancelMember implements Serializable {
-    private Integer id;
+    private String id;
 
     private String memberAccount;
 
+    private String thirdAccount;
+
     private String cancelReason;
 
     private Integer count;
@@ -18,16 +20,16 @@ public class CancelMember implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
-    public Integer getId() {
+    public String getId() {
         return id;
     }
 
-    public CancelMember withId(Integer id) {
+    public CancelMember withId(String id) {
         this.setId(id);
         return this;
     }
 
-    public void setId(Integer id) {
+    public void setId(String id) {
         this.id = id;
     }
 
@@ -44,6 +46,19 @@ public class CancelMember implements Serializable {
         this.memberAccount = memberAccount;
     }
 
+    public String getThirdAccount() {
+        return thirdAccount;
+    }
+
+    public CancelMember withThirdAccount(String thirdAccount) {
+        this.setThirdAccount(thirdAccount);
+        return this;
+    }
+
+    public void setThirdAccount(String thirdAccount) {
+        this.thirdAccount = thirdAccount;
+    }
+
     public String getCancelReason() {
         return cancelReason;
     }
@@ -110,6 +125,7 @@ public class CancelMember implements Serializable {
         CancelMember other = (CancelMember) that;
         return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
             && (this.getMemberAccount() == null ? other.getMemberAccount() == null : this.getMemberAccount().equals(other.getMemberAccount()))
+            && (this.getThirdAccount() == null ? other.getThirdAccount() == null : this.getThirdAccount().equals(other.getThirdAccount()))
             && (this.getCancelReason() == null ? other.getCancelReason() == null : this.getCancelReason().equals(other.getCancelReason()))
             && (this.getCount() == null ? other.getCount() == null : this.getCount().equals(other.getCount()))
             && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
@@ -122,6 +138,7 @@ public class CancelMember implements Serializable {
         int result = 1;
         result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
         result = prime * result + ((getMemberAccount() == null) ? 0 : getMemberAccount().hashCode());
+        result = prime * result + ((getThirdAccount() == null) ? 0 : getThirdAccount().hashCode());
         result = prime * result + ((getCancelReason() == null) ? 0 : getCancelReason().hashCode());
         result = prime * result + ((getCount() == null) ? 0 : getCount().hashCode());
         result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
@@ -137,6 +154,7 @@ public class CancelMember implements Serializable {
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
         sb.append(", memberAccount=").append(memberAccount);
+        sb.append(", thirdAccount=").append(thirdAccount);
         sb.append(", cancelReason=").append(cancelReason);
         sb.append(", count=").append(count);
         sb.append(", createdAt=").append(createdAt);

+ 100 - 10
backend-core/src/main/java/cn/kdan/pdf/backend/core/model/CancelMemberExample.java

@@ -115,52 +115,62 @@ public class CancelMemberExample {
             return (Criteria) this;
         }
 
-        public Criteria andIdEqualTo(Integer value) {
+        public Criteria andIdEqualTo(String value) {
             addCriterion("id =", value, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdNotEqualTo(Integer value) {
+        public Criteria andIdNotEqualTo(String value) {
             addCriterion("id <>", value, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdGreaterThan(Integer value) {
+        public Criteria andIdGreaterThan(String value) {
             addCriterion("id >", value, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdGreaterThanOrEqualTo(Integer value) {
+        public Criteria andIdGreaterThanOrEqualTo(String value) {
             addCriterion("id >=", value, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdLessThan(Integer value) {
+        public Criteria andIdLessThan(String value) {
             addCriterion("id <", value, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdLessThanOrEqualTo(Integer value) {
+        public Criteria andIdLessThanOrEqualTo(String value) {
             addCriterion("id <=", value, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdIn(List<Integer> values) {
+        public Criteria andIdLike(String value) {
+            addCriterion("id like", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotLike(String value) {
+            addCriterion("id not like", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<String> values) {
             addCriterion("id in", values, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdNotIn(List<Integer> values) {
+        public Criteria andIdNotIn(List<String> values) {
             addCriterion("id not in", values, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdBetween(Integer value1, Integer value2) {
+        public Criteria andIdBetween(String value1, String value2) {
             addCriterion("id between", value1, value2, "id");
             return (Criteria) this;
         }
 
-        public Criteria andIdNotBetween(Integer value1, Integer value2) {
+        public Criteria andIdNotBetween(String value1, String value2) {
             addCriterion("id not between", value1, value2, "id");
             return (Criteria) this;
         }
@@ -235,6 +245,76 @@ public class CancelMemberExample {
             return (Criteria) this;
         }
 
+        public Criteria andThirdAccountIsNull() {
+            addCriterion("third_account is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountIsNotNull() {
+            addCriterion("third_account is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountEqualTo(String value) {
+            addCriterion("third_account =", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountNotEqualTo(String value) {
+            addCriterion("third_account <>", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountGreaterThan(String value) {
+            addCriterion("third_account >", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountGreaterThanOrEqualTo(String value) {
+            addCriterion("third_account >=", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountLessThan(String value) {
+            addCriterion("third_account <", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountLessThanOrEqualTo(String value) {
+            addCriterion("third_account <=", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountLike(String value) {
+            addCriterion("third_account like", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountNotLike(String value) {
+            addCriterion("third_account not like", value, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountIn(List<String> values) {
+            addCriterion("third_account in", values, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountNotIn(List<String> values) {
+            addCriterion("third_account not in", values, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountBetween(String value1, String value2) {
+            addCriterion("third_account between", value1, value2, "thirdAccount");
+            return (Criteria) this;
+        }
+
+        public Criteria andThirdAccountNotBetween(String value1, String value2) {
+            addCriterion("third_account not between", value1, value2, "thirdAccount");
+            return (Criteria) this;
+        }
+
         public Criteria andCancelReasonIsNull() {
             addCriterion("cancel_reason is null");
             return (Criteria) this;
@@ -485,11 +565,21 @@ public class CancelMemberExample {
             return (Criteria) this;
         }
 
+        public Criteria andIdLikeInsensitive(String value) {
+            addCriterion("upper(id) like", value.toUpperCase(), "id");
+            return (Criteria) this;
+        }
+
         public Criteria andMemberAccountLikeInsensitive(String value) {
             addCriterion("upper(member_account) like", value.toUpperCase(), "memberAccount");
             return (Criteria) this;
         }
 
+        public Criteria andThirdAccountLikeInsensitive(String value) {
+            addCriterion("upper(third_account) like", value.toUpperCase(), "thirdAccount");
+            return (Criteria) this;
+        }
+
         public Criteria andCancelReasonLikeInsensitive(String value) {
             addCriterion("upper(cancel_reason) like", value.toUpperCase(), "cancelReason");
             return (Criteria) this;

+ 3 - 0
backend-core/src/main/java/cn/kdan/pdf/backend/core/params/BindAccountParam.java

@@ -18,6 +18,9 @@ public class BindAccountParam {
 
     private String openid;
 
+    /**
+     * 绑定类型:wechat、tencent、phone
+     */
     private String provider;
 
     private String phone;

+ 11 - 2
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/CancelMemberServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.kdan.pdf.backend.core.service.impl;
 
+import cn.kdan.pdf.backend.core.mapper.CancelMemberMapper;
 import cn.kdan.pdf.backend.core.model.CancelMember;
 import cn.kdan.pdf.backend.core.model.Members;
 import cn.kdan.pdf.backend.core.model.SocialAccounts;
@@ -12,6 +13,7 @@ import org.springframework.util.StringUtils;
 import utils.CommonUtils;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -24,6 +26,8 @@ public class CancelMemberServiceImpl implements CancelMemberService {
 
     @Resource
     private SocialAccountService socialAccountService;
+    @Resource
+    private CancelMemberMapper cancelMemberMapper;
 
     @Override
     public void addCancelMember(Members members) {
@@ -37,14 +41,19 @@ public class CancelMemberServiceImpl implements CancelMemberService {
             thirdAccount = socialAccounts.get(0).getAccountId();
         }
 
+        // 插入注销账号记录,优先插入第三方注销记录
         CancelMember cancelMember = new CancelMember();
-//        cancelMember.setId(CommonUtils.generateId());
+        cancelMember.setId(CommonUtils.generateId());
         if(!StringUtils.isEmpty(phone)){
             cancelMember.setMemberAccount(phone);
         } else if(!StringUtils.isEmpty(email)){
             cancelMember.setMemberAccount(email);
         } else{
-            cancelMember.setMemberAccount(thirdAccount);
+            cancelMember.setThirdAccount(thirdAccount);
         }
+        Date date = new Date();
+        cancelMember.setCreatedAt(date);
+        cancelMember.setUpdatedAt(date);
+        cancelMemberMapper.insert(cancelMember);
     }
 }

+ 3 - 1
backend-core/src/main/java/cn/kdan/pdf/backend/core/service/impl/MemberServiceImpl.java

@@ -586,6 +586,7 @@ public class MemberServiceImpl implements MemberService {
         bindAccountVo.setMember(memberVo);
 
         String provider = param.getProvider();
+        // 绑定手机号
         if("phone".equals(provider)){
             bindPhone(param, socialAccounts, currentUser);
             memberVo.setPhone(param.getPhone());
@@ -598,7 +599,7 @@ public class MemberServiceImpl implements MemberService {
     }
 
     /**
-     * 手机号绑定
+     * 绑定手机号
      * @param param 入参
      * @param socialAccounts 社交账号
      * @param currentUser 当前用户
@@ -608,6 +609,7 @@ public class MemberServiceImpl implements MemberService {
         if(StringUtils.isEmpty(phone)){
             throw new BackendRuntimeException("手机号不能为空");
         }
+        //被绑定手机号用户
         Members member = userService.getByAccount(phone);
         if(member != null){
             //不允许绑定自己

+ 1 - 1
backend-core/src/main/resources/generatorConfig.xml

@@ -18,7 +18,7 @@
             <property name="suppressAllComments" value="true"/>
         </commentGenerator>
         <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
-                        connectionURL="jdbc:mysql://139.196.160.101:33056/17pdf_backend_test&useSSL=false"
+                        connectionURL="jdbc:mysql://139.196.160.101:33056/17pdf_backend_test?useSSL=false"
                         userId="root" password="Kdan123456!"
         >
             <property name="nullCatalogMeansCurrent" value="true"/>

+ 32 - 17
backend-core/src/main/resources/sqlmap/CancelMemberMapper.xml

@@ -2,8 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.kdan.pdf.backend.core.mapper.CancelMemberMapper">
   <resultMap id="BaseResultMap" type="cn.kdan.pdf.backend.core.model.CancelMember">
-    <id column="id" jdbcType="INTEGER" property="id" />
+    <id column="id" jdbcType="VARCHAR" property="id" />
     <result column="member_account" jdbcType="VARCHAR" property="memberAccount" />
+    <result column="third_account" jdbcType="VARCHAR" property="thirdAccount" />
     <result column="cancel_reason" jdbcType="VARCHAR" property="cancelReason" />
     <result column="count" jdbcType="INTEGER" property="count" />
     <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
@@ -68,7 +69,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, member_account, cancel_reason, `count`, created_at, updated_at
+    id, member_account, third_account, cancel_reason, `count`, created_at, updated_at
   </sql>
   <select id="selectByExample" parameterType="cn.kdan.pdf.backend.core.model.CancelMemberExample" resultMap="BaseResultMap">
     select
@@ -84,15 +85,15 @@
       order by ${orderByClause}
     </if>
   </select>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     select 
     <include refid="Base_Column_List" />
     from cancel_member
-    where id = #{id,jdbcType=INTEGER}
+    where id = #{id,jdbcType=VARCHAR}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
     delete from cancel_member
-    where id = #{id,jdbcType=INTEGER}
+    where id = #{id,jdbcType=VARCHAR}
   </delete>
   <delete id="deleteByExample" parameterType="cn.kdan.pdf.backend.core.model.CancelMemberExample">
     delete from cancel_member
@@ -101,12 +102,12 @@
     </if>
   </delete>
   <insert id="insert" parameterType="cn.kdan.pdf.backend.core.model.CancelMember">
-    insert into cancel_member (id, member_account, cancel_reason, 
-      `count`, created_at, updated_at
-      )
-    values (#{id,jdbcType=INTEGER}, #{memberAccount,jdbcType=VARCHAR}, #{cancelReason,jdbcType=VARCHAR}, 
-      #{count,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}
-      )
+    insert into cancel_member (id, member_account, third_account, 
+      cancel_reason, `count`, created_at, 
+      updated_at)
+    values (#{id,jdbcType=VARCHAR}, #{memberAccount,jdbcType=VARCHAR}, #{thirdAccount,jdbcType=VARCHAR}, 
+      #{cancelReason,jdbcType=VARCHAR}, #{count,jdbcType=INTEGER}, #{createdAt,jdbcType=TIMESTAMP}, 
+      #{updatedAt,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="cn.kdan.pdf.backend.core.model.CancelMember">
     insert into cancel_member
@@ -117,6 +118,9 @@
       <if test="memberAccount != null">
         member_account,
       </if>
+      <if test="thirdAccount != null">
+        third_account,
+      </if>
       <if test="cancelReason != null">
         cancel_reason,
       </if>
@@ -132,11 +136,14 @@
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
-        #{id,jdbcType=INTEGER},
+        #{id,jdbcType=VARCHAR},
       </if>
       <if test="memberAccount != null">
         #{memberAccount,jdbcType=VARCHAR},
       </if>
+      <if test="thirdAccount != null">
+        #{thirdAccount,jdbcType=VARCHAR},
+      </if>
       <if test="cancelReason != null">
         #{cancelReason,jdbcType=VARCHAR},
       </if>
@@ -161,11 +168,14 @@
     update cancel_member
     <set>
       <if test="record.id != null">
-        id = #{record.id,jdbcType=INTEGER},
+        id = #{record.id,jdbcType=VARCHAR},
       </if>
       <if test="record.memberAccount != null">
         member_account = #{record.memberAccount,jdbcType=VARCHAR},
       </if>
+      <if test="record.thirdAccount != null">
+        third_account = #{record.thirdAccount,jdbcType=VARCHAR},
+      </if>
       <if test="record.cancelReason != null">
         cancel_reason = #{record.cancelReason,jdbcType=VARCHAR},
       </if>
@@ -185,8 +195,9 @@
   </update>
   <update id="updateByExample" parameterType="map">
     update cancel_member
-    set id = #{record.id,jdbcType=INTEGER},
+    set id = #{record.id,jdbcType=VARCHAR},
       member_account = #{record.memberAccount,jdbcType=VARCHAR},
+      third_account = #{record.thirdAccount,jdbcType=VARCHAR},
       cancel_reason = #{record.cancelReason,jdbcType=VARCHAR},
       `count` = #{record.count,jdbcType=INTEGER},
       created_at = #{record.createdAt,jdbcType=TIMESTAMP},
@@ -201,6 +212,9 @@
       <if test="memberAccount != null">
         member_account = #{memberAccount,jdbcType=VARCHAR},
       </if>
+      <if test="thirdAccount != null">
+        third_account = #{thirdAccount,jdbcType=VARCHAR},
+      </if>
       <if test="cancelReason != null">
         cancel_reason = #{cancelReason,jdbcType=VARCHAR},
       </if>
@@ -214,16 +228,17 @@
         updated_at = #{updatedAt,jdbcType=TIMESTAMP},
       </if>
     </set>
-    where id = #{id,jdbcType=INTEGER}
+    where id = #{id,jdbcType=VARCHAR}
   </update>
   <update id="updateByPrimaryKey" parameterType="cn.kdan.pdf.backend.core.model.CancelMember">
     update cancel_member
     set member_account = #{memberAccount,jdbcType=VARCHAR},
+      third_account = #{thirdAccount,jdbcType=VARCHAR},
       cancel_reason = #{cancelReason,jdbcType=VARCHAR},
       `count` = #{count,jdbcType=INTEGER},
       created_at = #{createdAt,jdbcType=TIMESTAMP},
       updated_at = #{updatedAt,jdbcType=TIMESTAMP}
-    where id = #{id,jdbcType=INTEGER}
+    where id = #{id,jdbcType=VARCHAR}
   </update>
   <select id="selectByExampleWithRowbounds" parameterType="cn.kdan.pdf.backend.core.model.CancelMemberExample" resultMap="BaseResultMap">
     select