package com.mossle.msg.rs;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import com.mossle.core.mapper.JsonMapper;
import com.mossle.core.util.BaseDTO;
import com.mossle.core.util.StringUtils;
import com.mossle.msg.domain.MsgInfo;
import com.mossle.msg.manager.MsgInfoManager;
import com.mossle.security.util.SpringSecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
@Path("msg")
public class MsgResource {
private static Logger logger = LoggerFactory.getLogger(MsgResource.class);
private MsgInfoManager msgInfoManager;
private JsonMapper jsonMapper = new JsonMapper();
@GET
@Path("unreadCount")
@Produces(MediaType.APPLICATION_JSON)
public BaseDTO unreadCount() {
String userId = SpringSecurityUtils.getCurrentUserId();
Integer count = msgInfoManager.getCount(
"select count(*) from MsgInfo where receiverId=? and status=0",
userId);
BaseDTO result = new BaseDTO();
result.setData(count);
return result;
}
// ~ ======================================================================
@Resource
public void setMsgInfoManager(MsgInfoManager msgInfoManager) {
this.msgInfoManager = msgInfoManager;
}
}