提交 a6d79f3c 编写于 作者: tangyaolong's avatar tangyaolong

完善代码

上级 7925886a
...@@ -41,6 +41,8 @@ import org.springframework.http.HttpEntity; ...@@ -41,6 +41,8 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -111,8 +113,6 @@ public class NotifyCoreService { ...@@ -111,8 +113,6 @@ public class NotifyCoreService {
createWorkRecordClient=new DefaultDingTalkClient(dingTalkCreateWorkRecordApi); createWorkRecordClient=new DefaultDingTalkClient(dingTalkCreateWorkRecordApi);
finishWorkRecordClient = new DefaultDingTalkClient(dingTalkFinishWorkRecordApi); finishWorkRecordClient = new DefaultDingTalkClient(dingTalkFinishWorkRecordApi);
} }
@Value("${ibiz.notify.pagesize:10}")
private int pageSize;
@Value("${ibiz.notify.expiretime:300000}") @Value("${ibiz.notify.expiretime:300000}")
private Long expireTime; private Long expireTime;
...@@ -658,10 +658,15 @@ public class NotifyCoreService { ...@@ -658,10 +658,15 @@ public class NotifyCoreService {
* 获取某个用户全量存储催办消息 * 获取某个用户全量存储催办消息
* @return * @return
*/ */
public Page<MsgBody> getBacklogAllContent(String toUserId) { public Page<MsgBody> getBacklogAllContent(String toUserId,int msgType) {
if(StringUtils.isEmpty(toUserId))
throw new BadRequestAlertException("无效用户ID","NotifyCoreService","getBacklogAllContent");
if(ObjectUtils.isEmpty(msgType))
throw new BadRequestAlertException("无效消息种类","NotifyCoreService","getBacklogAllContent");
MsgBodySearchContext context = new MsgBodySearchContext(); MsgBodySearchContext context = new MsgBodySearchContext();
context.setN_tousers_in(toUserId);
context.setSize(Integer.MAX_VALUE); context.setSize(Integer.MAX_VALUE);
context.setN_msgtype_eq(msgType);
context.setN_tousers_eq(toUserId); context.setN_tousers_eq(toUserId);
Page<MsgBody> result = msgBodyService.searchDefault(context); Page<MsgBody> result = msgBodyService.searchDefault(context);
return result; return result;
...@@ -671,13 +676,10 @@ public class NotifyCoreService { ...@@ -671,13 +676,10 @@ public class NotifyCoreService {
* 获取某个用户分页存储催办消息 * 获取某个用户分页存储催办消息
* @return * @return
*/ */
public Page<MsgBody> getBacklogPageContent(String toUserId) { public Page<MsgBody> getBacklogPageContent(MsgBodySearchContext context) {
MsgBodySearchContext context = new MsgBodySearchContext();
context.setSize(pageSize);
context.setN_tousers_eq(toUserId);
Page<MsgBody> result = msgBodyService.searchDefault(context); Page<MsgBody> result = msgBodyService.searchDefault(context);
msgMap.put(toUserId,result); msgMap.put(context.getN_tousers_eq(),result);
expireMap.put(toUserId,System.currentTimeMillis()) ; expireMap.put(context.getN_tousers_eq(),System.currentTimeMillis()) ;
return result; return result;
} }
...@@ -685,14 +687,21 @@ public class NotifyCoreService { ...@@ -685,14 +687,21 @@ public class NotifyCoreService {
* 缓存某个用户分页催办消息 * 缓存某个用户分页催办消息
* @return * @return
*/ */
public Page<MsgBody> getBacklogByPage(String toUserId) { public Page<MsgBody> getBacklogByPage(MsgBodySearchContext context) {
if(ObjectUtils.isEmpty(context))
throw new BadRequestAlertException("无效消息上下文","NotifyCoreService","getBacklogAllContent");
String toUserId = context.getN_tousers_eq();
if(!msgMap.containsKey(toUserId) && !expireMap.containsKey(toUserId)){ if(!msgMap.containsKey(toUserId) && !expireMap.containsKey(toUserId)){
return getBacklogPageContent(toUserId); return getBacklogPageContent(context);
}else { }else {
if(msgMap.get(toUserId).getSize() != context.getSize()){
return getBacklogPageContent(context);
}
if(System.currentTimeMillis() - expireMap.get(toUserId) <= expireTime){ if(System.currentTimeMillis() - expireMap.get(toUserId) <= expireTime){
return msgMap.get(toUserId); return msgMap.get(toUserId);
}else { }else {
return getBacklogPageContent(toUserId); return getBacklogPageContent(context);
} }
} }
} }
......
...@@ -6,6 +6,7 @@ import cn.ibizlab.core.extensions.domain.Template; ...@@ -6,6 +6,7 @@ import cn.ibizlab.core.extensions.domain.Template;
import cn.ibizlab.core.extensions.service.NotifyCoreService; import cn.ibizlab.core.extensions.service.NotifyCoreService;
import cn.ibizlab.core.notify.domain.MsgBody; import cn.ibizlab.core.notify.domain.MsgBody;
import cn.ibizlab.core.notify.filter.MsgBodySearchContext; import cn.ibizlab.core.notify.filter.MsgBodySearchContext;
import cn.ibizlab.core.notify.filter.MsgOpenAccessSearchContext;
import cn.ibizlab.core.notify.filter.MsgUserAccountSearchContext; import cn.ibizlab.core.notify.filter.MsgUserAccountSearchContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -78,9 +79,9 @@ public class NotifyCoreResource { ...@@ -78,9 +79,9 @@ public class NotifyCoreResource {
* @param * @param
* @return * @return
*/ */
@RequestMapping(method = RequestMethod.POST,value = "/notify/msgbody/getbacklogbypage/{tousers}") @RequestMapping(method = RequestMethod.POST,value = "/notify/msgbody/getallbacklogall")
public ResponseEntity<Page> getAllBacklogAll(@Validated @NotNull @PathVariable("tousers") String toUsers){ public ResponseEntity<Page> getAllBacklogAll(@RequestBody MsgBodyDTO dto){
Page page = notifyCoreService.getBacklogAllContent(toUsers); Page page = notifyCoreService.getBacklogAllContent(dto.getToUsers(),dto.getMsgType());
return ResponseEntity.status(HttpStatus.OK).body(new PageImpl(mapping.toDto(page.getContent()), page.getPageable(), page.getTotalElements())); return ResponseEntity.status(HttpStatus.OK).body(new PageImpl(mapping.toDto(page.getContent()), page.getPageable(), page.getTotalElements()));
} }
/** /**
...@@ -88,9 +89,9 @@ public class NotifyCoreResource { ...@@ -88,9 +89,9 @@ public class NotifyCoreResource {
* @param * @param
* @return * @return
*/ */
@RequestMapping(method = RequestMethod.POST,value = "/notify/msgbody/getbacklogbypage/{tousers}") @RequestMapping(method = RequestMethod.POST,value = "/notify/msgbody/getbacklogbypage")
public ResponseEntity<Page> getBacklogByPage(@Validated @NotNull @PathVariable("tousers") String toUsers) { public ResponseEntity<Page> getBacklogByPage(@RequestBody MsgBodySearchContext context) {
Page page = notifyCoreService.getBacklogByPage(toUsers); Page page = notifyCoreService.getBacklogByPage(context);
return ResponseEntity.status(HttpStatus.OK).body(new PageImpl(mapping.toDto(page.getContent()), page.getPageable(), page.getTotalElements())); return ResponseEntity.status(HttpStatus.OK).body(new PageImpl(mapping.toDto(page.getContent()), page.getPageable(), page.getTotalElements()));
} }
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册