联调问题
This commit is contained in:
parent
6bd10c86fa
commit
c02c8aaaf9
|
|
@ -59,8 +59,12 @@ public class PersonnelController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
//人员所属下拉
|
||||
//0:运检站1:项目部
|
||||
/**
|
||||
* 人员所属下拉
|
||||
* 0:运检站1:项目部
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getInspectionStationSelect")
|
||||
public AjaxResult getInspectionStationSelect(InspectionStationVo vo) {
|
||||
try {
|
||||
|
|
@ -72,8 +76,12 @@ public class PersonnelController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
//人员性质/人员分类/岗位下拉
|
||||
// 0:人员分类1:人员性质2:岗位列表
|
||||
/**
|
||||
* 人员性质/人员分类/岗位下拉
|
||||
* 0:人员分类1:人员性质2:岗位列表
|
||||
* @param vo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getPersonnelClassificationSelect")
|
||||
public AjaxResult getPersonnelClassificationSelect(InspectionStationVo vo) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,19 @@ public interface PersonnelService {
|
|||
*/
|
||||
int updatePersonnel(PersonnelVo personnelVo);
|
||||
|
||||
/**
|
||||
* 人员所属下拉
|
||||
* 0:运检站1:项目部
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
List<SelectDto> getInspectionStationSelect(String category);
|
||||
|
||||
/**
|
||||
* 人员性质/人员分类/岗位下拉
|
||||
* 0:人员分类1:人员性质2:岗位列表
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
List<SelectDto> getPersonnelClassificationSelect(String category);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.digital.service.impl;
|
||||
|
||||
import com.bonus.common.utils.AesUtil;
|
||||
import com.bonus.common.utils.SecurityUtils;
|
||||
import com.bonus.common.utils.StringUtils;
|
||||
import com.bonus.digital.dao.PersonnelVo;
|
||||
|
|
@ -30,7 +31,11 @@ public class PersonnelServiceImpl implements PersonnelService {
|
|||
*/
|
||||
@Override
|
||||
public List<PersonnelVo> getPersonnelList(PersonnelVo personnelVo) {
|
||||
return personnelMapper.getPersonnelList(personnelVo);
|
||||
List<PersonnelVo> personnelList = personnelMapper.getPersonnelList(personnelVo);
|
||||
for (PersonnelVo personnel : personnelList) {
|
||||
personnel.setPhone(AesUtil.encrypt(personnel.getPhone()));
|
||||
}
|
||||
return personnelList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,11 +75,23 @@ public class PersonnelServiceImpl implements PersonnelService {
|
|||
return personnelMapper.updatePersonnel(personnelVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员所属下拉
|
||||
* 0:运检站1:项目部
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SelectDto> getInspectionStationSelect(String category) {
|
||||
return personnelMapper.getInspectionStationSelect(category);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员性质/人员分类/岗位下拉
|
||||
* 0:人员分类1:人员性质2:岗位列表
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SelectDto> getPersonnelClassificationSelect(String category) {
|
||||
return personnelMapper.getPersonnelClassificationSelect(category);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
package com.bonus.common.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* AES 加解密工具类
|
||||
*/
|
||||
public class AesUtil {
|
||||
|
||||
// 默认密钥和向量(应与前端保持一致)
|
||||
private static final String DEFAULT_KEY = "0123456789abcdef0123456789abcdef";
|
||||
private static final String DEFAULT_IV = "0123456789abcdef";
|
||||
|
||||
// 算法/模式/填充
|
||||
private static final String ALGORITHM = "AES";
|
||||
private static final String TRANSFORMATION = "AES/CBC/PKCS5Padding";
|
||||
|
||||
/**
|
||||
* 加密
|
||||
* @param data 要加密的数据
|
||||
* @param key 密钥(可选,默认使用类常量)
|
||||
* @param iv 初始向量(可选,默认使用类常量)
|
||||
* @return Base64编码的加密字符串
|
||||
*/
|
||||
public static String encrypt(String data, String key, String iv) {
|
||||
try {
|
||||
if (key == null) key = DEFAULT_KEY;
|
||||
if (iv == null) iv = DEFAULT_IV;
|
||||
|
||||
// 检查密钥长度
|
||||
if (key.length() != 16 && key.length() != 24 && key.length() != 32) {
|
||||
throw new IllegalArgumentException("密钥长度必须为16、24或32位");
|
||||
}
|
||||
|
||||
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), ALGORITHM);
|
||||
IvParameterSpec ivParameter = new IvParameterSpec(iv.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParameter);
|
||||
|
||||
byte[] encrypted = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
return Base64.getEncoder().encodeToString(encrypted);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("加密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
* @param encryptedData Base64编码的加密字符串
|
||||
* @param key 密钥(可选,默认使用类常量)
|
||||
* @param iv 初始向量(可选,默认使用类常量)
|
||||
* @return 解密后的原文
|
||||
*/
|
||||
public static String decrypt(String encryptedData, String key, String iv) {
|
||||
try {
|
||||
if (key == null) key = DEFAULT_KEY;
|
||||
if (iv == null) iv = DEFAULT_IV;
|
||||
|
||||
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), ALGORITHM);
|
||||
IvParameterSpec ivParameter = new IvParameterSpec(iv.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
Cipher cipher = Cipher.getInstance(TRANSFORMATION);
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameter);
|
||||
|
||||
byte[] decoded = Base64.getDecoder().decode(encryptedData);
|
||||
byte[] decrypted = cipher.doFinal(decoded);
|
||||
return new String(decrypted, StandardCharsets.UTF_8);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("解密失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用默认密钥和向量加密
|
||||
*/
|
||||
public static String encrypt(String data) {
|
||||
return encrypt(data, DEFAULT_KEY, DEFAULT_IV);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用默认密钥和向量解密
|
||||
*/
|
||||
public static String decrypt(String encryptedData) {
|
||||
return decrypt(encryptedData, DEFAULT_KEY, DEFAULT_IV);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机密钥
|
||||
* @param length 密钥长度(16/24/32)
|
||||
* @return 随机密钥
|
||||
*/
|
||||
public static String generateKey(int length) {
|
||||
if (length != 16 && length != 24 && length != 32) {
|
||||
throw new IllegalArgumentException("密钥长度必须为16、24或32");
|
||||
}
|
||||
|
||||
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < length; i++) {
|
||||
int index = (int) (Math.random() * chars.length());
|
||||
sb.append(chars.charAt(index));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import com.bonus.common.utils.AesUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -75,7 +77,11 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUserList(SysUser user)
|
||||
{
|
||||
return userMapper.selectUserList(user);
|
||||
List<SysUser> sysUserList = userMapper.selectUserList(user);
|
||||
for (SysUser sysUser : sysUserList){
|
||||
sysUser.setPhonenumber(AesUtil.encrypt(sysUser.getPhonenumber()));
|
||||
}
|
||||
return sysUserList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue