package com.yonge.cooleshow.admin.controller;

import com.yonge.cooleshow.biz.dal.vo.UserRewardVo;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yonge.toolset.base.page.PageInfo;
import com.yonge.toolset.mybatis.support.PageUtil;

import com.yonge.toolset.base.util.StringUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import com.yonge.cooleshow.biz.dal.vo.ActivityUserRewardVo;
import com.yonge.cooleshow.biz.dal.dto.search.ActivityUserRewardSearch;
import com.yonge.cooleshow.biz.dal.entity.ActivityUserReward;
import com.yonge.cooleshow.biz.dal.service.ActivityUserRewardService;

@RestController
@RequestMapping("/activityUserReward")
@Api(value = "活动用户获奖表", tags = "活动用户获奖表")
public class ActivityUserRewardController extends BaseController {

    @Autowired
    private ActivityUserRewardService activityUserRewardService;

	/**
     * 查询单条
     */
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "详情", notes = "传入id")
    @PreAuthorize("@pcs.hasPermissions('activityUserReward/detail')")
    public HttpResponseResult<ActivityUserRewardVo> detail(@PathVariable("id") Long id) {
    	return succeed(activityUserRewardService.detail(id));
	}
    
    /**
     * 查询分页
     */
    @PostMapping("/page")
    @ApiOperation(value = "查询分页", notes = "传入activityUserRewardSearch")
    @PreAuthorize("@pcs.hasPermissions('activityUserReward/page')")
    public HttpResponseResult<PageInfo<UserRewardVo>> page(@RequestBody @Valid ActivityUserRewardSearch query) {
		IPage<UserRewardVo> pages = activityUserRewardService.selectPage(PageUtil.getPage(query), query);
        return succeed(PageUtil.pageInfo(pages));
	}
}