Search in sources :

Example 16 with User

use of com.moxi.mogublog.commons.entity.User in project mogu_blog_v2 by moxi624.

the class UserServiceImpl method resetUserPassword.

@Override
public String resetUserPassword(UserVO userVO) {
    String defaultPassword = sysParamsService.getSysParamsValueByKey(SysConf.SYS_DEFAULT_PASSWORD);
    User user = userService.getById(userVO.getUid());
    user.setPassWord(MD5Utils.string2MD5(defaultPassword));
    user.setUpdateTime(new Date());
    user.updateById();
    return ResultUtil.successWithMessage(MessageConf.OPERATION_SUCCESS);
}
Also used : User(com.moxi.mogublog.commons.entity.User)

Example 17 with User

use of com.moxi.mogublog.commons.entity.User in project mogu_blog_v2 by moxi624.

the class UserServiceImpl method getPageList.

@Override
public IPage<User> getPageList(UserVO userVO) {
    QueryWrapper<User> queryWrapper = new QueryWrapper<>();
    // 查询用户名
    if (StringUtils.isNotEmpty(userVO.getKeyword()) && !StringUtils.isEmpty(userVO.getKeyword().trim())) {
        queryWrapper.like(SQLConf.USER_NAME, userVO.getKeyword().trim()).or().like(SQLConf.NICK_NAME, userVO.getKeyword().trim());
    }
    if (StringUtils.isNotEmpty(userVO.getSource()) && !StringUtils.isEmpty(userVO.getSource().trim())) {
        queryWrapper.eq(SQLConf.SOURCE, userVO.getSource().trim());
    }
    if (userVO.getCommentStatus() != null) {
        queryWrapper.eq(SQLConf.COMMENT_STATUS, userVO.getCommentStatus());
    }
    if (StringUtils.isNotEmpty(userVO.getOrderByAscColumn())) {
        // 将驼峰转换成下划线
        String column = StringUtils.underLine(new StringBuffer(userVO.getOrderByAscColumn())).toString();
        queryWrapper.orderByAsc(column);
    } else if (StringUtils.isNotEmpty(userVO.getOrderByDescColumn())) {
        // 将驼峰转换成下划线
        String column = StringUtils.underLine(new StringBuffer(userVO.getOrderByDescColumn())).toString();
        queryWrapper.orderByDesc(column);
    } else {
        queryWrapper.orderByDesc(SQLConf.CREATE_TIME);
    }
    queryWrapper.select(User.class, i -> !i.getProperty().equals(SQLConf.PASS_WORD));
    Page<User> page = new Page<>();
    page.setCurrent(userVO.getCurrentPage());
    page.setSize(userVO.getPageSize());
    queryWrapper.ne(SQLConf.STATUS, EStatus.DISABLED);
    IPage<User> pageList = userService.page(page, queryWrapper);
    List<User> list = pageList.getRecords();
    final StringBuffer fileUids = new StringBuffer();
    list.forEach(item -> {
        if (StringUtils.isNotEmpty(item.getAvatar())) {
            fileUids.append(item.getAvatar() + SysConf.FILE_SEGMENTATION);
        }
    });
    Map<String, String> pictureMap = new HashMap<>();
    String pictureResult = null;
    if (fileUids != null) {
        pictureResult = this.pictureFeignClient.getPicture(fileUids.toString(), SysConf.FILE_SEGMENTATION);
    }
    List<Map<String, Object>> picList = webUtil.getPictureMap(pictureResult);
    picList.forEach(item -> {
        pictureMap.put(item.get(SQLConf.UID).toString(), item.get(SQLConf.URL).toString());
    });
    for (User item : list) {
        // 获取图片
        if (StringUtils.isNotEmpty(item.getAvatar())) {
            List<String> pictureUidsTemp = StringUtils.changeStringToString(item.getAvatar(), SysConf.FILE_SEGMENTATION);
            List<String> pictureListTemp = new ArrayList<>();
            pictureUidsTemp.forEach(picture -> {
                if (pictureMap.get(picture) != null && pictureMap.get(picture) != "") {
                    pictureListTemp.add(pictureMap.get(picture));
                }
            });
            if (pictureListTemp.size() > 0) {
                item.setPhotoUrl(pictureListTemp.get(0));
            }
        }
    }
    pageList.setRecords(list);
    return pageList;
}
Also used : User(com.moxi.mogublog.commons.entity.User) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 18 with User

use of com.moxi.mogublog.commons.entity.User in project mogu_blog_v2 by moxi624.

the class UserServiceImpl method editUser.

@Override
public String editUser(UserVO userVO) {
    User user = userService.getById(userVO.getUid());
    user.setUserName(userVO.getUserName());
    user.setEmail(userVO.getEmail());
    user.setStartEmailNotification(userVO.getStartEmailNotification());
    user.setOccupation(userVO.getOccupation());
    user.setGender(userVO.getGender());
    user.setQqNumber(userVO.getQqNumber());
    user.setSummary(userVO.getSummary());
    user.setBirthday(userVO.getBirthday());
    user.setAvatar(userVO.getAvatar());
    user.setNickName(userVO.getNickName());
    user.setUserTag(userVO.getUserTag());
    user.setCommentStatus(userVO.getCommentStatus());
    user.setUpdateTime(new Date());
    user.updateById();
    return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
Also used : User(com.moxi.mogublog.commons.entity.User)

Aggregations

User (com.moxi.mogublog.commons.entity.User)18 ApiOperation (io.swagger.annotations.ApiOperation)10 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)6 SystemConfig (com.moxi.mogublog.commons.entity.SystemConfig)3 JSONObject (com.alibaba.fastjson.JSONObject)2 IPage (com.baomidou.mybatisplus.core.metadata.IPage)2 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Blog (com.moxi.mogublog.commons.entity.Blog)1 Comment (com.moxi.mogublog.commons.entity.Comment)1 Feedback (com.moxi.mogublog.commons.entity.Feedback)1 Link (com.moxi.mogublog.commons.entity.Link)1 ECommentSource (com.moxi.mougblog.base.enums.ECommentSource)1 DeleteException (com.moxi.mougblog.base.exception.exceptionType.DeleteException)1 InsertException (com.moxi.mougblog.base.exception.exceptionType.InsertException)1 List (java.util.List)1 Map (java.util.Map)1 AuthResponse (me.zhyd.oauth.model.AuthResponse)1