This commit is contained in:
linfeng 2022-04-30 15:57:10 +08:00
parent e5f4a6ad14
commit 60ae5403df
7 changed files with 33 additions and 29 deletions

View File

@ -41,6 +41,12 @@ public class Constant {
public static final Integer NOT_READ = 0; public static final Integer NOT_READ = 0;
public static final Integer HAS_READ = 1; public static final Integer HAS_READ = 1;
/**
* 用户是否禁用
*/
public static final Integer USER_NORMAL = 0;
public static final Integer USER_BANNER = 1;
/** /**
* 圈子是否禁用 * 圈子是否禁用
*/ */

View File

@ -43,7 +43,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
@Override @Override
public void ban(Integer id) { public void ban(Integer id) {
Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus(); Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus();
if(status==1){ if(status.equals(Constant.USER_BANNER)){
throw new LinfengException("该用户已被禁用"); throw new LinfengException("该用户已被禁用");
} }
this.lambdaUpdate() this.lambdaUpdate()
@ -55,7 +55,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
@Override @Override
public void openBan(Integer id) { public void openBan(Integer id) {
Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus(); Integer status = this.lambdaQuery().eq(AppUserEntity::getUid, id).one().getStatus();
if(status==0){ if(status.equals(Constant.USER_NORMAL)){
throw new LinfengException("该用户已解除禁用"); throw new LinfengException("该用户已解除禁用");
} }
this.lambdaUpdate() this.lambdaUpdate()

View File

@ -23,7 +23,7 @@ public class LinkServiceImpl extends ServiceImpl<LinkDao, LinkEntity> implements
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
IPage<LinkEntity> page = this.page( IPage<LinkEntity> page = this.page(
new Query<LinkEntity>().getPage(params), new Query<LinkEntity>().getPage(params),
new QueryWrapper<LinkEntity>() new QueryWrapper<>()
); );
return new PageUtils(page); return new PageUtils(page);

View File

@ -59,11 +59,11 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
); );
List<PostEntity> data = page.getRecords(); List<PostEntity> data = page.getRecords();
List<PostListResponse> responseList=new ArrayList<>(); List<PostListResponse> responseList = new ArrayList<>();
data.forEach(l->{ data.forEach(l -> {
PostListResponse response=new PostListResponse(); PostListResponse response = new PostListResponse();
BeanUtils.copyProperties(l,response); BeanUtils.copyProperties(l, response);
if(response.getDiscussId()>0){ if (response.getDiscussId() > 0) {
DiscussEntity discussEntity = discussService.getById(response.getDiscussId()); DiscussEntity discussEntity = discussService.getById(response.getDiscussId());
response.setDiscussTitle(discussEntity.getTitle()); response.setDiscussTitle(discussEntity.getTitle());
} }
@ -76,7 +76,7 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
response.setMedia(list); response.setMedia(list);
responseList.add(response); responseList.add(response);
}); });
PageUtils pageUtils=new PageUtils(page); PageUtils pageUtils = new PageUtils(page);
pageUtils.setList(responseList); pageUtils.setList(responseList);
return pageUtils; return pageUtils;
} }
@ -84,31 +84,32 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
@Override @Override
public Integer findTopicPostCount(Integer topicId) { public Integer findTopicPostCount(Integer topicId) {
LambdaQueryWrapper<PostEntity> lambdaQueryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<PostEntity> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(PostEntity::getTopicId,topicId); lambdaQueryWrapper.eq(PostEntity::getTopicId, topicId);
return baseMapper.selectCount(lambdaQueryWrapper); return baseMapper.selectCount(lambdaQueryWrapper);
} }
/** /**
* 选取圈子中热度最高的三条动态的首图作为展示 * 选取圈子中热度最高的三条动态的首图作为展示
*
* @param id * @param id
* @return * @return
*/ */
@Override @Override
public List<String> findThreeMedia(Integer id) { public List<String> findThreeMedia(Integer id) {
QueryWrapper<PostEntity> queryWrapper=new QueryWrapper<>(); QueryWrapper<PostEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("topic_id",id); queryWrapper.lambda().eq(PostEntity::getTopicId, id);
queryWrapper.eq("type",1); queryWrapper.lambda().eq(PostEntity::getType, 1);
queryWrapper.orderByDesc("read_count"); queryWrapper.lambda().orderByDesc(PostEntity::getReadCount);
queryWrapper.last("limit 10"); queryWrapper.last("limit 10");
List<PostEntity> postEntityList = baseMapper.selectList(queryWrapper); List<PostEntity> postEntityList = baseMapper.selectList(queryWrapper);
List<String> imageList=new ArrayList<>(); List<String> imageList = new ArrayList<>();
for (int i = 0; i < postEntityList.size() ; i++) { for (int i = 0; i < postEntityList.size(); i++) {
if(!postEntityList.get(i).getMedia().equals("")){ if (!postEntityList.get(i).getMedia().equals("")) {
List<String> jsonToList = JsonUtils.JsonToList(postEntityList.get(i).getMedia()); List<String> jsonToList = JsonUtils.JsonToList(postEntityList.get(i).getMedia());
if(jsonToList.size()>0){ if (jsonToList.size() > 0) {
if(imageList.size()>2){ if (imageList.size() > 2) {
break; break;
}else{ } else {
imageList.add(jsonToList.get(0)); imageList.add(jsonToList.get(0));
} }
} }
@ -122,13 +123,13 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
@Transactional @Transactional
public void deleteByAdmin(List<Integer> ids) { public void deleteByAdmin(List<Integer> ids) {
//通知用户消息违规被删除了 //通知用户消息违规被删除了
ids.forEach(postId->{ ids.forEach(postId -> {
PostEntity post = this.getById(postId); PostEntity post = this.getById(postId);
String content = StrUtil.format(Constant.ADMIN_POST_DOWN,post.getTitle()); String content = StrUtil.format(Constant.ADMIN_POST_DOWN, post.getTitle());
messageService.sendMessage(0,post.getUid(),postId,Constant.PUSHARTICLE,content,Constant.TITLE_VIOLATION); messageService.sendMessage(0, post.getUid(), postId, Constant.PUSHARTICLE, content, Constant.TITLE_VIOLATION);
}); });
boolean remove = this.removeByIds(ids); boolean remove = this.removeByIds(ids);
if(!remove){ if (!remove) {
throw new LinfengException("批量删除失败"); throw new LinfengException("批量删除失败");
} }
} }

View File

@ -3,7 +3,9 @@ package io.linfeng.modules.admin.service.impl;
import io.linfeng.common.exception.LinfengException; import io.linfeng.common.exception.LinfengException;
import io.linfeng.common.utils.Constant; import io.linfeng.common.utils.Constant;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

View File

@ -1,7 +1,5 @@
package io.linfeng.modules.admin.service.impl; 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 org.springframework.stereotype.Service;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

View File

@ -18,7 +18,6 @@ import io.linfeng.modules.admin.entity.TopicEntity;
public class TopicServiceImpl extends ServiceImpl<TopicDao, TopicEntity> implements TopicService { public class TopicServiceImpl extends ServiceImpl<TopicDao, TopicEntity> implements TopicService {
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
IPage<TopicEntity> page = this.page( IPage<TopicEntity> page = this.page(
@ -30,7 +29,6 @@ public class TopicServiceImpl extends ServiceImpl<TopicDao, TopicEntity> impleme
} }
@Override @Override
public AppPageUtils queryByPage(Map<String, Object> params) { public AppPageUtils queryByPage(Map<String, Object> params) {
Integer classId = Integer.valueOf((String) params.get(Constant.CLASSID)); Integer classId = Integer.valueOf((String) params.get(Constant.CLASSID));
@ -45,5 +43,4 @@ public class TopicServiceImpl extends ServiceImpl<TopicDao, TopicEntity> impleme
} }
} }