Search in sources :

Example 11 with UserInfoBO

use of com.ch999.haha.admin.document.redis.UserInfoBO in project haha by hahafreeasair666.

the class UserComponent method userRegister.

/**
 * 用户注册
 * @param registerVO
 * @return
 */
public Integer userRegister(RegisterVO registerVO) {
    if (!registerVO.getPwd1().equals(registerVO.getPwd2())) {
        return null;
    }
    UserInfo userInfo = new UserInfo();
    userInfo.setUsername(registerVO.getUserName());
    userInfo.setMobile(registerVO.getMobile());
    userInfo.setPwd(registerVO.getPwd1());
    userInfoService.insert(userInfo);
    // 注册的时候就给用户一个初始信用积分
    UserInfoBO userInfoBO = new UserInfoBO(userInfo.getId(), userInfo);
    userInfoBORepository.save(userInfoBO);
    return userInfo.getId();
}
Also used : UserInfo(com.ch999.haha.admin.entity.UserInfo) UserInfoBO(com.ch999.haha.admin.document.redis.UserInfoBO)

Example 12 with UserInfoBO

use of com.ch999.haha.admin.document.redis.UserInfoBO in project haha by hahafreeasair666.

the class UserComponent method getLoginUser.

/**
 * 获取当前用户信息
 *
 * @return
 */
public UserInfoBO getLoginUser() {
    Integer userId = getUserId();
    if (userId == -1) {
        return new UserInfoBO();
    } else {
        UserInfoBO one = userInfoBORepository.findOne(userId);
        if (one == null) {
            UserInfo userInfo = userInfoService.selectById(userId);
            UserInfoBO userInfoBO = new UserInfoBO(userId, userInfo);
            userInfoBORepository.save(userInfoBO);
            return userInfo != null ? userInfoBO : new UserInfoBO();
        } else {
            return one;
        }
    }
}
Also used : UserInfo(com.ch999.haha.admin.entity.UserInfo) UserInfoBO(com.ch999.haha.admin.document.redis.UserInfoBO)

Example 13 with UserInfoBO

use of com.ch999.haha.admin.document.redis.UserInfoBO 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

UserInfoBO (com.ch999.haha.admin.document.redis.UserInfoBO)12 UserInfo (com.ch999.haha.admin.entity.UserInfo)4 UserCenterInfoCountVO (com.ch999.haha.admin.vo.mappervo.UserCenterInfoCountVO)2 EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)1 Imgs (com.ch999.haha.admin.entity.Imgs)1 UserFans (com.ch999.haha.admin.entity.UserFans)1 MyCenterVO (com.ch999.haha.admin.vo.MyCenterVO)1 OtherCenterVO (com.ch999.haha.admin.vo.OtherCenterVO)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1