org.springframework.cache.annotation.CachePut Java Examples

The following examples show how to use org.springframework.cache.annotation.CachePut. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DriverServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.DRIVER + Common.Cache.ID, key = "#driver.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.DRIVER + Common.Cache.SERVICE_NAME, key = "#driver.serviceName", condition = "#result!=null"),
                @CachePut(value = Common.Cache.DRIVER + Common.Cache.HOST_PORT, key = "#driver.host+'.'+#driver.port", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.DRIVER + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.DRIVER + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public Driver update(Driver driver) {
    Driver temp = selectById(driver.getId());
    if (null == temp) {
        throw new ServiceException("The driver does not exist");
    }
    driver.setUpdateTime(null);
    if (driverMapper.updateById(driver) > 0) {
        Driver select = driverMapper.selectById(driver.getId());
        driver.setServiceName(select.getServiceName());
        return select;
    }
    throw new ServiceException("The driver update failed");
}
 
Example #2
Source File: GenConfigServiceImpl.java    From sk-admin with Apache License 2.0 6 votes vote down vote up
@Override
@CachePut(key = "#p0")
public GenConfig update(String tableName, GenConfig genConfig) {
    // 如果 api 路径为空,则自动生成路径
    if(StringUtils.isBlank(genConfig.getApiPath())){
        String separator = File.separator;
        String[] paths;
        String symbol = "\\";
        if (symbol.equals(separator)) {
            paths = genConfig.getPath().split("\\\\");
        } else {
            paths = genConfig.getPath().split(File.separator);
        }
        StringBuilder api = new StringBuilder();
        for (String path : paths) {
            api.append(path);
            api.append(separator);
            if ("src".equals(path)) {
                api.append("api");
                break;
            }
        }
        genConfig.setApiPath(api.toString());
    }
    return genConfigDao.save(genConfig);
}
 
Example #3
Source File: PointAttributeServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.POINT_ATTRIBUTE + Common.Cache.ID, key = "#pointAttribute.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.POINT_ATTRIBUTE + Common.Cache.NAME, key = "#pointAttribute.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.POINT_ATTRIBUTE + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.POINT_ATTRIBUTE + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public PointAttribute update(PointAttribute pointAttribute) {
    PointAttribute temp = selectById(pointAttribute.getId());
    if (null == temp) {
        throw new ServiceException("The point attribute does not exist");
    }
    pointAttribute.setUpdateTime(null);
    if (pointAttributeMapper.updateById(pointAttribute) > 0) {
        PointAttribute select = pointAttributeMapper.selectById(pointAttribute.getId());
        pointAttribute.setName(select.getName());
        return select;
    }
    throw new ServiceException("The point attribute update failed");
}
 
Example #4
Source File: DriverInfoServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.DRIVER_INFO + Common.Cache.ID, key = "#driverInfo.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.DRIVER_INFO + Common.Cache.DRIVER_INFO_ID, key = "#driverInfo.driverAttributeId+'.'+#driverInfo.profileId", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.DRIVER_INFO + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.DRIVER_INFO + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public DriverInfo add(DriverInfo driverInfo) {
    DriverInfo select = selectByDriverAttributeId(driverInfo.getDriverAttributeId(), driverInfo.getProfileId());
    Optional.ofNullable(select).ifPresent(d -> {
        throw new ServiceException("The driver info already exists in the profile");
    });
    if (driverInfoMapper.insert(driverInfo) > 0) {
        return driverInfoMapper.selectById(driverInfo.getId());
    }
    throw new ServiceException("The driver info add failed");
}
 
Example #5
Source File: PostServiceImpl.java    From blog-sharon with Apache License 2.0 6 votes vote down vote up
/**
 * 当前文章的相似文章
 *
 * @param post post
 * @return List
 */
@Override
@CachePut(value = POSTS_CACHE_NAME, key = "'posts_related_'+#post.getPostId()")
public List<Post> relatedPosts(Post post) {
    //获取当前文章的所有标签
    List<Tag> tags = post.getTags();
    List<Post> tempPosts = new ArrayList<>();
    for (Tag tag : tags) {
        tempPosts.addAll(postRepository.findPostsByTags(tag));
    }
    //去掉当前的文章
    tempPosts.remove(post);
    //去掉重复的文章
    List<Post> allPosts = new ArrayList<>();
    for (int i = 0; i < tempPosts.size(); i++) {
        if (!allPosts.contains(tempPosts.get(i))) {
            allPosts.add(tempPosts.get(i));
        }
    }
    return allPosts;
}
 
