Search in sources :

Example 1 with SocialConfig

use of com.zyd.blog.business.entity.SocialConfig in project OneBlog by zhangyd-c.

the class SysSocialConfigServiceImpl method getByPlatform.

@Override
public SocialConfig getByPlatform(String platform) {
    if (StringUtil.isEmpty(platform)) {
        return null;
    }
    Example example = new Example(SysSocialConfig.class);
    Example.Criteria criteria = example.createCriteria();
    criteria.andEqualTo("platform", platform.toLowerCase());
    SysSocialConfig sysSocialConfig = sysSocialConfigMapper.selectOneByExample(example);
    if (null == sysSocialConfig) {
        return null;
    }
    return new SocialConfig(sysSocialConfig);
}
Also used : Example(tk.mybatis.mapper.entity.Example) SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig) SocialConfig(com.zyd.blog.business.entity.SocialConfig) SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig)

Example 2 with SocialConfig

use of com.zyd.blog.business.entity.SocialConfig in project OneBlog by zhangyd-c.

the class OAuthController method renderAuth.

@RequestMapping("/social/{source}")
public ModelAndView renderAuth(@PathVariable("source") String source, HttpServletResponse response, HttpServletRequest request) {
    SocialConfig socialConfig = sysSocialConfigService.getByPlatform(source);
    if (null == socialConfig) {
        throw new ZhydException(source + " 平台的配置尚未完成,暂时不支持登录!");
    }
    SocialStrategy socialStrategy = new SocialStrategy(japUserService, new JapConfig());
    JapResponse japResponse = socialStrategy.authenticate(JapUtil.blogSocialConfig2JapSocialConfig(socialConfig, source), request, response);
    if (!japResponse.isSuccess()) {
        throw new ZhydException(japResponse.getMessage());
    }
    if (japResponse.isRedirectUrl()) {
        return ResultUtil.redirect((String) japResponse.getData());
    } else {
        JapUser japUser = (JapUser) japResponse.getData();
        User user = (User) japUser.getAdditional();
        SessionUtil.setUser(user);
        return ResultUtil.redirect("/");
    }
}
Also used : ZhydException(com.zyd.blog.framework.exception.ZhydException) JapUser(com.fujieid.jap.core.JapUser) JapConfig(com.fujieid.jap.core.config.JapConfig) User(com.zyd.blog.business.entity.User) JapUser(com.fujieid.jap.core.JapUser) SocialStrategy(com.fujieid.jap.social.SocialStrategy) JapResponse(com.fujieid.jap.core.result.JapResponse) SocialConfig(com.zyd.blog.business.entity.SocialConfig) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with SocialConfig

use of com.zyd.blog.business.entity.SocialConfig in project OneBlog by zhangyd-c.

the class SysSocialConfigServiceImpl method getByPrimaryKey.

@Override
public SocialConfig getByPrimaryKey(Long primaryKey) {
    Assert.notNull(primaryKey, "This argument is required; it must not be null");
    SysSocialConfig entity = sysSocialConfigMapper.selectByPrimaryKey(primaryKey);
    return null == entity ? null : new SocialConfig(entity);
}
Also used : SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig) SocialConfig(com.zyd.blog.business.entity.SocialConfig) SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig)

Example 4 with SocialConfig

use of com.zyd.blog.business.entity.SocialConfig in project OneBlog by zhangyd-c.

the class SysSocialConfigServiceImpl method getByClientId.

@Override
public SocialConfig getByClientId(String clientId) {
    Assert.notNull(clientId, "This argument is required; it must not be null");
    SysSocialConfig entity = sysSocialConfigMapper.getByClientId(clientId);
    return null == entity ? null : new SocialConfig(entity);
}
Also used : SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig) SocialConfig(com.zyd.blog.business.entity.SocialConfig) SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig)

Example 5 with SocialConfig

use of com.zyd.blog.business.entity.SocialConfig in project OneBlog by zhangyd-c.

the class SysSocialConfigServiceImpl method findPageBreakByCondition.

@Override
public PageInfo<SocialConfig> findPageBreakByCondition(SocialConfigConditionVO vo) {
    PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
    List<SysSocialConfig> list = sysSocialConfigMapper.findPageBreakByCondition(vo);
    if (CollectionUtils.isEmpty(list)) {
        return null;
    }
    PageInfo bean = new PageInfo<SysSocialConfig>(list);
    bean.setList(list.stream().map(SocialConfig::new).collect(Collectors.toList()));
    return bean;
}
Also used : PageInfo(com.github.pagehelper.PageInfo) SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig) SocialConfig(com.zyd.blog.business.entity.SocialConfig) SysSocialConfig(com.zyd.blog.persistence.beans.SysSocialConfig)

Aggregations

SocialConfig (com.zyd.blog.business.entity.SocialConfig)5 SysSocialConfig (com.zyd.blog.persistence.beans.SysSocialConfig)4 JapUser (com.fujieid.jap.core.JapUser)1 JapConfig (com.fujieid.jap.core.config.JapConfig)1 JapResponse (com.fujieid.jap.core.result.JapResponse)1 SocialStrategy (com.fujieid.jap.social.SocialStrategy)1 PageInfo (com.github.pagehelper.PageInfo)1 User (com.zyd.blog.business.entity.User)1 ZhydException (com.zyd.blog.framework.exception.ZhydException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 Example (tk.mybatis.mapper.entity.Example)1