优化代码

This commit is contained in:
linfeng 2024-06-11 08:38:07 +08:00
parent cd5756e785
commit da953520cb
7 changed files with 16 additions and 13 deletions

View File

@ -52,6 +52,9 @@ public class Constant {
public static final Integer USER_NORMAL = 0;
public static final Integer USER_BANNER = 1;
public static final String USER_BANNER_MSG = "该账号已被禁用";
/**

View File

@ -101,8 +101,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
@Transactional(rollbackFor = Exception.class)
public void ban(Integer id) {
Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus();
if (status.equals(Constant.USER_BANNER)) {
throw new LinfengException("该用户已被禁用");
if(status.equals(Constant.USER_BANNER)){
throw new LinfengException(Constant.USER_BANNER_MSG);
}
this.lambdaUpdate()
.set(AppUserEntity::getStatus, Constant.USER_BANNER)
@ -116,7 +116,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
public void openBan(Integer id) {
Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus();
if (status.equals(Constant.USER_NORMAL)) {
throw new LinfengException("该用户已解除禁用");
throw new LinfengException(Constant.USER_BANNER_MSG);
}
boolean update = this.lambdaUpdate()
.set(AppUserEntity::getStatus, Constant.USER_NORMAL)
@ -165,7 +165,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
if (ObjectUtil.isNotNull(appUserEntity)) {
//登录
if (appUserEntity.getStatus().equals(Constant.USER_BANNER)) {
throw new LinfengException("该账户已被禁用");
throw new LinfengException(Constant.USER_BANNER_MSG);
}
return appUserEntity.getUid();
} else {
@ -330,8 +330,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
.eq(AppUserEntity::getOpenid, openId)
.one();
if (ObjectUtil.isNotNull(user)) {
if (user.getStatus() .equals(Constant.USER_BANNER)) {
throw new LinfengException("该账户已被禁用");
if(user.getStatus().equals(Constant.USER_BANNER)){
throw new LinfengException(Constant.USER_BANNER_MSG);
}
//其他业务todo
return user.getUid();

View File

@ -202,7 +202,7 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
@Transactional(rollbackFor = Exception.class)
public void addComment(AddCommentForm request, AppUserEntity user) {
if(user.getStatus().equals(Constant.USER_BANNER)){
throw new LinfengException("您的账号已被禁用!");
throw new LinfengException(Constant.USER_BANNER_MSG);
}
CommentEntity commentEntity=new CommentEntity();
@ -217,8 +217,8 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
@Override
@Transactional(rollbackFor = Exception.class)
public Integer addPost(AddPostForm request, AppUserEntity user) {
if(user.getStatus()!=0){
throw new LinfengException("您的账号已被禁用");
if(user.getStatus().equals(Constant.USER_BANNER)){
throw new LinfengException(Constant.USER_BANNER_MSG);
}
PostEntity post=new PostEntity();
BeanUtils.copyProperties(request,post);

View File

@ -35,7 +35,7 @@ public class AppSystemConfigController {
@ApiOperation("logo配置")
@GetMapping("/miniConfig")
@GetMapping("/config")
public R miniConfig(){
SystemEntity system = systemService.miniConfig();
return R.ok().put("logo",system.getIntro());

View File

@ -47,7 +47,7 @@
})
},
getSysInfo() {
this.$H.get("system/miniConfig").then(res => {
this.$H.get("system/config").then(res => {
if (res.code == 0) {
this.logo = res.logo;
}

View File

@ -29,7 +29,7 @@
});
},
getSysInfo() {
this.$H.get("system/miniConfig").then(res => {
this.$H.get("system/config").then(res => {
if (res.code == 0) {
this.logo = res.logo;
}

View File

@ -147,7 +147,7 @@
});
},
getSysInfo() {
this.$H.get('system/miniConfig').then(res => {
this.$H.get('system/config').then(res => {
this.shareCover = res.logo;
});
},