dev-discount
胡锐 2 years ago
commit 8b99b14929
  1. 79
      hai-cweb/src/main/java/com/cweb/controller/BsMsgController.java
  2. 17
      hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java

@ -23,10 +23,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author sum1dream
@ -49,9 +47,6 @@ public class BsMsgController {
@ApiOperation(value = "查询站内信列表")
public ResponseData getMsgByList(
@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "jumpType", required = false) Integer jumpType,
@RequestParam(value = "msgType", required = false) Integer msgType,
@RequestParam(value = "title", required = false) String title,
@RequestParam(value = "companyId", required = true) String companyId,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request
@ -61,17 +56,30 @@ public class BsMsgController {
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String, Object> map = new HashMap<>(5);
map.put("type", type);
map.put("jumpType", jumpType);
map.put("msgType", msgType);
map.put("title", title);
// 查询个人信息
Map<String, Object> mapUser = new HashMap<>();
mapUser.put("companyId" , companyId);
mapUser.put("msgType" , 1);
mapUser.put("type" , type);
mapUser.put("userId" , userInfoModel.getHighUser().getId());
mapUser.put("num" , 1000);
List<BsMsg> listUser = bsMsgService.queryMsgByList(mapUser);
// 查询全局信息
Map<String, Object> map = new HashMap<>();
map.put("companyId" , companyId);
map.put("type" , type);
map.put("msgType" , 2);
map.put("num" , 1000);
List<BsMsg> list = bsMsgService.queryMsgByList(map);
PageHelper.startPage(pageNum,pageSize);
list.addAll(listUser);
list = list.stream().sorted(Comparator.comparing(BsMsg::getCreateTime).reversed())
.collect(Collectors.toList());
List<BsMsg> list = bsMsgService.getMsgByList(map);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(list));
} catch (Exception e) {
@ -100,47 +108,4 @@ public class BsMsgController {
}
}
@RequestMapping(value = "/queryMsgByList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询站内信列表")
public ResponseData queryMsgByList(
@RequestParam(value = "companyId", required = false) Long companyId,
@RequestParam(value = "type", required = false) Long type,
HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String, Object> mapUser = new HashMap<>();
mapUser.put("companyId" , companyId);
mapUser.put("type" , type);
mapUser.put("userId" , userInfoModel.getHighUser().getId());
mapUser.put("msgType" , 1);
// 查询个人站内信
List<BsMsg> userMsg = bsMsgService.queryMsgByList(mapUser);
// 查询全局站内信
Map<String, Object> map = new HashMap<>();
map.put("companyId" , companyId);
map.put("type" , type);
map.put("msgType" , 2);
// 查询个人站内信
List<BsMsg> msgList = bsMsgService.queryMsgByList(map);
msgList.addAll(userMsg);
return ResponseMsgUtil.success(msgList);
} catch (Exception e) {
log.error("HighOrderController -> addOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@Api(value = "内容管理 内容发布")
@ -113,7 +114,7 @@ public class CmsContentController {
object.put("jumpType" , cmsContent.get(0).getJumpType());
object.put("jumpUrl" , cmsContent.get(0).getJumpUrl());
}
List<BsMsg> listUser = new ArrayList<>();
List<BsMsg> list = new ArrayList<>();
if (sessionObject != null) {
Map<String, Object> mapUser = new HashMap<>();
@ -121,20 +122,22 @@ public class CmsContentController {
mapUser.put("companyId" , companyId);
mapUser.put("msgType" , 1);
mapUser.put("userId" , userInfoModel.getHighUser().getId());
mapUser.put("num" , 3);
listUser = bsMsgService.queryMsgByList(mapUser);
mapUser.put("num" , 6);
list = bsMsgService.queryMsgByList(mapUser);
}
Map<String, Object> map = new HashMap<>();
if (list.size() == 0) {
map.put("companyId" , companyId);
map.put("msgType" , 2);
map.put("num" , 3);
List<BsMsg> list = bsMsgService.queryMsgByList(map);
list.addAll(listUser);
map.put("num" , 6);
list = bsMsgService.queryMsgByList(map);
}
list = list.stream().sorted(Comparator.comparing(BsMsg::getCreateTime).reversed())
.collect(Collectors.toList());
for (BsMsg bsMsg : list) {
bsMsg.setTimeData( DateUtil.timeDifference(bsMsg.getCreateTime(), new Date() ));
}

Loading…
Cancel
Save