Package com.mossle.msg.rs

Source Code of com.mossle.msg.rs.MsgResource

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;
    }
}
TOP

Related Classes of com.mossle.msg.rs.MsgResource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.