Search in sources :

Example 1 with UserFans

use of com.ch999.haha.admin.entity.UserFans in project haha by hahafreeasair666.

the class UserFansServiceImpl method followOrCancel.

@Override
public Boolean followOrCancel(Integer userId1, Integer userId2, Boolean isFollow) {
    if (userInfoService.selectById(userId2) == null) {
        return null;
    }
    Wrapper<UserFans> wrapper = new EntityWrapper<>();
    wrapper.eq("userid1", userId1).eq("userid2", userId2);
    List<UserFans> userFans = this.selectList(wrapper);
    if (isFollow == null || isFollow) {
        if (CollectionUtils.isNotEmpty(userFans)) {
            return false;
        }
        UserFans newUserFans = new UserFans(userId1, userId2);
        return this.insert(newUserFans);
    } else {
        if (CollectionUtils.isEmpty(userFans)) {
            return false;
        }
        UserFans userFans1 = userFans.get(0);
        return this.deleteById(userFans1.getId());
    }
}
Also used : EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) UserFans(com.ch999.haha.admin.entity.UserFans)

Example 2 with UserFans

use of com.ch999.haha.admin.entity.UserFans in project haha by hahafreeasair666.

the class UserInfoServiceImpl method getUserCenterInfo.

@Override
public OtherCenterVO getUserCenterInfo(Integer userId, Integer loginUserId) {
    OtherCenterVO userCenterVO = new OtherCenterVO();
    UserCenterInfoCountVO userInfoCount = getUserInfoCount(userId);
    userCenterVO.setUserId(userId);
    userCenterVO.setFollows(userInfoCount.getFollow());
    userCenterVO.setFans(userInfoCount.getFans());
    UserInfoBO one = userInfoBORepository.findOne(userId);
    if (one == null) {
        return null;
    }
    userCenterVO.setAvatar(one.getUserInfo().getPicPath());
    userCenterVO.setDescription(one.getUserInfo().getAutograph());
    userCenterVO.setMyCredit(one.getCreditInfo().get("creditNum") != null ? (int) one.getCreditInfo().get("creditNum") : 0);
    userCenterVO.setUserName(one.getUserInfo().getUsername());
    // 组装是否已关注信息
    if (loginUserId != null) {
        Wrapper<UserFans> wrapper = new EntityWrapper<>();
        wrapper.eq("userid1", loginUserId);
        wrapper.eq("userid2", userId);
        if (userFansService.selectCount(wrapper) == 0 && !userId.equals(loginUserId)) {
            userCenterVO.setIsCanFollow(true);
        } else {
            userCenterVO.setIsCanFollow(false);
        }
    } else {
        userCenterVO.setIsCanFollow(true);
    }
    return userCenterVO;
}
Also used : UserCenterInfoCountVO(com.ch999.haha.admin.vo.mappervo.UserCenterInfoCountVO) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) UserFans(com.ch999.haha.admin.entity.UserFans) OtherCenterVO(com.ch999.haha.admin.vo.OtherCenterVO) UserInfoBO(com.ch999.haha.admin.document.redis.UserInfoBO)

Aggregations

EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)2 UserFans (com.ch999.haha.admin.entity.UserFans)2 UserInfoBO (com.ch999.haha.admin.document.redis.UserInfoBO)1 OtherCenterVO (com.ch999.haha.admin.vo.OtherCenterVO)1 UserCenterInfoCountVO (com.ch999.haha.admin.vo.mappervo.UserCenterInfoCountVO)1