优化
This commit is contained in:
parent
e5f4a6ad14
commit
60ae5403df
@ -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;
|
||||
|
||||
/**
|
||||
* 圈子是否禁用
|
||||
*/
|
||||
|
@ -43,7 +43,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> 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<AppUserDao, AppUserEntity> 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()
|
||||
|
@ -23,7 +23,7 @@ public class LinkServiceImpl extends ServiceImpl<LinkDao, LinkEntity> implements
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<LinkEntity> page = this.page(
|
||||
new Query<LinkEntity>().getPage(params),
|
||||
new QueryWrapper<LinkEntity>()
|
||||
new QueryWrapper<>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
|
@ -59,11 +59,11 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
|
||||
);
|
||||
List<PostEntity> data = page.getRecords();
|
||||
|
||||
List<PostListResponse> responseList=new ArrayList<>();
|
||||
data.forEach(l->{
|
||||
PostListResponse response=new PostListResponse();
|
||||
BeanUtils.copyProperties(l,response);
|
||||
if(response.getDiscussId()>0){
|
||||
List<PostListResponse> 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<PostDao, PostEntity> 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<PostDao, PostEntity> implements
|
||||
@Override
|
||||
public Integer findTopicPostCount(Integer topicId) {
|
||||
LambdaQueryWrapper<PostEntity> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(PostEntity::getTopicId,topicId);
|
||||
lambdaQueryWrapper.eq(PostEntity::getTopicId, topicId);
|
||||
return baseMapper.selectCount(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 选取圈子中热度最高的三条动态的首图作为展示
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> findThreeMedia(Integer id) {
|
||||
QueryWrapper<PostEntity> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.eq("topic_id",id);
|
||||
queryWrapper.eq("type",1);
|
||||
queryWrapper.orderByDesc("read_count");
|
||||
QueryWrapper<PostEntity> 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<PostEntity> postEntityList = baseMapper.selectList(queryWrapper);
|
||||
List<String> imageList=new ArrayList<>();
|
||||
for (int i = 0; i < postEntityList.size() ; i++) {
|
||||
if(!postEntityList.get(i).getMedia().equals("")){
|
||||
List<String> imageList = new ArrayList<>();
|
||||
for (int i = 0; i < postEntityList.size(); i++) {
|
||||
if (!postEntityList.get(i).getMedia().equals("")) {
|
||||
List<String> 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<PostDao, PostEntity> implements
|
||||
@Transactional
|
||||
public void deleteByAdmin(List<Integer> 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("批量删除失败");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -18,7 +18,6 @@ import io.linfeng.modules.admin.entity.TopicEntity;
|
||||
public class TopicServiceImpl extends ServiceImpl<TopicDao, TopicEntity> implements TopicService {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<TopicEntity> page = this.page(
|
||||
@ -30,7 +29,6 @@ public class TopicServiceImpl extends ServiceImpl<TopicDao, TopicEntity> impleme
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AppPageUtils queryByPage(Map<String, Object> params) {
|
||||
Integer classId = Integer.valueOf((String) params.get(Constant.CLASSID));
|
||||
@ -45,5 +43,4 @@ public class TopicServiceImpl extends ServiceImpl<TopicDao, TopicEntity> impleme
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user