Example #6
Source File: DeviceServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.DEVICE + Common.Cache.ID, key = "#device.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.DEVICE + Common.Cache.GROUP_NAME, key = "#device.groupId+'.'+#device.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.DEVICE + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.DEVICE + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public Device update(Device device) {
    Device temp = selectById(device.getId());
    if (null == temp) {
        throw new ServiceException("The device does not exist");
    }
    device.setUpdateTime(null);
    if (deviceMapper.updateById(device) > 0) {
        Device select = deviceMapper.selectById(device.getId());
        device.setGroupId(select.getGroupId()).setName(select.getName());
        return select;
    }
    throw new ServiceException("The device update failed");
}
 
Example #7
Source File: LabelServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.LABEL + Common.Cache.ID, key = "#label.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.LABEL + Common.Cache.NAME, key = "#label.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.LABEL + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.LABEL + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public Label update(Label label) {
    Label temp = selectById(label.getId());
    if (null == temp) {
        throw new ServiceException("The label does not exist");
    }
    label.setUpdateTime(null);
    if (labelMapper.updateById(label) > 0) {
        Label select = labelMapper.selectById(label.getId());
        label.setName(select.getName());
        return select;
    }
    throw new ServiceException("The label update failed");
}
 
Example #8
Source File: UserServiceImpl.java    From mysiteforme with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(put = {
		@CachePut(value = "user", key = "'user_id_'+T(String).valueOf(#result.id)",condition = "#result.id != null and #result.id != 0"),
		@CachePut(value = "user", key = "'user_name_'+#user.loginName", condition = "#user.loginName !=null and #user.loginName != ''"),
		@CachePut(value = "user", key = "'user_email_'+#user.email", condition = "#user.email != null and #user.email != ''"),
		@CachePut(value = "user", key = "'user_tel_'+#user.tel", condition = "#user.tel != null and #user.tel != ''")
})
@Transactional(readOnly = false, rollbackFor = Exception.class)
public User saveUser(User user) {
	ToolUtil.entryptPassword(user);
	user.setLocked(false);
	baseMapper.insert(user);
	//保存用户角色关系
	this.saveUserRoles(user.getId(),user.getRoleLists());
	return findUserById(user.getId());
}
 
Example #9
Source File: LabelBindServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {@CachePut(value = Common.Cache.LABEL_BIND + Common.Cache.ID, key = "#labelBind.id", condition = "#result!=null")},
        evict = {
                @CacheEvict(value = Common.Cache.LABEL_BIND + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.LABEL_BIND + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public LabelBind update(LabelBind labelBind) {
    LabelBind temp = selectById(labelBind.getId());
    if (null == temp) {
        throw new ServiceException("The label bind does not exist");
    }
    labelBind.setUpdateTime(null);
    if (labelBindMapper.updateById(labelBind) > 0) {
        return labelBindMapper.selectById(labelBind.getId());
    }
    throw new ServiceException("The label bind update failed");
}
 
Example #10
Source File: ProfileServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.PROFILE + Common.Cache.ID, key = "#profile.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.PROFILE + Common.Cache.NAME, key = "#profile.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.PROFILE + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.PROFILE + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public Profile add(Profile profile) {
    Driver driver = driverService.selectById(profile.getDriverId());
    if (null == driver) {
        throw new ServiceException("The driver does not exist");
    }
    Profile select = selectByName(profile.getName());
    if (null != select) {
        throw new ServiceException("The profile already exists");
    }
    if (profileMapper.insert(profile) > 0) {
        return profileMapper.selectById(profile.getId());
    }
    throw new ServiceException("The profile add failed");
}
 
Example #11
Source File: PostServiceImpl.java    From stone with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 当前文章的相似文章
 *
 * @param post post
 * @return List
 */
@Override
@CachePut(value = POSTS_CACHE_NAME, key = "'posts_related_'+#post.getPostId()")
public List<Post> relatedPosts(Post post) {
    //获取当前文章的所有标签
    final List<Tag> tags = post.getTags();
    final List<Post> tempPosts = new ArrayList<>();
    for (Tag tag : tags) {
        tempPosts.addAll(postRepository.findPostsByTags(tag));
    }
    //去掉当前的文章
    tempPosts.remove(post);
    //去掉重复的文章
    final List<Post> allPosts = new ArrayList<>();
    for (int i = 0; i < tempPosts.size(); i++) {
        if (!allPosts.contains(tempPosts.get(i))) {
            allPosts.add(tempPosts.get(i));
        }
    }
    return allPosts;
}
 
Example #12
Source File: UserServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.USER + Common.Cache.ID, key = "#user.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.USER + Common.Cache.NAME, key = "#user.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.USER + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.USER + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public User update(User user) {
    user.setName(null).setUpdateTime(null);
    if (userMapper.updateById(user) > 0) {
        User select = userMapper.selectById(user.getId());
        user.setName(select.getName());
        return select;
    }
    throw new ServiceException("The user update failed");
}
 
