用户判空处理

This commit is contained in:
linfeng 2022-12-09 13:03:53 +08:00
parent 61a37df4c2
commit 7ff65ba2cc
4 changed files with 30 additions and 27 deletions

View File

@ -284,6 +284,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
@Override
public AppUserInfoResponse findUserInfoById(Integer uid, AppUserEntity user) {
AppUserEntity userEntity = this.getById(uid);
if(ObjectUtil.isNull(userEntity)){
throw new LinfengException("用户不存在");
}
AppUserInfoResponse response = new AppUserInfoResponse();
BeanUtils.copyProperties(userEntity, response);
return response;

View File

@ -83,6 +83,7 @@
</view>
</view>
</view>
<u-line color="#d8d8d8"></u-line>
<view class="comment-box">
<view class="title">评论{{ postDetail.commentCount }}</view>
<view style="margin-bottom: 40rpx;" v-for="(item, index) in commentList" :key="index">

View File

@ -137,24 +137,33 @@
this.$H.post('user/userInfoById', {
uid: this.uid
}).then(res => {
this.userInfo = res.result;
if (res.result.gender === 1) {
this.userInfo.gender = '男'
} else if (res.result.gender === 2) {
this.userInfo.gender = '女'
} else {
this.userInfo.gender = '保密'
if(res.code==0){
this.userInfo = res.result;
if (res.result.gender === 1) {
this.userInfo.gender = '男'
} else if (res.result.gender === 2) {
this.userInfo.gender = '女'
} else {
this.userInfo.gender = '保密'
}
let user = {
uid: res.result.uid,
username: res.result.username,
avatar: res.result.avatar,
}
this.userJson = JSON.stringify(user)
uni.setNavigationBarTitle({
title: this.userInfo.username
});
}else{
setTimeout(function() {
uni.switchTab({
url: '/pages/index/index'
});
}, 1500);
}
let user = {
uid: res.result.uid,
username: res.result.username,
avatar: res.result.avatar,
}
this.userJson = JSON.stringify(user)
uni.setNavigationBarTitle({
title: this.userInfo.username
});
this.loading = false;
})

View File

@ -91,11 +91,6 @@
hasLogin: false
};
},
computed: {
msgCount() {
return this.$store.state.messegeNum
}
},
onLoad() {
//#ifdef MP-WEIXIN
wx.showShareMenu({
@ -121,11 +116,6 @@
};
},
methods: {
getMsgNum() {
this.$H.post('message/num').then(res => {
this.$store.state.messegeNum = [0, 0, 0, res.result.allCount, 0];
});
},
phoneLogin() {
uni.navigateTo({
url: '/pages/login/login'