From 88e520b3cbb5f25ff6d5010980f3e684a4c127d4 Mon Sep 17 00:00:00 2001 From: ajaxfan <909938737@qq.com> Date: Mon, 4 Jan 2021 17:10:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/base/entity/BaseCacheUser.java | 215 +++++++++--------- .../impl/BaseCacheUserServiceImpl.java | 34 +-- 2 files changed, 128 insertions(+), 121 deletions(-) diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java index d432655..6e529ce 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/entity/BaseCacheUser.java @@ -16,132 +16,131 @@ import java.util.Date; @Accessors(chain = true) public class BaseCacheUser { + /** + * PKID + */ + private Long userId; - /** - * PKID - */ - private Long userId; + /** + * 姓名 + */ + private String lastName; + /** + * 姓氏 + */ + private String firstName; + /** + * 全名 + */ + private String fullName; - /** - * 姓名 - */ - private String lastName; - /** - *姓氏 - */ - private String firstName; - /** - * 全名 - */ - private String fullName; + /** + * 电子邮件 + */ + private String emailAddress; + // + /** + * 用户名 + */ + private String loginName; + // + /** + * 手机号 + */ + private String mobilePhone; + /** + * 办公号 + */ + private String officePhone; - /** - * 电子邮件 - */ - private String emailAddress; - // - /** - * 用户名 - */ - private String loginName; - // - /** - * 手机号 - */ - private String mobilePhone; - /** - * 办公号 - */ - private String officePhone; + /** + * 性别 + */ + private String sex; - /** - * 性别 - */ - private String sex; + /** + * 员工类别 + */ + private String employeeCategory; - /** - * 员工类别 - */ - private String employeeCategory; + /** + * 用户类型 + */ + private String userType; - /** - * 用户类型 - */ - private String userType; + /** + * 出生日期 + */ + private Date dateOfBirth; - /** - * 出生日期 - */ - private Date dateOfBirth; + /** + * 年龄 + */ + private Integer age; - /** - * 年龄 - */ - private Integer age; + /** + * 员工编号 + */ + private String employeeNumber; - /** - * 员工编号 - */ - private String employeeNumber; + /** + * 国籍ID + */ + private String nationalityId; - /** - * 国籍ID - */ - private String nationalityId; + /** + * 国籍 + */ + private String nationality; - /** - * 国籍 - */ - private String nationality; + /** + * 身份证号码 + */ + private String nationalIdentifier; - /** - * 身份证号码 - */ - private String nationalIdentifier; + /** + * 主管ID + */ + private Integer supervisorId; - /** - * 主管ID - */ - private Integer supervisorId; + /** + * 组织ID + */ + private String organizationId; - /** - * 组织ID - */ - private String organizationId; + /** + * 组织名称 + */ + private String organizationName; + // + /** + * 组织机构类别 + */ + private String orgCategory; - /** - * 组织名称 - */ - private String organizationName; - // - /** - * 组织机构类别 - */ - private String orgCategory; + /** + * 部门ID + */ + private String deptId; - /** - * 部门ID - */ - private String deptId; + /** + * 部门名称 + */ + private String deptName; - /** - * 部门名称 - */ - private String deptName; + /** + * 角色ID + */ + private String roleIds; - /** - * 角色ID - */ - private String roleIds; + /** + * 业务组id + */ + private Integer bussiGroupId; - /** - * 业务组id - */ - private Integer bussiGroupId; - - /** - * 职位ID - */ - private Integer positionId; + /** + * 职位ID + */ + private Integer positionId; } diff --git a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java index 42e2a86..9e5c847 100644 --- a/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java +++ b/uboot-common/src/main/java/com/chinaunicom/mall/ebtp/common/base/service/impl/BaseCacheUserServiceImpl.java @@ -22,6 +22,8 @@ import lombok.extern.slf4j.Slf4j; @Service @Slf4j public class BaseCacheUserServiceImpl implements IBaseCacheUserService { + // TODO 设置种子ID, 对其雪花ID长度 + private static final long ID_SEED = 1345977833027100000L; private static final Map USERS = new ConcurrentHashMap<>(); @@ -31,19 +33,10 @@ public class BaseCacheUserServiceImpl implements IBaseCacheUserService { log.debug("Current user principal: " + map); - return new BaseCacheUser().setUserId(1L).setFullName((String) map.get("staffName")) - .setLoginName((String) map.get("username")).setRoleIds((String) map.get("staffId")) - .setOrganizationId((String) map.get("ou")).setOrganizationName((String) map.get("ouName")); - -// BaseCacheUser user = new BaseCacheUser(); -// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); -// if (attributes != null) { -// HttpServletRequest request = attributes.getRequest(); -// String token = request.getHeader("JwtToken"); -// user = USERS.get(token); -// } -// log.info(" --------------- 当前用户:" + JsonUtils.objectToJson(user) + " ------------------------------"); -// return user; + return new BaseCacheUser().setUserId(getUserId((String) map.get("staffId"))) + .setFullName((String) map.get("staffName")).setLoginName((String) map.get("username")) + .setRoleIds((String) map.get("staffId")).setOrganizationId((String) map.get("ou")) + .setOrganizationName((String) map.get("ouName")); } @Override @@ -51,6 +44,21 @@ public class BaseCacheUserServiceImpl implements IBaseCacheUserService { return USERS.values(); } + /** + * @param string + * @return + */ + // TODO: 山东框架使用未使用雪花ID存放字符串,暂时使用该方法进行id转换 + private Long getUserId(String rawUid) { + long id = ID_SEED; + byte[] bytes = rawUid.getBytes(); + + for (byte b : bytes) { + id += b; + } + return id; + } + static { BaseCacheUser user = new BaseCacheUser().setUserId(1L).setFullName("采购经理").setLoginName("caigou") .setRoleIds("caigou").setOrganizationId("100").setOrganizationName("中国联通吉林分公司");