6 changed files with 267 additions and 35 deletions
@ -0,0 +1,110 @@ |
|||
package com.zdxt.enforcementcode.controller.app.enforcement; |
|||
|
|||
|
|||
import cn.hutool.core.convert.Convert; |
|||
import com.zdxt.enforcementcode.common.config.SrnwgConfig; |
|||
import com.zdxt.enforcementcode.common.util.IdCardCryptoUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.dromara.common.mybatis.core.page.PageQuery; |
|||
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|||
import org.dromara.common.web.core.BaseController; |
|||
import org.dromara.system.domain.bo.QuerySysUserBo; |
|||
import org.dromara.system.domain.vo.SysUserVo; |
|||
import org.dromara.system.service.ISysUserService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.ResponseBody; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 执法端共用方法类 |
|||
* @Author: kylin |
|||
* @Date: 2024/5/1 3:00 下午 |
|||
* @Version: 1.0 |
|||
* @Desc: TODO |
|||
*/ |
|||
@Slf4j |
|||
@Controller |
|||
@RequestMapping("/app-enf/app") |
|||
public class AppSystemController extends BaseController { |
|||
|
|||
@Autowired |
|||
private ISysUserService userService; |
|||
|
|||
@Autowired |
|||
private SrnwgConfig srnwgConfig; |
|||
|
|||
/** |
|||
* 监督端查询执法人员&非执法人员 |
|||
* 排除admin和手机号码为空的数据) |
|||
* |
|||
* @param user 查询条件 |
|||
* @param pageQuery 分页参数 |
|||
* @return 分页结果 |
|||
*/ |
|||
@PostMapping("/selectUserListByHave") |
|||
@ResponseBody |
|||
public TableDataInfo selectUserListByHave(QuerySysUserBo user, PageQuery pageQuery) { |
|||
// 初始化 params,避免空指针异常
|
|||
if (user.getParams() == null) { |
|||
user.setParams(new java.util.HashMap<>()); |
|||
} |
|||
|
|||
// 设置排除的用户ID列表
|
|||
if (null != user.getNotUserId()) { |
|||
user.getParams().put("notUserIds", Convert.toStrArray(user.getNotUserId())); |
|||
} |
|||
|
|||
// 设置是否显示执法证号标识
|
|||
if (null != user.getIsShowCardId()) { |
|||
user.getParams().put("showCardId", user.getIsShowCardId()); |
|||
} |
|||
|
|||
// 清空部门ID过滤
|
|||
user.setDeptId(null); |
|||
|
|||
// 调用 Service 层获取分页数据
|
|||
TableDataInfo<SysUserVo> result = userService.selectUserListByHave(user, pageQuery); |
|||
List<SysUserVo> list = result.getRows(); |
|||
|
|||
// 解密手机号
|
|||
if (list != null && !list.isEmpty()) { |
|||
decryptPhoneNumbers(list); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* 批量解密用户手机号 |
|||
* |
|||
* @param userList 用户列表 |
|||
*/ |
|||
private void decryptPhoneNumbers(List<SysUserVo> userList) { |
|||
String secretKey = srnwgConfig.getSecretKey(); |
|||
userList.forEach(user -> { |
|||
if (StringUtils.isEmpty(user.getPhonenumber())) { |
|||
return; |
|||
} |
|||
|
|||
// 纯数字表示未加密,直接使用
|
|||
if (user.getPhonenumber().matches("^\\d+$")) { |
|||
return; |
|||
} |
|||
|
|||
// 尝试解密手机号
|
|||
try { |
|||
String decryptPhone = IdCardCryptoUtil.symmetricDecryptIdCard(secretKey, user.getPhonenumber()); |
|||
user.setPhonenumber(decryptPhone); |
|||
} catch (Exception e) { |
|||
// 解密失败,保持原值
|
|||
log.warn("手机号解密失败: {}", user.getPhonenumber(), e); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
package org.dromara.system.domain.bo; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 用户查询对象 sys_user |
|||
* |
|||
* @author ruoyi |
|||
*/ |
|||
@Data |
|||
public class QuerySysUserBo implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 用户ID |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 部门ID |
|||
*/ |
|||
private String deptId; |
|||
|
|||
/** |
|||
* 部门父ID |
|||
*/ |
|||
private String parentId; |
|||
|
|||
/** |
|||
* 角色ID |
|||
*/ |
|||
private Long roleId; |
|||
|
|||
/** |
|||
* 登录名称 |
|||
*/ |
|||
private String loginName; |
|||
|
|||
/** |
|||
* 用户名称(支持模糊查询用户名称或执法证号) |
|||
*/ |
|||
private String userName; |
|||
|
|||
/** |
|||
* 执法证号 |
|||
*/ |
|||
private String lawCertificateNum; |
|||
|
|||
/** |
|||
* 用户邮箱 |
|||
*/ |
|||
private String email; |
|||
|
|||
/** |
|||
* 手机号码 |
|||
*/ |
|||
private String phonenumber; |
|||
|
|||
/** |
|||
* 用户性别(0男 1女 2未知) |
|||
*/ |
|||
private String sex; |
|||
|
|||
/** |
|||
* 帐号状态(0正常 1停用) |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* 删除标志(0代表存在 2代表删除) |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
/** |
|||
* 租户代码 |
|||
*/ |
|||
private String tenantCode; |
|||
|
|||
/** |
|||
* 排除的用户ID(单个) |
|||
*/ |
|||
private String notUserId; |
|||
|
|||
/** |
|||
* 是否显示执法证号(0-是,需要筛选执法人员) |
|||
*/ |
|||
private Integer isShowCardId; |
|||
|
|||
/** |
|||
* 用户类型 |
|||
*/ |
|||
private String type; |
|||
|
|||
/** |
|||
* 扩展参数 |
|||
* params.beginTime - 开始时间 |
|||
* params.endTime - 结束时间 |
|||
* params.notUserIds - 排除的用户ID数组 |
|||
* params.showCardId - 是否显示执法证号 |
|||
* params.dataScope - 数据权限SQL片段 |
|||
*/ |
|||
private Map<String, Object> params; |
|||
|
|||
|
|||
} |
|||
|
|||
Loading…
Reference in new issue