用户的功能迁移
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.convert.user;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AuthenticateBO;
|
||||
import cn.iocoder.mall.system.biz.bo.user.UserAuthenticateBO;
|
||||
import cn.iocoder.mall.system.biz.bo.user.UserBO;
|
||||
import cn.iocoder.mall.system.biz.dataobject.admin.AdminDO;
|
||||
import cn.iocoder.mall.system.biz.dataobject.user.UserDO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserUpdateDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserUpdateStatusDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface UserConvert {
|
||||
|
||||
UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
|
||||
|
||||
UserBO convert(UserDO bean);
|
||||
|
||||
/**
|
||||
* 用户分页列表 - DOPage转换BO
|
||||
* @param userDOPage
|
||||
* @return
|
||||
*/
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<UserBO> convertToPage(IPage<UserDO> userDOPage);
|
||||
|
||||
/**
|
||||
* 更新用户信息 - DTO转换DO
|
||||
* @param userUpdateDTO
|
||||
* @return
|
||||
*/
|
||||
UserDO convertToUserDO(UserUpdateDTO userUpdateDTO);
|
||||
|
||||
/**
|
||||
* 更新用户状态 - DTO转换DO
|
||||
* @param userUpdateStatusDTO
|
||||
* @return
|
||||
*/
|
||||
UserDO convertToUserDO(UserUpdateStatusDTO userUpdateStatusDTO);
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.dto.user;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @Author: jiangweifan
|
||||
* @Date: 2020/5/12
|
||||
* @Description: 用户信息 - 用户分页列表DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserPageDTO {
|
||||
|
||||
/**
|
||||
* 昵称,模糊匹配
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 状态。1 - 开启;2 - 禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 页码,从 1 开始
|
||||
*/
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.service.user;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.user.UserBO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserPageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserUpdateDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserUpdateStatusDTO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 用户 Service 接口
|
||||
*/
|
||||
@Validated
|
||||
public interface UserService {
|
||||
|
||||
/**
|
||||
* 根据条件分页获取用户列表
|
||||
* @param userPageDTO
|
||||
* @return
|
||||
*/
|
||||
PageResult<UserBO> getUserPage(UserPageDTO userPageDTO);
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param userUpdateDTO
|
||||
* @return
|
||||
*/
|
||||
Boolean updateUserInfo(@Valid UserUpdateDTO userUpdateDTO);
|
||||
|
||||
/**
|
||||
* 更新用户状态
|
||||
* @param userUpdateStatusDTO
|
||||
* @return
|
||||
*/
|
||||
Boolean updateUserStatus(@Valid UserUpdateStatusDTO userUpdateStatusDTO);
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.service.user;
|
||||
|
||||
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AuthenticateBO;
|
||||
import cn.iocoder.mall.system.biz.bo.user.UserAuthenticateBO;
|
||||
import cn.iocoder.mall.system.biz.bo.user.UserBO;
|
||||
import cn.iocoder.mall.system.biz.convert.user.UserConvert;
|
||||
import cn.iocoder.mall.system.biz.dao.user.UserMapper;
|
||||
import cn.iocoder.mall.system.biz.dataobject.user.UserDO;
|
||||
import cn.iocoder.mall.system.biz.dto.oatuh2.OAuth2MobileCodeAuthenticateDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserPageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserUpdateDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.user.UserUpdateStatusDTO;
|
||||
import cn.iocoder.mall.system.biz.enums.user.UserStatusEnum;
|
||||
import cn.iocoder.mall.system.biz.service.oauth2.OAuth2Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import static cn.iocoder.mall.system.biz.enums.SystemErrorCodeEnum.*;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 根据条件分页获取用户列表
|
||||
* @param userPageDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageResult<UserBO> getUserPage(UserPageDTO userPageDTO) {
|
||||
return UserConvert.INSTANCE.convertToPage(userMapper.selectUserPage(userPageDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param userUpdateDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateUserInfo(UserUpdateDTO userUpdateDTO) {
|
||||
// 查询用户是否存在
|
||||
UserDO userDO = userMapper.selectById(userUpdateDTO.getId());
|
||||
if (null == userDO) {
|
||||
throw ServiceExceptionUtil.exception(USER_NOT_EXISTS);
|
||||
}
|
||||
// 更新用户信息
|
||||
UserDO updateDO = UserConvert.INSTANCE.convertToUserDO(userUpdateDTO);
|
||||
userMapper.updateById(updateDO);
|
||||
// TODO 伟帆 操作日志
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新用户状态
|
||||
* @param userUpdateStatusDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateUserStatus(UserUpdateStatusDTO userUpdateStatusDTO) {
|
||||
// 查询用户是否存在
|
||||
UserDO userDO = userMapper.selectById(userUpdateStatusDTO.getId());
|
||||
if (null == userDO) {
|
||||
throw ServiceExceptionUtil.exception(USER_NOT_EXISTS);
|
||||
}
|
||||
// 判断更新状态是否存在
|
||||
if (null != userUpdateStatusDTO.getStatus() &&
|
||||
Arrays.stream(UserStatusEnum.ARRAYS).noneMatch(status -> status == userUpdateStatusDTO.getStatus())) {
|
||||
throw ServiceExceptionUtil.exception(USER_STATUS_NOT_EXISTS);
|
||||
}
|
||||
// 如果状态相同,则返回错误
|
||||
if (null != userUpdateStatusDTO.getStatus() && userUpdateStatusDTO.getStatus().equals(userDO.getStatus())) {
|
||||
throw ServiceExceptionUtil.exception(USER_STATUS_EQUALS);
|
||||
}
|
||||
// 更新用户信息
|
||||
UserDO updateStatusDO = UserConvert.INSTANCE.convertToUserDO(userUpdateStatusDTO);
|
||||
userMapper.updateById(updateStatusDO);
|
||||
// TODO 伟帆 操作日志
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
13
system/system-biz/src/main/resources/application.yaml
Normal file
13
system/system-biz/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
spring:
|
||||
# Application 的配置项
|
||||
application:
|
||||
name: system-application
|
||||
# Profile 的配置项
|
||||
profiles:
|
||||
active: local
|
||||
|
||||
# TODO 小范 TO 芋艿,这个临时加了个
|
||||
qiniu:
|
||||
bucket: xx
|
||||
access-key: xx
|
||||
secret-key: xx
|
||||
Reference in New Issue
Block a user