}
}
### 6、service
**接口:BorrowerService**
void saveBorrowerVOByUserId(BorrowerVO borrowerVO, Long userId);
**实现:BorrowerServiceImpl**
@Resource
private BorrowerAttachMapper borrowerAttachMapper;
@Resource
private UserInfoMapper userInfoMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public void saveBorrowerVOByUserId(BorrowerVO borrowerVO, Long userId) {
UserInfo userInfo = userInfoMapper.selectById(userId);
//保存借款人信息
Borrower borrower = new Borrower();
BeanUtils.copyProperties(borrowerVO, borrower);
borrower.setUserId(userId);
borrower.setName(userInfo.getName());
borrower.setIdCard(userInfo.getIdCard());
borrower.setMobile(userInfo.getMobile());
borrower.setStatus(BorrowerStatusEnum.AUTH_RUN.getStatus());//认证中
baseMapper.insert(borrower);
//保存附件
List<BorrowerAttach> borrowerAttachList = borrowerVO.getBorrowerAttachList();
borrowerAttachList.forEach(borrowerAttach -> {
borrowerAttach.setBorrowerId(borrower.getId());
borrowerAttachMapper.insert(borrowerAttach);
});
//更新会员状态,更新为认证中
userInfo.setBorrowAuthStatus(BorrowerStatusEnum.AUTH_RUN.getStatus());
userInfoMapper.updateById(userInfo);
}
## 二、前端整合
**pages/user/borrower.vue 脚本**
save() {
// debugger
this.submitBtnDisabled = true
this.
a
x
i
o
s
.
axios .
axios.post(‘/api/core/borrower/save’, this.borrower)
.then((response) => {
this.active = 1
})
},
![](https://img-blog.csdnimg.cn/ad92c898b5684790911a155cf6583c2c.png)
## 一、获取借款人状态
### 1、BorrowerController
@ApiOperation(“获取借款人认证状态”)
@GetMapping(“/auth/getBorrowerStatus”)
public R getBorrowerStatus(HttpServletRequest request){
String token = request.getHeader(“token”);
Long userId = JwtUtils.getUserId(token);
Integer status = borrowerService.getStatusByUserId(userId);
return R.ok().data(“borrowerStatus”, status);
}
### 2、service
**接口:BorrowerService**
Integer getStatusByUserId(Long userId);
**实现:BorrowerServiceImpl**
@Override
public Integer getStatusByUserId(Long userId) {
QueryWrapper<Borrower> borrowerQueryWrapper = new QueryWrapper<>();
borrowerQueryWrapper.select("status").eq("user_id", userId);
List<Object> objects = baseMapper.selectObjs(borrowerQueryWrapper);
if(objects.size() == 0){
//借款人尚未提交信息
return BorrowerStatusEnum.NO_AUTH.getStatus();
}
Integer status = (Integer)objects.get(0);
return status;
}
## 二、前端开发
**pages/user/borrower.vue 脚本**
**将this.initSelected()在this.getUserInfo()中调用**
**methods中添加方法:**
//获取借款人信息
getUserInfo() {
this.
a
x
i
o
s
.
axios .
axios.get(‘/api/core/borrower/auth/getBorrowerStatus’)
.then((response) => {
this.borrowerStatus = response.data.borrowerStatus
if (this.borrowerStatus === 0) {
//未认证
this.active = 0
//获取下拉列表
this.initSelected()
} else if (this.borrowerStatus === 1) {
//认证中
this.active = 1
} else if (this.borrowerStatus === 2) {
//认证成功
this.active = 2
} else if (this.borrowerStatus === -1) {
//认证失败
this.active = 2
}
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!