package com.ifish.action;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ifish.dto.ShopsLookUserDto;
import com.ifish.entity.PushList;
import com.ifish.hibernate.Pagination;
import com.ifish.service.PageListService;
import com.ifish.util.IfishUtil;

/**
 * @ClassName: PageListAction
 * @Description: TODO
 * @author ggw
 */
@Controller
@RequestMapping("/pageList")
public class PageListAction {

    @Autowired
    private PageListService pageListService;

    private static Logger log = LoggerFactory.getLogger(PageListAction.class);

    /**
     * 推送信息列表
     *
     * @param createDate
     * @param userId
     * @param firstResult
     * @param pageSize
     * @return
     */
    @RequestMapping("/pushListInf.do")
    @ResponseBody
    public Object pushListInf(Integer pushId, Integer userId, Integer firstResult, Integer pageSize) {
        try {
            if (firstResult == null) {
                firstResult = 0;
            }
            if (pageSize == null) {
                pageSize = 10;
            }
            Pagination<PushList> page = this.pageListService.getPushListByPage(pushId, userId, firstResult, pageSize);
            return IfishUtil.returnPageData(page);
        } catch (Exception e) {
            log.error("get pushListInf page information:error message:{}", e.toString());
        }
        return null;
    }

    /**
     * 看护工作台
     *
     * @param createDate
     * @param userId
     * @param firstResult
     * @param pageSize
     * @return
     */
    @RequestMapping("/lookList.do")
    @ResponseBody
    public Object lookList(Integer shopsUserId, Integer firstResult, Integer pageSize) {
        try {
            if (firstResult == null) {
                firstResult = 0;
            }
            if (pageSize == null) {
                pageSize = 10;
            }
            Pagination<ShopsLookUserDto> page = this.pageListService.getLookListByPage(shopsUserId, firstResult, pageSize);
            return IfishUtil.returnPageData(page);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("lookList:error message:{}", e.toString());
        }
        return null;
    }

}
