@Override public void updateUserOrganization(String userId, String oldOrgId, String newOrgId) { if (oldOrgId == null) { oldOrgId = ""; } UserOrganizationCriteria userOrganizationCriteria = new UserOrganizationCriteria(); userOrganizationCriteria .createCriteria() .andUserIdEqualTo(userId) .andOrganizationIdEqualTo(oldOrgId); List<UserOrganization> userOrganizations = userOrganizationMapper.selectByExample(userOrganizationCriteria); if (null != userOrganizations && userOrganizations.size() > 0) { UserOrganization userOrganization = userOrganizations.get(0); if (null != newOrgId) { userOrganization.setOrganizationId(newOrgId); userOrganizationMapper.updateByPrimaryKey(userOrganization); } else { userOrganizationMapper.deleteByPrimaryKey(userOrganization.getId()); } } else { // 新增 if ((null == oldOrgId || "".equals(oldOrgId)) && null != newOrgId) { UserOrganization userOrganization = new UserOrganization(); userOrganization.setId(new Date().getTime() + ""); userOrganization.setUserId(userId); userOrganization.setOrganizationId(newOrgId); userOrganizationMapper.insert(userOrganization); } } }
@Override public void connectUserOrganization(String userId, String roleId) { UserOrganization record = new UserOrganization(); record.setId(new Date().getTime() + ""); record.setUserId(userId); record.setOrganizationId(roleId); userOrganizationMapper.insert(record); }