com.lcw.one.util.utils.UUID类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中com.lcw.one.util.utils.UUID类的一些代码示例,展示了UUID类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UUID类的具体详情如下:
包路径:com.lcw.one.util.utils.UUID
类名称:UUID

UUID介绍

暂无

代码示例

代码示例来源:origin: lcw2004/one

public static String randomUUID(int length) {
  String uuId = randomUUID();
  if(length > uuId.length()) {
    length = uuId.length();
  }
  return uuId.substring(0, length);
}

代码示例来源:origin: lcw2004/one

public static String randomUserId() {
    return randomUUID10();
  }
}

代码示例来源:origin: lcw2004/one

@Override
public UserManagerEO save(UserManagerEO entity) {
  if (entity.getSysOffice() == null) {
    throw new OneBaseException("用户所属机构不能为空");
  }
  // 验证登录名、手机号码是否重复
  userInfoEOService.validateUserInfo(entity.getUserInfo());
  String userId = UUID.randomUserId();
  entity.setOfficeId(entity.getSysOffice().getId());
  entity.setUserId(userId);
  UserInfoEO userInfoEO = entity.getUserInfo();
  userInfoEO.setUserId(userId);
  userInfoEO.setType(UserInfoTypeEnum.MANAGER.getValue());
  userInfoEO.setStatus(UserInfoStatusEnum.NORMAL.getValue());
  userInfoEO.setCreateTime(new Date());
  userInfoEO.setPassword(PasswordUtils.encryptPassword(entity.getPassword()));
  UserContactInfoEO userContactInfoEO = userInfoEO.getUserContactInfo();
  userContactInfoEO.setUserId(userId);
  userInfoEOService.save(userInfoEO);
  userContactInfoEOService.save(userContactInfoEO);
  sysUserRoleEOService.saveSysUserRole(userId, entity.getRoleIdList());
  super.save(entity);
  return entity;
}

代码示例来源:origin: lcw2004/one

public static String generateFilePath(String fileType) {
    String path = DateUtils.dateToString(new Date(), "yyyy" + FILE_SEPARATOR + "MM" + FILE_SEPARATOR + "dd");
    return path + FILE_SEPARATOR + UUID.randomUUID() + "." + fileType;
  }
}

代码示例来源:origin: lcw2004/one

@ApiOperation(value = "新增字典")
@PostMapping("")
public ResponseMessage<SysDictEO> save(@RequestBody SysDictEO sysMenuEO) {
  sysMenuEO.setDictId(UUID.randomUUID10());
  sysMenuEO.setDelFlag(DeleteFlagEnum.NORMAL.getValue());
  return Result.success(sysDictEOService.save(sysMenuEO));
}

代码示例来源:origin: lcw2004/one

/**
 * 设置Cookie值,随机生成一个Cookie
 *
 * @param request
 * @param response
 * @return
 * @throws IOException
 */
public static String setCookie(HttpServletRequest request, HttpServletResponse response) throws IOException {
  String cookieValue = UUID.randomUUID();
  setCookie(request, response, cookieValue);
  return cookieValue;
}

代码示例来源:origin: lcw2004/one

@Override
public BaseTemplateEO save(BaseTemplateEO entity) {
  entity.setTemplateId(UUID.randomUUID10());
  long count = dao.count(entity.getCode());
  if (count == 0) {
    entity.setIsDefault(1);
  }
  super.save(entity);
  return entity;
}

代码示例来源:origin: lcw2004/one

public void save(String auditItemId, List<FlowAuditItemDetailEO> detailList) {
  for (FlowAuditItemDetailEO detailEO: detailList) {
    detailEO.setDetailId(UUID.randomUUID());
    detailEO.setAuditItemId(auditItemId);
  }
  this.save(detailList);
}

代码示例来源:origin: lcw2004/one

@CacheEvict(value = "system_dict", key = "'system_dict'", allEntries = true)
public SysDictDataEO save(String dictId, SysDictDataEO sysDictDataEO) {
  sysDictDataEO.setDataId(UUID.randomUUID10());
  sysDictDataEO.setDictId(dictId);
  sysDictDataEO.setSort(dao.getNextSort(dictId));
  return this.save(sysDictDataEO);
}

代码示例来源:origin: lcw2004/one

public void createEvent(EventBean eventBean) {
  eventBean.setCreateTime(new Date());
  eventBean.setEventId(UUID.randomUUID());
  // 存数据库做备份,立即执行,否则事件接收的时候还没执行会弄乱数据
  sysEventEOService.save(eventBean);
  sysEventEOService.flush();
  // 调用Redis发送事件
  String json = GsonUtil.toJson(eventBean);
  logger.info("Send Event Message [{}]", json);
  stringRedisTemplate.convertAndSend(ONE_EVENT_CHANNEL, json);
}

代码示例来源:origin: lcw2004/one

@Override
public SysRoleEO save(SysRoleEO sysRoleEO) {
  sysRoleEO.setId(UUID.randomUUID10());
  sysRoleEO.setDelFlag(DeleteFlagEnum.NORMAL.getValue());
  if (sysRoleEO.getOrderIndex() == null) {
    sysRoleEO.setOrderIndex(dao.getNextSort());
  }
  dao.save(sysRoleEO);
  sysHomeComponentEOService.save(sysRoleEO.getId(), sysRoleEO.getComponentIdList());
  return sysRoleEO;
}

代码示例来源:origin: lcw2004/one

@ApiOperation(value = "验证用户输入的验证码")
@GetMapping(value = "/validVerifyCode")
public ResponseMessage validImageVerifyCode(HttpServletRequest request, HttpServletResponse response, String verifyCode) {
  // 验证用户输入的验证码
  String cookieValue = CookieUtils.getCookieValue(request);
  verifyCodeService.validVerifyCode(cookieValue, VerifyCodeTypeEnum.RESET_PASSWORD, verifyCode);
  // 验证通过清除验证码
  redisUtil.remove(cookieValue + "_" + VerifyCodeTypeEnum.RESET_PASSWORD.getCode());
  // 设置标识表示验证通过了(没什么意义,就是一个标识)
  redisUtil.set(cookieValue + "_" + RESET_PASSWORD_AUTH_CODE, UUID.randomUUID(), GlobalConfig.getRegistryCodeExpireTime());
  return Result.success();
}

代码示例来源:origin: lcw2004/one

@Override
public T save(T t) {
  t.setId(UUID.randomUUID(10));
  t.setDelFlag(DeleteFlagEnum.NORMAL.getValue());
  dao.saveTreeEntity(t);
  return t;
}

代码示例来源:origin: lcw2004/one

@Override
public MsgAnnounceEO save(MsgAnnounceEO entity) {
  entity.setAnnounceId(UUID.randomUUID());
  entity.setCreateTime(new Date());
  entity.setIsTop(0);
  entity.setReadCount(0);
  entity.setStatus(MsgAnnounceStatusEnum.DRAFT.getValue());
  return super.save(entity);
}

代码示例来源:origin: lcw2004/one

public MsgAnnounceEO publish(MsgAnnounceEO entity) {
  if (StringUtils.isNotEmpty(entity.getAnnounceId())) {
    entity.setAnnounceId(UUID.randomUUID());
  }
  entity.setCreateTime(new Date());
  entity.setIsTop(0);
  entity.setReadCount(0);
  entity.setStatus(MsgAnnounceStatusEnum.STARTED.getValue());
  return super.save(entity);
}

代码示例来源:origin: lcw2004/one

private SysLogEO initFromRequest(HttpServletRequest request, ProceedingJoinPoint joinPoint) {
  Map<String, String> headers = RequestUtils.getHeaderMap(request);
  SysLogEO sysLog = new SysLogEO();
  sysLog.setLogId(UUID.randomUUID());
  sysLog.setIsFail(YesOrNoEnum.NO.getValue());
  sysLog.setCreateTime(new Date());
  sysLog.setHttpMethod(request.getMethod());
  sysLog.setHttpUri(StringUtils.limitLength(request.getRequestURI(), 200));
  sysLog.setHttpParamters(StringUtils.limitLength(GsonUtil.t2Json(RequestUtils.getParameterMapSafe(request)), 500));
  sysLog.setHttpUserAgent(StringUtils.limitLength(headers.get("user-agent"), 200));
  sysLog.setHttpRemoteHost(RequestUtils.getClientIp(request));
  sysLog.setUserId(LoginUserUtils.getLoginUserIdNoException(request));
  sysLog.setClassName(joinPoint.getSignature().getDeclaringTypeName());
  sysLog.setMethodName(joinPoint.getSignature().getName());
  ApiOperation apiOperation = AspectHelper.getMethodAnnotation(joinPoint, ApiOperation.class);
  if (apiOperation != null) {
    sysLog.setOperationName(apiOperation.value());
  }
  return sysLog;
}