Example #13
Source File: GroupServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.GROUP + Common.Cache.ID, key = "#group.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.GROUP + Common.Cache.NAME, key = "#group.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.GROUP + Common.Cache.DIC, allEntries = true, condition = "#result==true"),
                @CacheEvict(value = Common.Cache.GROUP + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public Group update(Group group) {
    Group temp = selectById(group.getId());
    if (null == temp) {
        throw new ServiceException("The group does not exist");
    }
    group.setUpdateTime(null);
    if (groupMapper.updateById(group) > 0) {
        Group select = groupMapper.selectById(group.getId());
        group.setName(select.getName());
        return select;
    }
    throw new ServiceException("The group update failed");
}
 
Example #14
Source File: RtmpServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.RTMP + Common.Cache.ID, key = "#rtmp.id", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.RTMP + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.RTMP + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public Rtmp add(Rtmp rtmp) {
    if (rtmpMapper.insert(rtmp) > 0) {
        Transcode transcode = new Transcode(rtmp);
        if (!transcodeMap.containsKey(transcode.getId())) {
            transcodeMap.put(transcode.getId(), transcode);
        }
        return selectById(rtmp.getId());
    }
    throw new ServiceException("The rtmp task add failed");
}
 
Example #15
Source File: LabelServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.LABEL + Common.Cache.ID, key = "#label.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.LABEL + Common.Cache.NAME, key = "#label.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.LABEL + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.LABEL + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public Label add(Label label) {
    Label select = selectByName(label.getName());
    Optional.ofNullable(select).ifPresent(l -> {
        throw new ServiceException("The label already exists");
    });
    if (labelMapper.insert(label) > 0) {
        return labelMapper.selectById(label.getId());
    }
    throw new ServiceException("The label add failed");
}
 
Example #16
Source File: DatabaseCachableClientDetailsService.java    From cola-cloud with MIT License 6 votes vote down vote up
@Transactional(rollbackFor = Exception.class)
@CachePut(value = OAUTH_CLINET_DETAILS_CACHE, key = "#clientDetails.clientId")
public ClientDetails updateCachedClientDetail(ClientDetails clientDetails) throws NoSuchClientException {
    Optional<Client> clientOptional = Optional.of(this.clientService.findOneByColumn("client_id", clientDetails.getClientId()));
    clientOptional.orElseThrow(() -> new NoSuchClientException("Client ID not found"));

    Client client = Client.builder()
            .clientId(clientDetails.getClientId())
            .clientSecret(clientDetails.getClientSecret())
            .accessTokenValiditySeconds(clientDetails.getAccessTokenValiditySeconds())
            .refreshTokenValiditySeconds(clientDetails.getRefreshTokenValiditySeconds()).build();
    client.setId(clientOptional.get().getId());

    client.setGrantType(clientDetails.getAuthorizedGrantTypes().stream().collect(Collectors.joining(",")));
    client.setRedirectUri(clientDetails.getRegisteredRedirectUri().stream().collect(Collectors.joining(",")));
    clientService.insert(client);

    EntityWrapper<Scope> wrapper = new EntityWrapper<>();
    wrapper.eq("client_id", clientOptional.get().getId());
    scopeService.delete(wrapper);

    List<Scope> clientScopes = clientDetails.getScope().stream().map(scope ->
            Scope.builder().clientId(client.getId()).autoApprove(false).scope(scope).build()).collect(Collectors.toList());
    this.scopeService.insertBatch(clientScopes);
    return clientDetails;
}
 
Example #17
Source File: DriverAttributeServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.DRIVER_ATTRIBUTE + Common.Cache.ID, key = "#driverAttribute.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.DRIVER_ATTRIBUTE + Common.Cache.NAME, key = "#driverAttribute.name", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.DRIVER_ATTRIBUTE + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.DRIVER_ATTRIBUTE + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public DriverAttribute update(DriverAttribute driverAttribute) {
    DriverAttribute temp = selectById(driverAttribute.getId());
    if (null == temp) {
        throw new ServiceException("The driver attribute does not exist");
    }
    driverAttribute.setUpdateTime(null);
    if (driverAttributeMapper.updateById(driverAttribute) > 0) {
        DriverAttribute select = driverAttributeMapper.selectById(driverAttribute.getId());
        driverAttribute.setName(select.getName());
        return select;
    }
    throw new ServiceException("The driver attribute update failed");
}
 
