Commit 9da18c5e authored by jiaorz's avatar jiaorz

后台添加IM接口

parent b737e663
package com.xxfc.platform.im.dto;
import lombok.Data;
@Data
public class MsgQueryDto {
private Integer page;
private Integer limit;
private Integer source;
private Long startTime;
private Long endTime;
private Integer praise;
private Integer comment;
private String username;
private Integer type;
}
...@@ -5,6 +5,8 @@ import cn.hutool.core.bean.BeanUtil; ...@@ -5,6 +5,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.admin.entity.AppUserLogin;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.ImiVo; import com.github.wxiaoqi.security.admin.vo.ImiVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
...@@ -13,6 +15,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO; ...@@ -13,6 +15,7 @@ import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult; import com.mongodb.client.result.UpdateResult;
import com.xxfc.platform.im.dto.CommentVo; import com.xxfc.platform.im.dto.CommentVo;
import com.xxfc.platform.im.dto.MsgQueryDto;
import com.xxfc.platform.im.dto.PraiseVo; import com.xxfc.platform.im.dto.PraiseVo;
import com.xxfc.platform.im.dto.QuestionParamDto; import com.xxfc.platform.im.dto.QuestionParamDto;
import com.xxfc.platform.im.model.*; import com.xxfc.platform.im.model.*;
...@@ -53,6 +56,8 @@ public class MsgBiz { ...@@ -53,6 +56,8 @@ public class MsgBiz {
@Autowired @Autowired
ThirdFeign thirdFeign; ThirdFeign thirdFeign;
@Autowired
UserFeign userFeign;
/** /**
* 获取消息列表 * 获取消息列表
* *
...@@ -339,6 +344,67 @@ public class MsgBiz { ...@@ -339,6 +344,67 @@ public class MsgBiz {
* 后台管理接口 * 后台管理接口
*/ */
public ObjectRestResponse getMsgList(MsgQueryDto msgQueryDto){
//获取所有朋友圈
Integer page = msgQueryDto.getPage() == null ? 1 : msgQueryDto.getPage();
Integer limit = msgQueryDto.getLimit() == null ? 10 : msgQueryDto.getLimit();
Pageable pageable = PageRequest.of(--page, limit);
Query query = null;
List<Msg> msgList = null;
if (msgQueryDto.getType() != null) {
query = new Query(Criteria.where("body.type").is(msgQueryDto.getType()));
//评论数
if (msgQueryDto.getComment() != null) {
query.addCriteria(Criteria.where("count.comment").gte(msgQueryDto.getComment()));
}
//点赞数
if (msgQueryDto.getPraise() != null) {
query.addCriteria(Criteria.where("count.praise").gte(msgQueryDto.getPraise()));
}
//来源
if (msgQueryDto.getSource() != null) {
if (msgQueryDto.getSource() == 1) {
query.addCriteria(Criteria.where("source").is(msgQueryDto.getSource()));
} else {
query.addCriteria(Criteria.where("source").is(msgQueryDto.getSource()).orOperator(Criteria.where("source").is(null)));
}
}
//下单时间
if (msgQueryDto.getStartTime() != null) {
query.addCriteria(Criteria.where("body.time").gte(msgQueryDto.getStartTime()).orOperator(Criteria.where("body.time").lte(msgQueryDto.getEndTime())));
}
//用户名
if (StringUtils.isNotBlank(msgQueryDto.getUsername())) {
AppUserLogin appUserLogin = userFeign.one(msgQueryDto.getUsername());
if (appUserLogin != null) {
query.addCriteria(Criteria.where("userId").is(appUserLogin.getImUserid()));
}
}
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), null);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(replaceMsgResult(msgList));
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
return ObjectRestResponse.succ(goodPageInfo);
} else {
List<Integer> ids = new ArrayList<>();
ids.add(2);
ids.add(4);
query = new Query(Criteria.where("body.type").in(ids));
int totalSize = mongoTemplate.find(query, Msg.class, "s_msg").size();
query.with(pageable);
query.with(new Sort(Sort.Direction.DESC, "time"));
msgList = fetchAndAttach(mongoTemplate.find(query, Msg.class, "s_msg"), null);
PageInfo<MsgVo> goodPageInfo = new PageInfo<>(replaceMsgResult(msgList));
goodPageInfo.setPageSize(totalSize % limit == 0 ? totalSize / limit : totalSize / limit + 1);
return ObjectRestResponse.succ(goodPageInfo);
}
}
/** /**
* 新增消息接口 * 新增消息接口
* @param param * @param param
......
...@@ -2,6 +2,7 @@ package com.xxfc.platform.im.rest; ...@@ -2,6 +2,7 @@ package com.xxfc.platform.im.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.im.biz.MsgBiz; import com.xxfc.platform.im.biz.MsgBiz;
import com.xxfc.platform.im.dto.MsgQueryDto;
import com.xxfc.platform.im.model.AddMsgParam; import com.xxfc.platform.im.model.AddMsgParam;
import com.xxfc.platform.im.model.Msg; import com.xxfc.platform.im.model.Msg;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -50,4 +51,9 @@ public class MsgController { ...@@ -50,4 +51,9 @@ public class MsgController {
public ObjectRestResponse updateMsg(@RequestBody Msg msg) { public ObjectRestResponse updateMsg(@RequestBody Msg msg) {
return msgBiz.update(msg); return msgBiz.update(msg);
} }
@PostMapping(value = "/bg/app/unauth/list")
public ObjectRestResponse getMsgList(@RequestBody MsgQueryDto msgQueryDto) {
return msgBiz.getMsgList(msgQueryDto);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment