package com.qxueyou.scc.controller;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.alibaba.druid.util.StringUtils;
|
import com.qxueyou.scc.base.model.Pager;
|
import com.qxueyou.scc.base.model.Result;
|
import com.qxueyou.scc.base.util.CollectionUtils;
|
import com.qxueyou.scc.base.util.QBeanUtils;
|
import com.qxueyou.scc.msg.model.MsgInfo;
|
import com.qxueyou.scc.msg.service.IMsgInfoService;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
|
@Api(tags="ÏûÏ¢¹ÜÀí½Ó¿Ú")
|
@Controller
|
@CrossOrigin(origins="*",maxAge=3600)
|
@RequestMapping(value = "/msg/msg/")
|
public class MsgInfoController {
|
|
// ·ÖÒ³²éѯÖУ¬Ä¬ÈϼǼÌõÊýºÍÒ³Êý
|
private static final int DEFAULT_PAGE_SIZE = 10;
|
private static final int DEFAULT_PAGE_NUM = 1;
|
|
@Autowired
|
IMsgInfoService msgInfoService;
|
|
/**
|
* ÏûÏ¢Áбí
|
*/
|
@ApiOperation(value = "»ñÈ¡ÏûÏ¢Áбí")
|
@RequestMapping(value = "list", method = RequestMethod.GET)
|
public @ResponseBody Result list(Short type,Integer pageSize,Integer pageNum) {
|
pageSize = pageSize != null && pageSize > 0 ? pageSize : DEFAULT_PAGE_SIZE;
|
pageNum = pageNum != null && pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM;
|
|
//ÏûÏ¢ÊýÁ¿
|
int totalCount = msgInfoService.listCount(type);
|
Pager pager = new Pager(pageSize,pageNum);
|
pager.setTotalCount(totalCount);
|
|
List<MsgInfo> list = msgInfoService.list(type,pageSize,pageNum);
|
|
List<Map<String, Object>> listResult =QBeanUtils.listBean2ListMap(list,
|
CollectionUtils.newStringMap("msgId", "msgId", "type", "type", "content", "content",
|
"readFlag","readFlag","createTime", "createTime"));
|
|
return new Result(true,"",CollectionUtils.newObjectMap("msgList",listResult,"page",pager));
|
}
|
|
/**
|
* ɾ³ýÏûÏ¢
|
* @param msgIds
|
* @return
|
*/
|
@ApiOperation(value = "ɾ³ýÏûÏ¢")
|
@RequestMapping(value = "delete", method = RequestMethod.GET)
|
public @ResponseBody Result deleteUserMsg(String msgIds){
|
if(StringUtils.isEmpty(msgIds)){
|
return new Result(false,"²ÎÊý´íÎó£¡");
|
}
|
|
return this.msgInfoService.deleteUserMsg(msgIds.split(","));
|
}
|
|
/**
|
* Çå¿Õ¸öÈËÏûÏ¢
|
*
|
* @return
|
*/
|
@ApiOperation(value = "Çå¿ÕÏûÏ¢")
|
@RequestMapping(value = "clear", method = RequestMethod.GET)
|
public @ResponseBody Result deleteAllUserMsg(Short type){
|
return this.msgInfoService.deleteAllUserMsg(type);
|
}
|
|
/**
|
* ÐÞ¸ÄÒѶÁ±ê־λ
|
* @param msgId
|
* @return
|
*/
|
@ApiOperation(value = "¸üÐÂΪÒѶÁ")
|
@RequestMapping(value = "read", method = RequestMethod.GET)
|
public @ResponseBody Result updateReadFlag(String msgIds){
|
return this.msgInfoService.updateReadStatus(msgIds.split(","));
|
}
|
|
/**
|
* È«²¿ÒѶÁ
|
* @param msgId
|
* @return
|
*/
|
@ApiOperation(value = "È«²¿¸üÐÂΪÒѶÁ")
|
@RequestMapping(value = "readall", method = RequestMethod.GET)
|
public @ResponseBody Result updateAllUserReadFlag(Short type){
|
return this.msgInfoService.updateUserAllReadStatus(type);
|
}
|
|
|
/**
|
* ×î½üµÄÌáÐÑÏûÏ¢
|
* @param msgId
|
* @return
|
*/
|
@ApiOperation(value = "×î½üµÄÒ»ÌõÌáÐÑÐÅÏ¢")
|
@RequestMapping(value = "last", method = RequestMethod.GET)
|
public @ResponseBody Result getLatest(){
|
return new Result(true,"",this.msgInfoService.readLastRemindMsg());
|
}
|
|
|
/**
|
* ×î½üµÄÌáÐÑÏûÏ¢
|
* @param msgId
|
* @return
|
*/
|
@ApiOperation(value = "°´ÀàÐÍ»ñȡδ¶ÁÏûÏ¢µÄÊýÁ¿")
|
@RequestMapping(value = "count", method = RequestMethod.GET)
|
public @ResponseBody Result queryUnReadMsgCountByType(){
|
return new Result(true,"",this.msgInfoService.queryUnReadMsgCountByType());
|
}
|
|
/**
|
* ²éѯδ¶ÁÏûÏ¢×ÜÊý
|
* @param msgId
|
* @return
|
*/
|
@ApiOperation(value = "²éѯÓû§Î´¶ÁÏûÏ¢×ÜÊý")
|
@RequestMapping(value = "totalcount", method = RequestMethod.GET)
|
public @ResponseBody Result queryUnReadTotalCount(){
|
return new Result(true,"",CollectionUtils.newObjectMap("totalCount",this.msgInfoService.queryUnReadTotalCount()));
|
}
|
|
}
|