Search in sources :

Example 1 with SysUser

use of com.zyd.blog.persistence.beans.SysUser in project OneBlog by zhangyd-c.

the class SysUserServiceImpl method listByRoleId.

/**
 * 通过角色Id获取用户列表
 *
 * @param roleId
 * @return
 */
@Override
public List<User> listByRoleId(Long roleId) {
    List<SysUser> sysUsers = sysUserMapper.listByRoleId(roleId);
    if (CollectionUtils.isEmpty(sysUsers)) {
        return null;
    }
    List<User> users = new ArrayList<>();
    for (SysUser su : sysUsers) {
        su.setUserType(new User(su).getUserTypeDescEnum().toString());
        users.add(new User(su));
    }
    return users;
}
Also used : SysUser(com.zyd.blog.persistence.beans.SysUser) User(com.zyd.blog.business.entity.User) SysUser(com.zyd.blog.persistence.beans.SysUser) ArrayList(java.util.ArrayList)

Example 2 with SysUser

use of com.zyd.blog.persistence.beans.SysUser in project OneBlog by zhangyd-c.

the class SysUserServiceImpl method listAll.

@Override
public List<User> listAll() {
    List<SysUser> sysUsers = sysUserMapper.selectAll();
    if (CollectionUtils.isEmpty(sysUsers)) {
        return null;
    }
    List<User> users = new ArrayList<>();
    for (SysUser sysUser : sysUsers) {
        users.add(new User(sysUser));
    }
    return users;
}
Also used : SysUser(com.zyd.blog.persistence.beans.SysUser) User(com.zyd.blog.business.entity.User) SysUser(com.zyd.blog.persistence.beans.SysUser) ArrayList(java.util.ArrayList)

Example 3 with SysUser

use of com.zyd.blog.persistence.beans.SysUser in project OneBlog by zhangyd-c.

the class SysUserServiceImpl method insertList.

@Override
@Transactional(rollbackFor = Exception.class)
public void insertList(List<User> users) {
    Assert.notNull(users, "Users不可为空!");
    List<SysUser> sysUsers = new ArrayList<>();
    String regIp = IpUtil.getRealIp(RequestHolder.getRequest());
    for (User user : users) {
        user.setUpdateTime(new Date());
        user.setCreateTime(new Date());
        user.setRegIp(regIp);
        user.setPrivacy(UserPrivacyEnum.PUBLIC.getCode());
        user.setNotification(UserNotificationEnum.DETAIL);
        sysUsers.add(user.getSysUser());
    }
    sysUserMapper.insertList(sysUsers);
}
Also used : SysUser(com.zyd.blog.persistence.beans.SysUser) User(com.zyd.blog.business.entity.User) SysUser(com.zyd.blog.persistence.beans.SysUser) ArrayList(java.util.ArrayList) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with SysUser

use of com.zyd.blog.persistence.beans.SysUser in project OneBlog by zhangyd-c.

the class SysUserServiceImpl method getByPrimaryKey.

@Override
public User getByPrimaryKey(Long primaryKey) {
    Assert.notNull(primaryKey, "PrimaryKey不可为空!");
    SysUser sysUser = sysUserMapper.selectByPrimaryKey(primaryKey);
    return null == sysUser ? null : new User(sysUser);
}
Also used : SysUser(com.zyd.blog.persistence.beans.SysUser) User(com.zyd.blog.business.entity.User) SysUser(com.zyd.blog.persistence.beans.SysUser)

Example 5 with SysUser

use of com.zyd.blog.persistence.beans.SysUser in project OneBlog by zhangyd-c.

the class SysUserServiceImpl method getByUuidAndSource.

@Override
public User getByUuidAndSource(String uuid, String source) {
    if (StringUtils.isEmpty(uuid) || StringUtils.isEmpty(source)) {
        return null;
    }
    SysUser user = new SysUser();
    user.setUuid(uuid);
    user.setSource(source);
    user = sysUserMapper.selectOne(user);
    return null == user ? null : new User(user);
}
Also used : SysUser(com.zyd.blog.persistence.beans.SysUser) User(com.zyd.blog.business.entity.User) SysUser(com.zyd.blog.persistence.beans.SysUser)

Aggregations

User (com.zyd.blog.business.entity.User)7 SysUser (com.zyd.blog.persistence.beans.SysUser)7 ArrayList (java.util.ArrayList)4 PageInfo (com.github.pagehelper.PageInfo)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1