代码示例来源:origin: lcw2004/one

@Override
public void sendMessage(List<String> userIdList, String templateId, Map<String, Object> placeholderMap) {
  Assert.isTrue(StringUtils.isNotEmpty(templateId), "消息模板编号不能为空");
  MsgTemplateEO msgTemplateEO = msgTemplateEOService.get(templateId);
  Assert.isTrue(msgTemplateEO != null, String.format("消息模板[%s]不存在", templateId));
  MsgMessageEO msgMessageEO = new MsgMessageEO();
  msgMessageEO.setMessageId(UUID.randomUUID());
  msgMessageEO.setContent(MessageUtils.fillMessageTemplate(msgTemplateEO.getContent(), placeholderMap));
  msgMessageEO.setSendTime(new Date());
  msgMessageEO.setTargetType(MessageTargetTypeEnum.TO_USER.getValue());
  msgMessageEO.setTemplateId(msgTemplateEO.getTemplateId());
  msgMessageEO.setTitle(MessageUtils.fillMessageTemplate(msgTemplateEO.getTitle(), placeholderMap));
  // 发送消息
  if (CollectionUtils.isNotEmpty(msgTemplateEO.getChannelIdList())) {
    for (String chanelId : msgTemplateEO.getChannelIdList()) {
      IMessageSender iMessageSender = IMessageSenderFactory.instance(chanelId);
      iMessageSender.send(userIdList, msgMessageEO);
    }
  }
}

代码示例来源:origin: lcw2004/one

@Override
public T saveTreeEntity(T entity) {
  TreeEntity treeEntity = (TreeEntity) entity;
  if (StringUtils.isEmpty(treeEntity.getId())) {
    treeEntity.setId(UUID.randomUUID());
  }
  String oldParentIds = treeEntity.getParentIds();
  TreeEntity parent = treeEntity.getParent();
  if (parent != null) {
    treeEntity.setParentId(parent.getId());
    treeEntity.setParentIds(parent.getParentIds() + parent.getId() + ",");
  }
  if (StringUtils.isNotEmpty(oldParentIds)) {
    List<TreeEntity> treeEntityList = list("from " + entity.getClass().getSimpleName() + " where parent_ids like ?1", "%," + treeEntity.getId() + ",%");
    if (CollectionUtils.isNotEmpty(treeEntityList)) {
      for (TreeEntity childTreeEntity : treeEntityList) {
        childTreeEntity.setParentIds(childTreeEntity.getParentIds().replace(oldParentIds, treeEntity.getParentIds()));
        this.save((T) childTreeEntity);
      }
    }
  }
  return this.save(entity);
}

代码示例来源:origin: lcw2004/one

sysFileEO.setFileId(UUID.randomUUID());
sysFileEO.setFileName(FileUtil.getFileName(fileName));
sysFileEO.setFileType(fileExtension);

代码示例来源:origin: lcw2004/one

public String loginSuccess(LoginUser loginUser) {
  validUser(loginUser);
  // 更新用户的登录时间以及登录IP
  userInfoEOService.updateLoginIp(loginUser.getUserId(), loginUser.getIp());
  userUtilService.fetchOtherInfo(loginUser);
  // 缓存登录用户信息
  String token = UUID.randomUUID();
  LoginUserUtils.set(loginUser.getUserId() + LoginUserUtils.LOGIN_STATE, loginUser.getIp());
  LoginUserUtils.set(token + LoginUserUtils.LOGIN_USER_NEW, loginUser);
  if (loginUser.getUserType() == UserInfoTypeEnum.SUPPLIER.getValue()) {
    LoginUserUtils.set(loginUser.getSupplierId() + LoginUserUtils.LOGIN_STATE, loginUser.getIp());
  }
  return token;
}

相关文章

UUID类方法