xueyiming 4 hónapja
szülő
commit
a85904a3d3

+ 1 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/WeComUserServiceImpl.java

@@ -91,7 +91,7 @@ public class WeComUserServiceImpl implements WeComUserService {
                 weComUser.setType(type);
                 weComUser.setGender(gender);
                 weComUser.setCorpId(corpId);
-                weComUserMapper.insert(weComUser);
+                weComUserMapper.insertSelective(weComUser);
                 Long userId = weComUser.getId();
                 if (userId == null) {
                     log.error("insertStaffWithUserJob insert weComUser error weComUser={}", weComUser);

+ 105 - 102
common-module/src/main/resources/mapper/WeComUserMapper.xml

@@ -132,108 +132,111 @@
       select LAST_INSERT_ID()
     </selectKey>
   </insert>
-  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.WeComUser">
-    insert into we_com_user
-    <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        id,
-      </if>
-      <if test="corpId != null">
-        corp_id,
-      </if>
-      <if test="externalUserId != null">
-        external_user_id,
-      </if>
-      <if test="unionId != null">
-        union_id,
-      </if>
-      <if test="externalUserId3rdParty != null">
-        external_user_id_3rd_party,
-      </if>
-      <if test="type != null">
-        `type`,
-      </if>
-      <if test="name != null">
-        `name`,
-      </if>
-      <if test="avatar != null">
-        avatar,
-      </if>
-      <if test="gender != null">
-        gender,
-      </if>
-      <if test="isDelete != null">
-        is_delete,
-      </if>
-      <if test="groupMsgDisabled != null">
-        group_msg_disabled,
-      </if>
-      <if test="createdAt != null">
-        created_at,
-      </if>
-      <if test="updatedAt != null">
-        updated_at,
-      </if>
-      <if test="deletedAt != null">
-        deleted_at,
-      </if>
-      <if test="createTime != null">
-        create_time,
-      </if>
-      <if test="updateTime != null">
-        update_time,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=BIGINT},
-      </if>
-      <if test="corpId != null">
-        #{corpId,jdbcType=BIGINT},
-      </if>
-      <if test="externalUserId != null">
-        #{externalUserId,jdbcType=VARCHAR},
-      </if>
-      <if test="unionId != null">
-        #{unionId,jdbcType=VARCHAR},
-      </if>
-      <if test="externalUserId3rdParty != null">
-        #{externalUserId3rdParty,jdbcType=VARCHAR},
-      </if>
-      <if test="type != null">
-        #{type,jdbcType=INTEGER},
-      </if>
-      <if test="name != null">
-        #{name,jdbcType=VARCHAR},
-      </if>
-      <if test="avatar != null">
-        #{avatar,jdbcType=VARCHAR},
-      </if>
-      <if test="gender != null">
-        #{gender,jdbcType=INTEGER},
-      </if>
-      <if test="isDelete != null">
-        #{isDelete,jdbcType=INTEGER},
-      </if>
-      <if test="groupMsgDisabled != null">
-        #{groupMsgDisabled,jdbcType=TINYINT},
-      </if>
-      <if test="createdAt != null">
-        #{createdAt,jdbcType=BIGINT},
-      </if>
-      <if test="updatedAt != null">
-        #{updatedAt,jdbcType=BIGINT},
-      </if>
-      <if test="deletedAt != null">
-        #{deletedAt,jdbcType=BIGINT},
-      </if>
-      <if test="createTime != null">
-        #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="updateTime != null">
-        #{updateTime,jdbcType=TIMESTAMP},
-      </if>
-    </trim>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.WeComUser" useGeneratedKeys="true" keyProperty="id">
+      insert into we_com_user
+      <trim prefix="(" suffix=")" suffixOverrides=",">
+          <if test="id != null">
+              id,
+          </if>
+          <if test="corpId != null">
+              corp_id,
+          </if>
+          <if test="externalUserId != null">
+              external_user_id,
+          </if>
+          <if test="unionId != null">
+              union_id,
+          </if>
+          <if test="externalUserId3rdParty != null">
+              external_user_id_3rd_party,
+          </if>
+          <if test="type != null">
+              `type`,
+          </if>
+          <if test="name != null">
+              `name`,
+          </if>
+          <if test="avatar != null">
+              avatar,
+          </if>
+          <if test="gender != null">
+              gender,
+          </if>
+          <if test="isDelete != null">
+              is_delete,
+          </if>
+          <if test="groupMsgDisabled != null">
+              group_msg_disabled,
+          </if>
+          <if test="createdAt != null">
+              created_at,
+          </if>
+          <if test="updatedAt != null">
+              updated_at,
+          </if>
+          <if test="deletedAt != null">
+              deleted_at,
+          </if>
+          <if test="createTime != null">
+              create_time,
+          </if>
+          <if test="updateTime != null">
+              update_time,
+          </if>
+      </trim>
+      <trim prefix="values (" suffix=")" suffixOverrides=",">
+          <if test="id != null">
+              #{id,jdbcType=BIGINT},
+          </if>
+          <if test="corpId != null">
+              #{corpId,jdbcType=BIGINT},
+          </if>
+          <if test="externalUserId != null">
+              #{externalUserId,jdbcType=VARCHAR},
+          </if>
+          <if test="unionId != null">
+              #{unionId,jdbcType=VARCHAR},
+          </if>
+          <if test="externalUserId3rdParty != null">
+              #{externalUserId3rdParty,jdbcType=VARCHAR},
+          </if>
+          <if test="type != null">
+              #{type,jdbcType=INTEGER},
+          </if>
+          <if test="name != null">
+              #{name,jdbcType=VARCHAR},
+          </if>
+          <if test="avatar != null">
+              #{avatar,jdbcType=VARCHAR},
+          </if>
+          <if test="gender != null">
+              #{gender,jdbcType=INTEGER},
+          </if>
+          <if test="isDelete != null">
+              #{isDelete,jdbcType=INTEGER},
+          </if>
+          <if test="groupMsgDisabled != null">
+              #{groupMsgDisabled,jdbcType=TINYINT},
+          </if>
+          <if test="createdAt != null">
+              #{createdAt,jdbcType=BIGINT},
+          </if>
+          <if test="updatedAt != null">
+              #{updatedAt,jdbcType=BIGINT},
+          </if>
+          <if test="deletedAt != null">
+              #{deletedAt,jdbcType=BIGINT},
+          </if>
+          <if test="createTime != null">
+              #{createTime,jdbcType=TIMESTAMP},
+          </if>
+          <if test="updateTime != null">
+              #{updateTime,jdbcType=TIMESTAMP},
+          </if>
+      </trim>
+      <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
+          select LAST_INSERT_ID()
+      </selectKey>
   </insert>
   <select id="countByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.WeComUserExample" resultType="java.lang.Long">
     select count(*) from we_com_user

+ 1 - 1
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComUserDataJob.java

@@ -121,7 +121,7 @@ public class WeComUserDataJob {
                     weComUser.setCreatedAt(createAt);
                     Long userId;
                     if (CollectionUtils.isEmpty(weComUserList)) {
-                        weComUserMapper.insert(weComUser);
+                        weComUserMapper.insertSelective(weComUser);
                         userId = weComUser.getId();
                     } else {
                         WeComUser oldWeComUser = weComUserList.get(0);