Преглед на файлове

feat:修改人员增删改查的问题

刘传伟 преди 1 месец
родител
ревизия
a89f684f74

+ 13 - 0
src/main/java/com/anyway/exception/GlobalExceptionHandler.java

@@ -45,6 +45,19 @@ public class GlobalExceptionHandler {
     }
 
     /**
+     * 业务异常
+     *
+     * @param e
+     * @return
+     */
+    @ExceptionHandler(BusinessException.class)
+    @ResponseBody
+    public R<Void> handleBusinessException(BusinessException e){
+        log.error("业务异常:{}", e.getMessage(), e);
+        return R.fail(e.getMessage());
+    }
+
+    /**
      * 处理不可预知的异常
      *
      * @param e

+ 1 - 1
src/main/java/com/anyway/favor/service/impl/PersonServiceImpl.java

@@ -156,7 +156,7 @@ public class PersonServiceImpl implements PersonService {
             matePerson.setMateId(person.getId());
             matePerson.setMaritalStatus(1);
             personDao.update(matePerson);
-        } else if (!person.getMateId().equals(matePerson.getMateId())) {
+        } else if (!Objects.equals(person.getId(), matePerson.getMateId())) {
             log.error("该配偶{}的配偶{}不是当前人员", person.getMateId(), matePerson.getMateId());
             throw new BusinessException("该配偶的配偶不是当前人员");
         }

+ 24 - 9
src/main/resources/mapper/PersonDao.xml

@@ -8,8 +8,8 @@
 
     <!-- 表查询字段 -->
     <sql id="allColumns">
-        p.id, p.name, p.card_id, p.call_name, p.gender, p.birthday, p.death_date, p.marital_status,
-        p.mate_id, p.mother_id, p.father_id, p.sort, p.address, p.remark, p.create_time, p.create_by, p.modify_time,
+        p.id, p.name, p.card_id, p.phone, p.call_name, p.gender, p.birthday, p.death_date, p.marital_status,
+        p.mate_id, p.mother_id, p.father_id, p.sort, p.address, p.tags, p.remark, p.weight, p.create_time, p.create_by, p.modify_time,
         p.modify_by
     </sql>
 
@@ -53,6 +53,9 @@
         <if test="mateId != null">
             AND p.mate_id = #{mateId}
         </if>
+        <if test="mateIsNull != null">
+            AND p.mate_id is null
+        </if>
         <if test="motherId != null">
             AND p.mother_id = #{motherId}
         </if>
@@ -101,11 +104,12 @@
     <!-- 新增人员表信息 -->
     <insert id="add" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
         INSERT INTO t_person (
-            name, card_id, call_name, gender, birthday, death_date, marital_status,
-            mate_id, mother_id, father_id, sort, address, remark, create_by
+            name, card_id, phone, call_name, gender, birthday, death_date, marital_status,
+            mate_id, mother_id, father_id, sort, address, tags, remark, weight, create_by
         ) VALUES (
             #{name},
             #{cardId},
+            #{phone},
             #{callName},
             #{gender},
             #{birthday},
@@ -116,7 +120,9 @@
             #{fatherId},
             #{sort},
             #{address},
+            #{tags},
             #{remark},
+            #{weight},
             #{createBy}
         )
     </insert>
@@ -125,13 +131,16 @@
     <update id="update">
         UPDATE t_person
         <set>
-            <if test="name != null">
+            <if test="@Ognl@isNotEmpty(name)">
                 name = #{name},
             </if>
-            <if test="cardId != null">
+            <if test="@Ognl@isNotEmpty(cardId)">
                 card_id = #{cardId},
             </if>
-            <if test="callName != null">
+            <if test="@Ognl@isNotEmpty(phone)">
+                phone = #{phone},
+            </if>
+            <if test="@Ognl@isNotEmpty(callName)">
                 call_name = #{callName},
             </if>
             <if test="gender != null">
@@ -167,12 +176,18 @@
             <if test="sort != null">
                 sort = #{sort},
             </if>
-            <if test="address != null">
+            <if test="@Ognl@isNotEmpty(address)">
                 address = #{address},
             </if>
-            <if test="remark != null">
+            <if test="@Ognl@isNotEmpty(tags)">
+                tags = #{tags},
+            </if>
+            <if test="@Ognl@isNotEmpty(remark)">
                 remark = #{remark},
             </if>
+            <if test="weight != null">
+                weight = #{weight},
+            </if>
             <if test="modifyBy != null">
                 modify_by = #{modifyBy}
             </if>