Example #18
Source File: BlackIpServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
@Caching(
        put = {
                @CachePut(value = Common.Cache.BLACK_IP + Common.Cache.ID, key = "#blackIp.id", condition = "#result!=null"),
                @CachePut(value = Common.Cache.BLACK_IP + Common.Cache.IP, key = "#blackIp.ip", condition = "#result!=null")
        },
        evict = {
                @CacheEvict(value = Common.Cache.BLACK_IP + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public BlackIp add(BlackIp blackIp) {
    BlackIp select = selectByIp(blackIp.getIp());
    Optional.ofNullable(select).ifPresent(ip -> {
        throw new ServiceException("The ip already exists in the blacklist");
    });
    if (blackIpMapper.insert(blackIp) > 0) {
        return blackIpMapper.selectById(blackIp.getId());
    }
    throw new ServiceException("The ip add to the blacklist failed");
}
 
Example #19
Source File: LabelBindServiceImpl.java    From iot-dc3 with Apache License 2.0 5 votes vote down vote up
@Override
@Caching(
        put = {@CachePut(value = Common.Cache.LABEL_BIND + Common.Cache.ID, key = "#labelBind.id", condition = "#result!=null")},
        evict = {
                @CacheEvict(value = Common.Cache.LABEL_BIND + Common.Cache.DIC, allEntries = true, condition = "#result!=null"),
                @CacheEvict(value = Common.Cache.LABEL_BIND + Common.Cache.LIST, allEntries = true, condition = "#result!=null")
        }
)
public LabelBind add(LabelBind labelBind) {
    if (labelBindMapper.insert(labelBind) > 0) {
        return labelBindMapper.selectById(labelBind.getId());
    }
    throw new ServiceException("The label bind add failed");
}
 
Example #20
Source File: QiNiuServiceImpl.java    From sk-admin with Apache License 2.0 5 votes vote down vote up
@Override
@CachePut(cacheNames = "qiNiuConfig", key = "'1'")
@Transactional(rollbackFor = Exception.class)
public QiniuConfig update(QiniuConfig qiniuConfig) {
    String http = "http://", https = "https://";
    if (!(qiniuConfig.getHost().toLowerCase().startsWith(http) || qiniuConfig.getHost().toLowerCase().startsWith(https))) {
        throw new SkException("外链域名必须以http://或者https://开头");
    }
    qiniuConfig.setId(1L);
    return qiNiuConfigDao.save(qiniuConfig);
}
 
Example #21
Source File: QiNiuServiceImpl.java    From eladmin with Apache License 2.0 5 votes vote down vote up
@Override
@CachePut(key = "'config'")
@Transactional(rollbackFor = Exception.class)
public QiniuConfig config(QiniuConfig qiniuConfig) {
    qiniuConfig.setId(1L);
    String http = "http://", https = "https://";
    if (!(qiniuConfig.getHost().toLowerCase().startsWith(http)||qiniuConfig.getHost().toLowerCase().startsWith(https))) {
        throw new BadRequestException("外链域名必须以http://或者https://开头");
    }
    return qiNiuConfigRepository.save(qiniuConfig);
}
 
Example #22
Source File: RoleServiceImpl.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Caching(
        put = {@CachePut(value = "role",key = "'role_id_'+T(String).valueOf(#result.id)",condition = "#result.id != null and #result.id != 0")},
        evict = {@CacheEvict(value = "roleAll",key = "'roleAll'" )
})
@Transactional(readOnly = false, rollbackFor = Exception.class)
@Override
public Role saveRole(Role role) {
    baseMapper.insert(role);
    baseMapper.saveRoleMenus(role.getId(),role.getMenuSet());
    return role;
}
 
Example #23
Source File: StudentService.java    From sfg-blog-posts with GNU General Public License v3.0 5 votes vote down vote up
@CachePut(key = "#result.id")
public Student create(String firstName, String lastName, String courseOfStudies) {
  LOG.info("Creating student with firstName={}, lastName={} and courseOfStudies={}", firstName, lastName, courseOfStudies);
  long newId = ID_CREATOR.incrementAndGet();
  Student newStudent = new Student(newId, firstName, lastName, courseOfStudies);
  students.put(newId, newStudent);

  return newStudent;
}
 
Example #24
Source File: BaseAppServiceImpl.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 添加应用
 *
 * @param app
 * @return 应用信息
 */
@CachePut(value = "apps", key = "#app.appId")
@Override
public BaseApp addAppInfo(BaseApp app) {
    String appId = String.valueOf(System.currentTimeMillis());
    String apiKey = RandomValueUtils.randomAlphanumeric(24);
    String secretKey = RandomValueUtils.randomAlphanumeric(32);
    app.setAppId(appId);
    app.setApiKey(apiKey);
    app.setSecretKey(secretKey);
    app.setCreateTime(new Date());
    app.setUpdateTime(app.getCreateTime());
    if (app.getIsPersist() == null) {
        app.setIsPersist(0);
    }
    baseAppMapper.insert(app);
    Map info = BeanConvertUtils.objectToMap(app);
    // 功能授权
    BaseClientDetails client = new BaseClientDetails();
    client.setClientId(app.getApiKey());
    client.setClientSecret(app.getSecretKey());
    client.setAdditionalInformation(info);
    client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "client_credentials", "implicit", "refresh_token"));
    client.setAccessTokenValiditySeconds(ACCESS_TOKEN_VALIDITY_SECONDS);
    client.setRefreshTokenValiditySeconds(REFRESH_TOKEN_VALIDITY_SECONDS);
    jdbcClientDetailsService.addClientDetails(client);
    return app;
}
 
Example #25
Source File: UserServiceImpl.java    From spring-boot-study with MIT License 5 votes vote down vote up
@Override
@CachePut(value = "fpcache",key = "#user.id")
public UserDO save(UserDO user) {
    System.out.println("保存用户使用 @CachePut 每次都会执行语句并缓存 save user by "+user.getUserName());
    return user;

}
 
Example #26
Source File: UserServiceImpl.java    From spring-boot-study with MIT License 5 votes vote down vote up
@Override
@CachePut(value = "fpcache",key = "#user.id")
public UserDO save(UserDO user) {
    System.out.println("保存用户使用 @CachePut 每次都会执行语句并缓存 save user by "+user.getUserName());
    return user;

}
 
Example #27
Source File: CachedProductFamilyService.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Save a containers details using a service's metadata
 *
 * @param productFamilyId the product family id of the container
 * @param instanceInfo    the service instance
 */
@CachePut(key = "#productFamilyId")
public APIContainer saveContainerFromInstance(String productFamilyId, InstanceInfo instanceInfo) {
    APIContainer container = products.get(productFamilyId);
    if (container == null) {
        container = createNewContainerFromService(productFamilyId, instanceInfo);
    } else {
        Set<APIService> apiServices = container.getServices();
        APIService service = createAPIServiceFromInstance(instanceInfo);
        apiServices.remove(service);

        apiServices.add(service);
        container.setServices(apiServices);
        //update container
        String versionFromInstance = instanceInfo.getMetadata().get(CATALOG_VERSION);
        String title = instanceInfo.getMetadata().get(CATALOG_TITLE);
        String description = instanceInfo.getMetadata().get(CATALOG_DESCRIPTION);

        container.setVersion(versionFromInstance);
        container.setTitle(title);
        container.setDescription(description);
        container.updateLastUpdatedTimestamp();

        products.put(productFamilyId, container);
    }

    return container;
}
 
Example #28
Source File: UserServiceImpl.java    From spring-boot-demo with MIT License 5 votes vote down vote up
/**
 * 保存或修改用户
 *
 * @param user 用户对象
 * @return 操作结果
 */
@CachePut(value = "user", key = "#user.id")
@Override
public User saveOrUpdate(User user) {
    DATABASES.put(user.getId(), user);
    log.info("保存用户【user】= {}", user);
    return user;
}
 
Example #29
Source File: UserServiceImpl.java    From spring-boot-examples with Apache License 2.0 5 votes vote down vote up
@Override
@CachePut(value = "user", key = "#user.id", condition = "#user.id != null")
public User save(User user) {
    user.setUpdateTime(new Date());
    userDAO.save(user);
    return userDAO.findById(user.getId());
}
 
Example #30
Source File: AliPayServiceImpl.java    From eladmin with Apache License 2.0 5 votes vote down vote up
@Override
@CachePut(key = "'config'")
@Transactional(rollbackFor = Exception.class)
public AlipayConfig config(AlipayConfig alipayConfig) {
    alipayConfig.setId(1L);
    return alipayRepository.save(alipayConfig);
}