Przeglądaj źródła

1.添加人员信息后返回当前自增主键。

zhengqiang 5 lat temu
rodzic
commit
ba99b38f17

+ 2 - 4
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -32,11 +32,9 @@
         <result property="wechatNoticeEnabled" column="wechat_notice_enabled"/>
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.smart.modules.base.entity.PersonInfo">
-        <!--
-        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
-            select sys_guid() from dual
+        <selectKey resultType="long" keyColumn="id_" keyProperty="id">
+            SELECT LAST_INSERT_ID() AS id_
         </selectKey>
-        -->
         <![CDATA[
 		insert into base_person_info
 	    (company_id,name_,phone_,id_card,open_id,face_enabled,face_bound,card_enabled,

+ 0 - 1
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -581,7 +581,6 @@ public class PersonDeviceLogApiController {
                             personTotalCount = personTotalCount + Integer.parseInt(personCountStr);
                         }
                     }
-
                 }
             }
 

+ 2 - 2
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java

@@ -382,6 +382,7 @@ public class PersonInfoApiController {
             }
 
             PersonInfo personInfo = personInfoService.findByNameAndPhone(name, phone);
+
             if(personInfo == null) {
                 personInfo = new PersonInfo();
                 personInfo.setCompanyId(admin.getCompanyId());
@@ -394,10 +395,9 @@ public class PersonInfoApiController {
                 personInfo.setCreateBy(String.valueOf(admin.getId()));
                 personInfo.setCreateTime(new Date());
 
+                //插入后,会将自增id写到id属性中
                 int affectCount = personInfoService.insert(personInfo);
 
-                personInfo = personInfoService.findByNameAndPhone(name, phone);
-
                 //todo 关联设备
                 String[] deviceIds = bindDevices.split(",");
                 for(String deviceId : deviceIds){