From 60ae5403dfd428b2c1b39908fb24f1b3ab3cd3de Mon Sep 17 00:00:00 2001 From: linfeng <2445465217@qq.com> Date: Sat, 30 Apr 2022 15:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/linfeng/common/utils/Constant.java | 6 +++ .../service/impl/AppUserServiceImpl.java | 4 +- .../admin/service/impl/LinkServiceImpl.java | 2 +- .../admin/service/impl/PostServiceImpl.java | 43 ++++++++++--------- .../service/impl/SensitiveServiceImpl.java | 2 + .../admin/service/impl/SystemServiceImpl.java | 2 - .../admin/service/impl/TopicServiceImpl.java | 3 -- 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/main/java/io/linfeng/common/utils/Constant.java b/src/main/java/io/linfeng/common/utils/Constant.java index 2d375f9..ac4a758 100644 --- a/src/main/java/io/linfeng/common/utils/Constant.java +++ b/src/main/java/io/linfeng/common/utils/Constant.java @@ -41,6 +41,12 @@ public class Constant { public static final Integer NOT_READ = 0; public static final Integer HAS_READ = 1; + /** + * 用户是否禁用 + */ + public static final Integer USER_NORMAL = 0; + public static final Integer USER_BANNER = 1; + /** * 圈子是否禁用 */ diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java index 85279aa..6b9a12b 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/AppUserServiceImpl.java @@ -43,7 +43,7 @@ public class AppUserServiceImpl extends ServiceImpl i @Override public void ban(Integer id) { Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus(); - if(status==1){ + if(status.equals(Constant.USER_BANNER)){ throw new LinfengException("该用户已被禁用"); } this.lambdaUpdate() @@ -55,7 +55,7 @@ public class AppUserServiceImpl extends ServiceImpl i @Override public void openBan(Integer id) { Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus(); - if(status==0){ + if(status.equals(Constant.USER_NORMAL)){ throw new LinfengException("该用户已解除禁用"); } this.lambdaUpdate() diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/LinkServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/LinkServiceImpl.java index 2be0646..c8c570a 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/LinkServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/LinkServiceImpl.java @@ -23,7 +23,7 @@ public class LinkServiceImpl extends ServiceImpl implements public PageUtils queryPage(Map params) { IPage page = this.page( new Query().getPage(params), - new QueryWrapper() + new QueryWrapper<>() ); return new PageUtils(page); diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/PostServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/PostServiceImpl.java index c2b7569..3bd7eb2 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/PostServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/PostServiceImpl.java @@ -59,11 +59,11 @@ public class PostServiceImpl extends ServiceImpl implements ); List data = page.getRecords(); - List responseList=new ArrayList<>(); - data.forEach(l->{ - PostListResponse response=new PostListResponse(); - BeanUtils.copyProperties(l,response); - if(response.getDiscussId()>0){ + List responseList = new ArrayList<>(); + data.forEach(l -> { + PostListResponse response = new PostListResponse(); + BeanUtils.copyProperties(l, response); + if (response.getDiscussId() > 0) { DiscussEntity discussEntity = discussService.getById(response.getDiscussId()); response.setDiscussTitle(discussEntity.getTitle()); } @@ -76,7 +76,7 @@ public class PostServiceImpl extends ServiceImpl implements response.setMedia(list); responseList.add(response); }); - PageUtils pageUtils=new PageUtils(page); + PageUtils pageUtils = new PageUtils(page); pageUtils.setList(responseList); return pageUtils; } @@ -84,31 +84,32 @@ public class PostServiceImpl extends ServiceImpl implements @Override public Integer findTopicPostCount(Integer topicId) { LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(); - lambdaQueryWrapper.eq(PostEntity::getTopicId,topicId); + lambdaQueryWrapper.eq(PostEntity::getTopicId, topicId); return baseMapper.selectCount(lambdaQueryWrapper); } /** * 选取圈子中热度最高的三条动态的首图作为展示 + * * @param id * @return */ @Override public List findThreeMedia(Integer id) { - QueryWrapper queryWrapper=new QueryWrapper<>(); - queryWrapper.eq("topic_id",id); - queryWrapper.eq("type",1); - queryWrapper.orderByDesc("read_count"); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(PostEntity::getTopicId, id); + queryWrapper.lambda().eq(PostEntity::getType, 1); + queryWrapper.lambda().orderByDesc(PostEntity::getReadCount); queryWrapper.last("limit 10"); List postEntityList = baseMapper.selectList(queryWrapper); - List imageList=new ArrayList<>(); - for (int i = 0; i < postEntityList.size() ; i++) { - if(!postEntityList.get(i).getMedia().equals("")){ + List imageList = new ArrayList<>(); + for (int i = 0; i < postEntityList.size(); i++) { + if (!postEntityList.get(i).getMedia().equals("")) { List jsonToList = JsonUtils.JsonToList(postEntityList.get(i).getMedia()); - if(jsonToList.size()>0){ - if(imageList.size()>2){ + if (jsonToList.size() > 0) { + if (imageList.size() > 2) { break; - }else{ + } else { imageList.add(jsonToList.get(0)); } } @@ -122,13 +123,13 @@ public class PostServiceImpl extends ServiceImpl implements @Transactional public void deleteByAdmin(List ids) { //通知用户消息违规被删除了 - ids.forEach(postId->{ + ids.forEach(postId -> { PostEntity post = this.getById(postId); - String content = StrUtil.format(Constant.ADMIN_POST_DOWN,post.getTitle()); - messageService.sendMessage(0,post.getUid(),postId,Constant.PUSHARTICLE,content,Constant.TITLE_VIOLATION); + String content = StrUtil.format(Constant.ADMIN_POST_DOWN, post.getTitle()); + messageService.sendMessage(0, post.getUid(), postId, Constant.PUSHARTICLE, content, Constant.TITLE_VIOLATION); }); boolean remove = this.removeByIds(ids); - if(!remove){ + if (!remove) { throw new LinfengException("批量删除失败"); } } diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/SensitiveServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/SensitiveServiceImpl.java index 0ae103a..eca498d 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/SensitiveServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/SensitiveServiceImpl.java @@ -3,7 +3,9 @@ package io.linfeng.modules.admin.service.impl; import io.linfeng.common.exception.LinfengException; import io.linfeng.common.utils.Constant; import org.springframework.stereotype.Service; + import java.util.Map; + import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/SystemServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/SystemServiceImpl.java index f040eaa..d35b050 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/SystemServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/SystemServiceImpl.java @@ -1,7 +1,5 @@ package io.linfeng.modules.admin.service.impl; -import io.linfeng.modules.admin.dao.AppUserDao; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/TopicServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/TopicServiceImpl.java index 5401dee..598e850 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/TopicServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/TopicServiceImpl.java @@ -18,7 +18,6 @@ import io.linfeng.modules.admin.entity.TopicEntity; public class TopicServiceImpl extends ServiceImpl implements TopicService { - @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -30,7 +29,6 @@ public class TopicServiceImpl extends ServiceImpl impleme } - @Override public AppPageUtils queryByPage(Map params) { Integer classId = Integer.valueOf((String) params.get(Constant.CLASSID)); @@ -45,5 +43,4 @@ public class TopicServiceImpl extends ServiceImpl impleme } - } \ No newline at end of file