后台实名信息接口
This commit is contained in:
parent
eea862961b
commit
3ac47228d1
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
|
@ -14,6 +15,7 @@ import java.util.Date;
|
|||
*/
|
||||
@TableName(value ="user_info")
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
public class UserInfo implements Serializable {
|
||||
/**
|
||||
*
|
||||
|
|
@ -64,53 +66,13 @@ public class UserInfo implements Serializable {
|
|||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String name;
|
||||
@TableField(exist = false)
|
||||
private String phone;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
UserInfo other = (UserInfo) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
|
||||
&& (this.getCertName() == null ? other.getCertName() == null : this.getCertName().equals(other.getCertName()))
|
||||
&& (this.getCertNo() == null ? other.getCertNo() == null : this.getCertNo().equals(other.getCertNo()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
|
||||
result = prime * result + ((getCertName() == null) ? 0 : getCertName().hashCode());
|
||||
result = prime * result + ((getCertNo() == null) ? 0 : getCertNo().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", certName=").append(certName);
|
||||
sb.append(", certNo=").append(certNo);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,4 +30,6 @@ public interface UserInfoService extends IService<UserInfo> {
|
|||
Integer countCertCount(String name, String idNum, String accountNo, String mobile);
|
||||
|
||||
int getAuthUserTag(long userId);
|
||||
|
||||
Object getList(Integer page, Integer size, String phone, String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,18 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.app.dao.UserDao;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.sqx.modules.app.mapper.UserInfoMapper;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
|
|
@ -21,6 +26,13 @@ import java.util.List;
|
|||
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
implements UserInfoService {
|
||||
|
||||
private final UserDao userDao;
|
||||
|
||||
public UserInfoServiceImpl(UserDao userDao) {
|
||||
this.userDao = userDao;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public UserInfo getByUserIdOrSave(long userId) {
|
||||
UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>()
|
||||
|
|
@ -114,6 +126,34 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
|||
// 老用户
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getList(Integer page, Integer size, String phone, String name) {
|
||||
LambdaQueryWrapper<UserInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(phone)) {
|
||||
UserEntity userEntity = userDao.selectOne(new LambdaQueryWrapper<UserEntity>().eq(UserEntity::getPhone, phone));
|
||||
lambdaQueryWrapper.eq(UserInfo::getUserId, userEntity == null ? -99999 : userEntity.getUserId());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
lambdaQueryWrapper.like(UserInfo::getCertName, name);
|
||||
}
|
||||
PageHelper.startPage(page, size);
|
||||
List<UserInfo> userInfoList = list(lambdaQueryWrapper);
|
||||
PageInfo<UserInfo> userInfoPageInfo = new PageInfo<>(userInfoList);
|
||||
|
||||
Set<Long> userIdList = userInfoList.stream().map(UserInfo::getUserId).collect(Collectors.toSet());
|
||||
Map<Long, UserEntity> userMap = userIdList.isEmpty() ? new HashMap<>() : userDao.selectList(new LambdaQueryWrapper<UserEntity>().in(UserEntity::getUserId, userIdList))
|
||||
.stream().collect(Collectors.toMap(UserEntity::getUserId, item -> item));
|
||||
|
||||
userInfoList.forEach(item -> {
|
||||
UserEntity userEntity = userMap.get(item.getUserId());
|
||||
if (userEntity == null) return;
|
||||
item.setName(userEntity.getUserName());
|
||||
item.setPhone(userEntity.getPhone());
|
||||
});
|
||||
return PageUtils.page(userInfoPageInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
package com.sqx.modules.userinfo.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
import com.sqx.modules.userinfo.dao.UserInfoDAO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/userInfo")
|
||||
public class UserInfoController {
|
||||
|
||||
private final UserInfoService userInfoService;
|
||||
|
||||
public UserInfoController(UserInfoService userInfoService) {
|
||||
this.userInfoService = userInfoService;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result getList(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String phone, @RequestParam(required = false) String name) {
|
||||
|
||||
return Result.success().put("data", userInfoService.getList(page, size, phone, name));
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
public Result update(@RequestBody @Validated UserInfoDAO userInfoDAO) {
|
||||
UserInfo info = new UserInfo();
|
||||
BeanUtil.copyProperties(userInfoDAO, info);
|
||||
info.setUpdateTime(DateUtil.date());
|
||||
return Result.success().put("data", userInfoService.update(info, new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userInfoDAO.getUserId())));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public Result delete(@RequestBody @Validated UserInfoDAO userInfoDAO) {
|
||||
return Result.success().put("data", userInfoService.remove(new LambdaQueryWrapper<UserInfo>().eq(UserInfo::getUserId, userInfoDAO.getUserId())));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.sqx.modules.userinfo.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class UserInfoDAO {
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@NotNull
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String certName;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
private String certNo;
|
||||
|
||||
/**
|
||||
* 银行账号
|
||||
*/
|
||||
private String accountNo;
|
||||
|
||||
/**
|
||||
* 银行预留手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 银行预留手机号
|
||||
*/
|
||||
private String bankName;
|
||||
}
|
||||
Loading…
Reference in New Issue