分页2
This commit is contained in:
@@ -7,6 +7,8 @@ import com.sqx.modules.message.entity.ActivityMessageInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
@@ -14,11 +16,11 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface ActivityMessageInfoDao extends BaseMapper<ActivityMessageInfo> {
|
||||
|
||||
IPage<ActivityMessageInfo> find(Page<ActivityMessageInfo> page,@Param("state") String state);
|
||||
List<ActivityMessageInfo> find(@Param("state") String state);
|
||||
|
||||
IPage<ActivityMessageInfo> findType(Page<ActivityMessageInfo> page,@Param("type") Integer type);
|
||||
List<ActivityMessageInfo> findType(@Param("type") Integer type);
|
||||
|
||||
IPage<ActivityMessageInfo> findTypeByUserId(Page<ActivityMessageInfo> page,@Param("type")String type,@Param("userId") String userId);
|
||||
List<ActivityMessageInfo> findTypeByUserId(@Param("type")String type,@Param("userId") String userId);
|
||||
|
||||
Integer updateState(@Param("state") String state, @Param("id") Long id);
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.sqx.modules.message.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.modules.message.dao.ActivityMessageInfoDao;
|
||||
import com.sqx.modules.message.entity.ActivityMessageInfo;
|
||||
@@ -54,8 +56,8 @@ public class ActivityMessageServiceImpl extends ServiceImpl<ActivityMessageInfoD
|
||||
|
||||
@Override
|
||||
public PageUtils find(String state, int page,int limit) {
|
||||
Page<ActivityMessageInfo> pages = new Page<>(page, limit);
|
||||
return new PageUtils(activityMessageInfoDao.find(pages,state));
|
||||
PageHelper.startPage(page, limit);
|
||||
return PageUtils.page(new PageInfo<>(activityMessageInfoDao.find(state)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,8 +69,8 @@ public class ActivityMessageServiceImpl extends ServiceImpl<ActivityMessageInfoD
|
||||
|
||||
@Override
|
||||
public PageUtils findType(Integer type, int page,int limit) {
|
||||
Page<ActivityMessageInfo> pages = new Page<>(page, limit);
|
||||
return new PageUtils(activityMessageInfoDao.findType(pages,type));
|
||||
PageHelper.startPage(page, limit);
|
||||
return PageUtils.page(new PageInfo<>(activityMessageInfoDao.findType(type)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,8 +87,8 @@ public class ActivityMessageServiceImpl extends ServiceImpl<ActivityMessageInfoD
|
||||
|
||||
@Override
|
||||
public PageUtils findTypeByUserId( String type,String userId, int page,int limit) {
|
||||
Page<ActivityMessageInfo> pages = new Page<>(page, limit);
|
||||
return new PageUtils(activityMessageInfoDao.findTypeByUserId(pages,type,userId));
|
||||
PageHelper.startPage(page, limit);
|
||||
return PageUtils.page(new PageInfo<>(activityMessageInfoDao.findTypeByUserId(type,userId)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package com.sqx.modules.message.service.impl;
|
||||
|
||||
import cn.hutool.core.map.MapProxy;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.Constant;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Query;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.job.entity.ScheduleJobLogEntity;
|
||||
import com.sqx.modules.message.dao.MessageInfoDao;
|
||||
import com.sqx.modules.message.entity.MessageInfo;
|
||||
import com.sqx.modules.message.service.MessageService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -38,20 +44,22 @@ public class MessageServiceImpl extends ServiceImpl<MessageInfoDao, MessageInfo>
|
||||
Long userId = (Long)params.get("userId");
|
||||
Integer state = (Integer)params.get("state");
|
||||
Integer type = (Integer)params.get("type");
|
||||
IPage<MessageInfo> page = this.page(
|
||||
new Query<MessageInfo>().getPage(params),
|
||||
new QueryWrapper<MessageInfo>()
|
||||
.eq(userId!=null,"user_id", userId)
|
||||
.eq(state!=null,"state", state)
|
||||
.eq(type!=null,"type", type).orderByDesc("create_at")
|
||||
);
|
||||
List<MessageInfo> records = page.getRecords();
|
||||
MapProxy proxy = MapProxy.create(params);
|
||||
long pageNum = proxy.getLong(Constant.PAGE, 1L);
|
||||
long pageSize = proxy.getLong(Constant.LIMIT, 10L);
|
||||
PageHelper.startPage((int) pageNum, (int) pageSize);
|
||||
PageUtils page = PageUtils.page(new PageInfo<>(this.list(new QueryWrapper<MessageInfo>()
|
||||
.eq(userId != null, "user_id", userId)
|
||||
.eq(state != null, "state", state)
|
||||
.eq(type != null, "type", type).orderByDesc("create_at"))));
|
||||
|
||||
List<MessageInfo> records = (List<MessageInfo>) page.getList();
|
||||
for (MessageInfo messageInfo:records){
|
||||
if(messageInfo.getUserId()!=null){
|
||||
messageInfo.setUserEntity(userService.selectUserById(Long.parseLong(messageInfo.getUserId())));
|
||||
}
|
||||
}
|
||||
return new PageUtils(page);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user