Selaa lähdekoodia

fix: 站点人员与求职人员身份证信息脱敏

zhangying 10 kuukautta sitten
vanhempi
commit
825d44a618

+ 1 - 1
src/main/java/com/hz/employmentsite/controller/baseSettings/SiteUserController.java

@@ -96,7 +96,7 @@ public class SiteUserController {
             row.add(item.roleName);
             row.add(item.genderName);
             row.add(item.mobile);
-            row.add(dateUtils.getAgeForIdCard(item.getIdCard()));
+            row.add(item.age);
             row.add(item.idCard);
             row.add(item.siteName);
             rowsData.add(row);

+ 7 - 6
src/main/java/com/hz/employmentsite/controller/jobUserManager/JobUserController.java

@@ -13,7 +13,6 @@ import com.hz.employmentsite.model.PcSiteUserExample;
 import com.hz.employmentsite.model.SelectProps;
 import com.hz.employmentsite.services.service.AccountService;
 import com.hz.employmentsite.services.service.jobUserManager.JobUserService;
-import com.hz.employmentsite.util.DateUtils;
 import com.hz.employmentsite.util.ExcelHelper;
 import com.hz.employmentsite.util.StringUtils;
 import com.hz.employmentsite.vo.jobUserManager.JobUserVo;
@@ -41,9 +40,6 @@ public class JobUserController {
     @Autowired
     private PcSiteMapper pcSiteMapper;
 
-    @Autowired
-    private DateUtils dateUtils;
-
     @Autowired
     private StringUtils stringUtils;
 
@@ -63,7 +59,7 @@ public class JobUserController {
 
     @ResponseBody
     @GetMapping("/getDataByID")
-    public BaseResponse<PcJobuser> getDataById(String id, String loginUserID) {
+    public BaseResponse<PcJobuser> getDataById(String id, String loginUserID, @RequestParam(required = false) Integer cipherType) {
         var data = jobuserService.getDataById(id);
         if (data == null) {
             data = new JobUserVo();
@@ -86,6 +82,11 @@ public class JobUserController {
                     data.setRegionCode(curSiteInfo.getRegionCode());
                 }
             }
+        } else {
+            if (cipherType != null && cipherType == 1) {
+                // 身份证脱敏
+                data.setIdentityNumber(stringUtils.desensitizeData(data.getIdentityNumber(), "************", 3, 4));
+            }
         }
         return RespGenerstor.success(data);
     }
@@ -177,7 +178,7 @@ public class JobUserController {
                 row.add(item.getNationName());
                 row.add(item.getUserMobile());
                 row.add(item.siteName);
-                row.add(dateUtils.getAgeForIdCard(item.getIdentityNumber()));
+                row.add(item.getAge());
                 row.add(item.cultureName);
                 row.add(item.getAddress());
                 row.add(item.jobStatusName);

+ 9 - 0
src/main/java/com/hz/employmentsite/services/impl/baseSettings/SiteUserImpl.java

@@ -10,6 +10,7 @@ import com.hz.employmentsite.services.service.UserService;
 import com.hz.employmentsite.services.service.baseSettings.SiteUserService;
 import com.hz.employmentsite.services.service.jobUserManager.OccupationalService;
 import com.hz.employmentsite.services.service.system.DictionaryService;
+import com.hz.employmentsite.util.DateUtils;
 import com.hz.employmentsite.util.StringUtils;
 import com.hz.employmentsite.vo.baseSettings.SiteUserVo;
 import net.sourceforge.pinyin4j.PinyinHelper;
@@ -36,6 +37,9 @@ public class SiteUserImpl implements SiteUserService {
     @Autowired
     private StringUtils stringUtils;
 
+    @Autowired
+    private DateUtils dateUtils;
+
     @Autowired
     private PcSiteUserMapper pcSiteUserMapper;
 
@@ -69,6 +73,11 @@ public class SiteUserImpl implements SiteUserService {
     public PageInfo<SiteUserVo> getList(int pageIndex, int pageSize, List<String> siteUserIDList, String siteUserName, String siteID, String roleName, String regionCode, String userNo) {
         PageHelper.startPage(pageIndex, pageSize);
         List<SiteUserVo> dataList = userInfoCQuery.getList(stringUtils.ListToInSql(siteUserIDList), siteUserName, siteID, roleName, regionCode, userNo);
+        // 身份证脱敏
+        dataList.forEach(item -> {
+            item.setAge(dateUtils.getAgeForIdCard(item.idCard));
+            item.setIdCard(stringUtils.desensitizeData(item.idCard, "************", 3, 4));
+        });
         PageInfo<SiteUserVo> result = new PageInfo(dataList);
         return result;
     }

+ 10 - 4
src/main/java/com/hz/employmentsite/services/impl/jobUserManager/JobUserServiceImpl.java

@@ -7,12 +7,12 @@ import com.hz.employmentsite.mapper.*;
 import com.hz.employmentsite.mapper.cquery.JobUserCQuery;
 import com.hz.employmentsite.model.*;
 import com.hz.employmentsite.services.service.jobUserManager.JobUserService;
+import com.hz.employmentsite.util.DateUtils;
 import com.hz.employmentsite.util.StringUtils;
 import com.hz.employmentsite.vo.jobUserManager.JobUserVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import javax.print.DocFlavor;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -28,6 +28,8 @@ public class JobUserServiceImpl implements JobUserService {
     @Autowired
     private StringUtils stringUtils;
     @Autowired
+    private DateUtils dateUtils;
+    @Autowired
     private PcEducationMapper pcEducationMapper;
     @Autowired
     private PcJobuserMapper pcJobuserMapper;
@@ -49,13 +51,17 @@ public class JobUserServiceImpl implements JobUserService {
                                        String workTime,String loginUserID) {
         PageHelper.startPage(pageIndex, pageSize);
         String curLoginUserSiteID = "";
-        if(!stringUtils.IsNullOrEmpty(loginUserID)){
+        if (!stringUtils.IsNullOrEmpty(loginUserID)) {
             PcSiteUserExample siteUserExp = new PcSiteUserExample();
             siteUserExp.or().andUserIDEqualTo(loginUserID);
             curLoginUserSiteID = pcSiteUserMapper.selectByExample(siteUserExp).get(0).getSiteID();
         }
-        List<JobUserVo> list = jobUserCQuery.selectJobUserList(stringUtils.ListToInSql(jobUserIDList), name, siteId, jobStatus, sexId, educationTypeId, emphasisTypeId, createUserId, workTime,curLoginUserSiteID);
-
+        List<JobUserVo> list = jobUserCQuery.selectJobUserList(stringUtils.ListToInSql(jobUserIDList), name, siteId, jobStatus, sexId, educationTypeId, emphasisTypeId, createUserId, workTime, curLoginUserSiteID);
+        // 身份证脱敏
+        list.forEach(item -> {
+            item.setAge(dateUtils.getAgeForIdCard(item.getIdentityNumber()));
+            item.setIdentityNumber(stringUtils.desensitizeData(item.getIdentityNumber(), "************", 3, 4));
+        });
         PageInfo<JobUserVo> result = new PageInfo(list);
 
         return result;

+ 16 - 1
src/main/java/com/hz/employmentsite/util/StringUtils.java

@@ -2,7 +2,6 @@ package com.hz.employmentsite.util;
 
 import org.springframework.stereotype.Component;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -23,4 +22,20 @@ public class StringUtils {
         return "'" + sql + "'";
     }
 
+    /**
+     * 重要信息脱密
+     *
+     * @param data        数据
+     * @param ciphertext  加密密文
+     * @param startLength 开始位置
+     * @param endLength   结束位置
+     * @return 脱敏后的文本数据
+     */
+    public String desensitizeData(String data, String ciphertext, int startLength, int endLength) {
+        if (IsNullOrEmpty(data)) {
+            return "";
+        }
+        return data.substring(0, startLength) + ciphertext + data.substring(data.length() - endLength);
+    }
+
 }

+ 2 - 2
vue/src/api/jobUserManager/jobuser/index.ts

@@ -23,12 +23,12 @@ export function getJobUserDataList(){
   );
 }
 
-export function getDataById(id: any,loginUserID:any) {
+export function getDataById(id: any, loginUserID: any, cipherType: any) {
   return request(
     {
       url: 'jobUserService/jobUser/getDataByID',
       method: 'get',
-      params: {id,loginUserID},
+      params: {id, loginUserID, cipherType},
     },
     { isNew: true },
   );

+ 22 - 0
vue/src/utils/dateUtil.ts

@@ -20,4 +20,26 @@ export function formatToDate(
   return dayjs(date).format(format);
 }
 
+export function calculateAge(idCardNumber) {
+  if (!idCardNumber) {
+    return 0;
+  }
+
+  // 假设身份证号中出生日期的格式为YYYYMMDD
+  const birthYear = parseInt(idCardNumber.substring(6, 10), 10);
+  const birthMonth = parseInt(idCardNumber.substring(10, 12), 10);
+  const birthDay = parseInt(idCardNumber.substring(12, 14), 10);
+  // 获取当前日期
+  const currentDate = new Date();
+  const currentYear = currentDate.getFullYear();
+  const currentMonth = currentDate.getMonth() + 1; // 月份从 0 开始
+  const currentDay = currentDate.getDate();
+  // 计算年龄
+  let age = currentYear - birthYear;
+  if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay)) {
+    age--; // 生日还未过,减去一岁
+  }
+  return age;
+}
+
 export const dateUtil = dayjs;

+ 1 - 7
vue/src/views/baseSettings/positionMap/index.vue

@@ -15,7 +15,6 @@
               :options="regionList"
               :field-names="{ label: 'name', value: 'code' }"
               :allow-clear="true"
-              @change="changeRegion"
             >
             </a-select>
           </a-form-item>
@@ -36,12 +35,7 @@
         </a-col>
         <a-col :span="6">
           <a-form-item label="日期" :label-col="{ span: 8 }" name="startDate">
-            <a-input
-              v-model:value="searchParams.startDate"
-              placeholder=""
-              :allow-clear="true"
-              type="date"
-            />
+            <a-date-picker v-model:value="searchParams.startDate" value-format="YYYY-MM-DD"/>
           </a-form-item>
         </a-col>
         <a-col :span="6" style="text-align: left">

+ 1 - 27
vue/src/views/baseSettings/siteUser/index.vue

@@ -117,11 +117,7 @@ export default defineComponent({
       {title: '用户类型', dataIndex: 'roleName', key: 'roleName',width:120, align: "center"},
       {title: '性别', dataIndex: 'genderName', key: 'genderName', align: "center"},
       {title: '联系电话', dataIndex: 'mobile', key: 'mobile', align: "center"},
-      {
-        title: '年龄', dataIndex: 'age', key: 'age', align: "center", customRender: item => {
-          return calculateAge(item.record.idCard);
-        }
-      },
+      {title: '年龄', dataIndex: 'age', key: 'age', align: "center"},
       {title: '身份证号', dataIndex: 'idCard', key: 'idCard', align: "center"},
       {title: '所属驿站', dataIndex: 'siteName', key: 'siteName', align: "center"},
       {title: '操作', key: 'operation', fixed: 'right', width: 150, align: "center"},
@@ -164,28 +160,6 @@ export default defineComponent({
       showTotal: total => getPaginationTotalTitle(total)
     }));
 
-    const calculateAge = (idCardNumber) => {
-      if (!idCardNumber) {
-        return 0;
-      }
-
-      // 假设身份证号中出生日期的格式为YYYYMMDD
-      const birthYear = parseInt(idCardNumber.substring(6, 10), 10);
-      const birthMonth = parseInt(idCardNumber.substring(10, 12), 10);
-      const birthDay = parseInt(idCardNumber.substring(12, 14), 10);
-      // 获取当前日期
-      const currentDate = new Date();
-      const currentYear = currentDate.getFullYear();
-      const currentMonth = currentDate.getMonth() + 1; // 月份从 0 开始
-      const currentDay = currentDate.getDate();
-      // 计算年龄
-      let age = currentYear - birthYear;
-      if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay)) {
-        age--; // 生日还未过,减去一岁
-      }
-      return age;
-    }
-
     const getAllSites = () => {
       getSiteList(searchParams).then((result :any) => {
         allSites.value = result.list;

+ 1 - 1
vue/src/views/jobUserManager/jobuser/edit.vue

@@ -865,7 +865,7 @@ export default defineComponent(
         getOccupationalLevelList()
         getFirstOccupationalList()
         getInfo().then((loginUserInfo:any)=>{
-          getDataById(id,loginUserInfo.userID).then(data => {
+          getDataById(id, loginUserInfo.userID, null).then(data => {
             formState.dataModel = data;
             if (formState.dataModel.regionCode) {
               changeCity();

+ 1 - 23
vue/src/views/jobUserManager/jobuser/index.vue

@@ -191,11 +191,7 @@ export default defineComponent({
       {title: '民族', dataIndex: 'nationName', key: 'nationName', width: 80, align: "center"},
       {title: '联系电话', dataIndex: 'userMobile', key: 'userMobile',align: "center"},
       {title: '所属驿站', dataIndex: 'siteName', key: 'siteName',align: "center"},
-      {
-        title: '年龄', dataIndex: 'age', key: 'age',align: "center", customRender: item => {
-          return calculateAge(item.record.identityNumber);
-        }
-      },
+      {title: '年龄', dataIndex: 'age', key: 'age', align: "center"},
       {title: '最高学历', dataIndex: 'cultureName', key: 'cultureName', align: "center"},
       {title: '地址', dataIndex: 'address', key: 'address',align: "center"},
       {title: '就业状态', dataIndex: 'jobStatusName', key: 'jobStatusName',align: "center"},
@@ -217,23 +213,6 @@ export default defineComponent({
     const educationTypeList = ref<SelectProps['options']>();
     const emphasisTypeList = ref<SelectProps['options']>();
 
-    const calculateAge = (idCardNumber) => {
-      // 假设身份证号中出生日期的格式为YYYYMMDD
-      const birthYear = parseInt(idCardNumber.substring(6, 10), 10);
-      const birthMonth = parseInt(idCardNumber.substring(10, 12), 10);
-      const birthDay = parseInt(idCardNumber.substring(12, 14), 10);
-      // 获取当前日期
-      const currentDate = new Date();
-      const currentYear = currentDate.getFullYear();
-      const currentMonth = currentDate.getMonth() + 1; // 月份从 0 开始
-      const currentDay = currentDate.getDate();
-      // 计算年龄
-      let age = currentYear - birthYear;
-      if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay)) {
-        age--; // 生日还未过,减去一岁
-      }
-      return age;
-    }
     const onSelectChange = (selectedRowKeys: any) => {
       formState.selectedRowKeys = selectedRowKeys;
     };
@@ -356,7 +335,6 @@ export default defineComponent({
       getSexList,
       getEducationList,
       getEmphasisTypeList,
-      calculateAge,
       onVitae,
       expand,
       exportSearchParams

+ 5 - 1
vue/src/views/jobUserManager/jobuser/vitae.vue

@@ -112,6 +112,10 @@ import type {SelectProps, TableColumnsType} from "ant-design-vue";
 import dayjs from "dayjs";
 import {getSysDictionaryList} from "@/api/system/dictionary";
 import {getJobHuntList} from "@/api/jobUserManager/jobhunt";
+import {useUserStore} from "@/store/modules/user";
+
+const userStore = useUserStore();
+const userInfo = ref(userStore.getUserInfo)
 
 // 求职人员信息
 const jobUserInfo = reactive({
@@ -235,7 +239,7 @@ const cultureList = ref<SelectProps['options']>();
 
 // 加载求职人员数据
 const loadData = (id: any) => {
-  getDataById(id).then(data => {
+  getDataById(id, userInfo.value.userID, 1).then(data => {
     Object.keys(jobUserInfo).forEach(key => {
       jobUserInfo[key] = data[key];
     })