package com.ifish.action;

import com.ifish.dto.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ifish.dto.PageingDto;
import com.ifish.enums.ResultEnum;
import com.ifish.exception.IfishException;
import com.ifish.helper.UserActivityHelperI;
import com.ifish.service.UserActivityService;
import org.apache.ibatis.annotations.Param;

/**
 * 用户动态
 *
 * @author Administrator
 *
 */
@RestController
public class UserActivityAction {

    @Autowired
    private UserActivityService userActivityService;

    @Autowired
    private UserActivityHelperI userActivityHelperI;

    /**
     * 分页获取用户动态
     *
     * @param param
     * @param result
     * @return
     */
    @RequestMapping(value = "/userActivities", method = RequestMethod.GET)
    public PageingDto<?> getUserActivityByPage(Integer pageSize, Integer firstResult) {
        //参数校验
        if (firstResult < 0 || (pageSize < 1 || pageSize > 20)) {
            throw new IfishException(ResultEnum.error401);
        }
        return userActivityHelperI.getUserActivityByPage(pageSize, firstResult);
    }

    @RequestMapping(value = "/userActivitiesMaxCount", method = RequestMethod.GET)
    public JsonResult<?> getUserActivityMaxCount() {
        try {
            return userActivityHelperI.getUserActivityMaxCount();
        } catch (Exception e) {
            throw new IfishException(ResultEnum.fail101);
        }

    }
}
