活动报名人员列表姓名星号处理

main
rong.liu 11 months ago
parent 9caa6ab593
commit 293ebf33ff
  1. 12
      competition/src/main/java/com/huoran/competition/service/impl/CompetitionRegistrationServiceImpl.java
  2. 43
      competition/src/main/java/com/huoran/competition/utils/HandleNameAsteriskReplacementUtil.java

@ -12,7 +12,10 @@ import com.huoran.common.entity.School;
import com.huoran.common.exception.CustomException; import com.huoran.common.exception.CustomException;
import com.huoran.common.exception.ExceptionEnum; import com.huoran.common.exception.ExceptionEnum;
import com.huoran.common.response.R; import com.huoran.common.response.R;
import com.huoran.competition.entity.*; import com.huoran.competition.entity.Competition;
import com.huoran.competition.entity.CompetitionRegistration;
import com.huoran.competition.entity.CompetitionTeam;
import com.huoran.competition.entity.CompleteCompetitionSetup;
import com.huoran.competition.entity.req.PageRegistrationStaffReq; import com.huoran.competition.entity.req.PageRegistrationStaffReq;
import com.huoran.competition.entity.vo.ExcelData; import com.huoran.competition.entity.vo.ExcelData;
import com.huoran.competition.entity.vo.PersonalExcelData; import com.huoran.competition.entity.vo.PersonalExcelData;
@ -23,6 +26,7 @@ import com.huoran.competition.service.CompetitionRegistrationService;
import com.huoran.competition.service.CompetitionTeamService; import com.huoran.competition.service.CompetitionTeamService;
import com.huoran.competition.service.TeamParticipantService; import com.huoran.competition.service.TeamParticipantService;
import com.huoran.competition.utils.ExcelStyleUtil; import com.huoran.competition.utils.ExcelStyleUtil;
import com.huoran.competition.utils.HandleNameAsteriskReplacementUtil;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -79,6 +83,12 @@ public class CompetitionRegistrationServiceImpl extends ServiceImpl<CompetitionR
public R registrationPageConditionQuery(PageRegistrationStaffReq req) { public R registrationPageConditionQuery(PageRegistrationStaffReq req) {
Page<RegistrationVO> page = new Page<RegistrationVO>(req.getPageNum(), req.getPageSize()); Page<RegistrationVO> page = new Page<RegistrationVO>(req.getPageNum(), req.getPageSize());
IPage<RegistrationVO> pageList = baseMapper.selectRegistrationByCondition(page, req); IPage<RegistrationVO> pageList = baseMapper.selectRegistrationByCondition(page, req);
pageList
.getRecords().forEach(registrationVO -> {
registrationVO.setUsername( HandleNameAsteriskReplacementUtil.desensitizedName(registrationVO.getUsername()));
});
return R.ok().put("data", pageList); return R.ok().put("data", pageList);
} }

@ -0,0 +1,43 @@
package com.huoran.competition.utils;
import org.apache.commons.lang3.StringUtils;
public class HandleNameAsteriskReplacementUtil {
/**
* @description: 名字脱敏
* 脱敏规则: 隐藏中中间部分比如:李某人 置换为 * , 李某置换为 *司徒司翘置换为 **
* @return:
* @author: ***
* @time: 2022/6/22
*/
public static String desensitizedName(String fullName) {
if (!com.mysql.cj.util.StringUtils.isNullOrEmpty(fullName)) {
int length = fullName.length();
if (length == 2) {
return fullName.substring(0, 1).concat("*");
} else if (length == 3) {
return StringUtils.left(fullName, 1).concat("*").concat(StringUtils.right(fullName, 1));
} else if (length > 3) {
return StringUtils.left(fullName, 1).concat(generateAsterisk(fullName.substring(1, length - 1).length())).concat(StringUtils.right(fullName, 1));
} else {
return fullName;
}
}
return fullName;
}
/**
* @description: 返回指定长度*字符串
* @return:
* @author: ***
* @time: 2022/6/22
*/
private static String generateAsterisk(int length) {
String result = "";
for (int i = 0; i < length; i++) {
result += "*";
}
return result;
}
}
Loading…
Cancel
Save