|
|
@ -5,14 +5,18 @@ import cn.dev33.satoken.stp.StpUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.jiagutech.common.UserConstants; |
|
|
|
import com.jiagutech.common.exception.BizCode; |
|
|
|
import com.jiagutech.common.exception.BusinessException; |
|
|
|
import com.jiagutech.dto.common.LoginUser; |
|
|
|
import com.jiagutech.dto.common.PageRequest; |
|
|
|
import com.jiagutech.dto.common.PageResult; |
|
|
|
import com.jiagutech.dto.mapping.UserMapping; |
|
|
|
import com.jiagutech.dto.request.LoginRequest; |
|
|
|
import com.jiagutech.dto.request.UserRequest; |
|
|
|
import com.jiagutech.dto.response.LoginResponse; |
|
|
|
import com.jiagutech.dto.response.RecordItem; |
|
|
|
import com.jiagutech.dto.response.UserItem; |
|
|
|
import com.jiagutech.entity.UserEntity; |
|
|
|
import com.jiagutech.mapper.UserMapper; |
|
|
@ -62,8 +66,14 @@ public class UserServiceImpl implements UserService { |
|
|
|
.setRealName(user.getRealName()) |
|
|
|
.setUnitName(user.getUnitName()) |
|
|
|
.setPhone(user.getPhone()) |
|
|
|
.setRole(0) |
|
|
|
.setRole(1) |
|
|
|
.setPassword(BCrypt.hashpw(user.getPassword())); |
|
|
|
QueryWrapper<UserEntity> wrapper = Wrappers.query(); |
|
|
|
wrapper.eq("phone", user.getPhone()); |
|
|
|
UserEntity hasExists = userMapper.selectOne(wrapper); |
|
|
|
if (hasExists != null) { |
|
|
|
throw new BusinessException(BizCode.USER_PHONE_EXIST); |
|
|
|
} |
|
|
|
userMapper.insert(userEntity); |
|
|
|
emailUtil.sendEmail(null, user.getPhone(), user.getUnitName(), user.getRealName()); |
|
|
|
|
|
|
@ -77,11 +87,15 @@ public class UserServiceImpl implements UserService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<UserItem> approvalUserList() { |
|
|
|
public PageResult<UserItem> approvalUserList(PageRequest pageRequest) { |
|
|
|
QueryWrapper<UserEntity> wrapper = Wrappers.query(); |
|
|
|
wrapper.eq("status", 2); |
|
|
|
List<UserEntity> userEntities = userMapper.selectList(wrapper); |
|
|
|
return UserMapping.INSTANCE.convertToUserItems(userEntities); |
|
|
|
wrapper.orderByDesc("create_time"); |
|
|
|
wrapper.eq("role", 1); |
|
|
|
Page<UserEntity> page = new Page<>(pageRequest.getPageNum(), pageRequest.getPageSize()); |
|
|
|
|
|
|
|
Page<UserEntity> result = userMapper.selectPage(page, wrapper); |
|
|
|
List<UserItem> userItems = UserMapping.INSTANCE.convertToUserItems(result.getRecords()); |
|
|
|
return PageResult.of((int) result.getTotal(), (int) result.getSize(), (int) result.getCurrent(), userItems); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -92,7 +106,7 @@ public class UserServiceImpl implements UserService { |
|
|
|
int res = userMapper.updateById(userEntity); |
|
|
|
if (res > 0) { |
|
|
|
assert userEntity != null; |
|
|
|
StpUtil.logout(); |
|
|
|
StpUtil.logout(userEntity.getId()); |
|
|
|
} |
|
|
|
return res > 0; |
|
|
|
} |
|
|
|