mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-14 19:15:06 +08:00
promotion:增加优惠劵的后端分页接口
This commit is contained in:
@ -2,6 +2,12 @@ package cn.iocoder.yudao.module.member.api.user;
|
||||
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
/**
|
||||
* 会员用户的 API 接口
|
||||
*
|
||||
@ -17,4 +23,30 @@ public interface MemberUserApi {
|
||||
*/
|
||||
UserRespDTO getUser(Long id);
|
||||
|
||||
/**
|
||||
* 获得会员用户信息们
|
||||
*
|
||||
* @param ids 用户编号的数组
|
||||
* @return 用户信息们
|
||||
*/
|
||||
List<UserRespDTO> getUsers(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得会员用户 Map
|
||||
*
|
||||
* @param ids 用户编号的数组
|
||||
* @return 会员用户 Map
|
||||
*/
|
||||
default Map<Long, UserRespDTO> getUserMap(Collection<Long> ids) {
|
||||
return convertMap(getUsers(ids), UserRespDTO::getId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于用户昵称,模糊匹配用户列表
|
||||
*
|
||||
* @param nickname 用户昵称,模糊匹配
|
||||
* @return 用户信息的列表
|
||||
*/
|
||||
List<UserRespDTO> getUserListByNickname(String nickname);
|
||||
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.api.user.dto;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户信息 Response DTO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class UserInfoDTO {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 帐号状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 注册 IP
|
||||
*/
|
||||
private String registerIp;
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
private String loginIp;
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private Date loginDate;
|
||||
|
||||
}
|
@ -8,6 +8,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员用户的 API 实现类
|
||||
@ -27,4 +29,14 @@ public class MemberUserApiImpl implements MemberUserApi {
|
||||
return UserConvert.INSTANCE.convert2(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRespDTO> getUsers(Collection<Long> ids) {
|
||||
return UserConvert.INSTANCE.convertList2(userService.getUserList(ids));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserRespDTO> getUserListByNickname(String nickname) {
|
||||
return UserConvert.INSTANCE.convertList2(userService.getUserListByNickname(nickname));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,39 +0,0 @@
|
||||
package cn.iocoder.yudao.module.member.controller.admin.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.UserInfoDTO;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.convert.user.UserConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* @author Banging
|
||||
*/
|
||||
@Slf4j
|
||||
@Api("用户管理")
|
||||
@RestController(value = "memberUserController")
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
private MemberUserService userService;
|
||||
|
||||
@ApiOperation(value = "用户信息获取",notes = "用户基本信息的获取")
|
||||
@GetMapping("/{tel}")
|
||||
public CommonResult<UserInfoDTO> getUserInfo(@PathVariable String tel){
|
||||
MemberUserDO user = userService.getUserByMobile(tel);
|
||||
return CommonResult.success(UserConvert.INSTANCE.convertInfo(user));
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package cn.iocoder.yudao.module.member.convert.user;
|
||||
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.UserInfoDTO;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.UserRespDTO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoRespVO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserConvert {
|
||||
|
||||
@ -15,5 +16,7 @@ public interface UserConvert {
|
||||
AppUserInfoRespVO convert(MemberUserDO bean);
|
||||
|
||||
UserRespDTO convert2(MemberUserDO bean);
|
||||
UserInfoDTO convertInfo(MemberUserDO bean);
|
||||
|
||||
List<UserRespDTO> convertList2(List<MemberUserDO> list);
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.user;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员 User Mapper
|
||||
*
|
||||
@ -16,4 +19,9 @@ public interface MemberUserMapper extends BaseMapperX<MemberUserDO> {
|
||||
return selectOne(MemberUserDO::getMobile, mobile);
|
||||
}
|
||||
|
||||
default List<MemberUserDO> selectListByNicknameLike(String nickname) {
|
||||
return selectList(new LambdaQueryWrapperX<MemberUserDO>()
|
||||
.likeIfPresent(MemberUserDO::getNickname, nickname));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserUpdateMobile
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员用户 Service 接口
|
||||
@ -21,6 +23,15 @@ public interface MemberUserService {
|
||||
*/
|
||||
MemberUserDO getUserByMobile(String mobile);
|
||||
|
||||
/**
|
||||
* 基于用户昵称,模糊匹配用户列表
|
||||
*
|
||||
* @param nickname 用户昵称,模糊匹配
|
||||
* @return 用户信息的列表
|
||||
*/
|
||||
List<MemberUserDO> getUserListByNickname(String nickname);
|
||||
|
||||
|
||||
/**
|
||||
* 基于手机号创建用户。
|
||||
* 如果用户已经存在,则直接进行返回
|
||||
@ -47,6 +58,14 @@ public interface MemberUserService {
|
||||
*/
|
||||
MemberUserDO getUser(Long id);
|
||||
|
||||
/**
|
||||
* 通过用户 ID 查询用户们
|
||||
*
|
||||
* @param ids 用户 ID
|
||||
* @return 用户对象信息数组
|
||||
*/
|
||||
List<MemberUserDO> getUserList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 修改用户昵称
|
||||
* @param userId 用户id
|
||||
|
@ -19,7 +19,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
@ -51,6 +53,11 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
return memberUserMapper.selectByMobile(mobile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberUserDO> getUserListByNickname(String nickname) {
|
||||
return memberUserMapper.selectListByNicknameLike(nickname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemberUserDO createUserIfAbsent(String mobile, String registerIp) {
|
||||
// 用户已经存在
|
||||
@ -86,6 +93,11 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
return memberUserMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberUserDO> getUserList(Collection<Long> ids) {
|
||||
return memberUserMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserNickname(Long userId, String nickname) {
|
||||
MemberUserDO user = this.checkUserExists(userId);
|
||||
|
Reference in New Issue
Block a user