package com.yonge.cooleshow.admin.controller;

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.ActivityRegistrationVo;
import com.yonge.cooleshow.biz.dal.dto.search.ActivityRegistrationSearch;
import com.yonge.cooleshow.biz.dal.entity.ActivityRegistration;
import com.yonge.cooleshow.biz.dal.service.ActivityRegistrationService;

@RestController
@RequestMapping("/activityRegistration")
@Api(value = "活动报名表", tags = "活动报名表")
public class ActivityRegistrationController extends BaseController {

    @Autowired
    private ActivityRegistrationService activityRegistrationService;

	/**
     * 查询单条
     */
    @GetMapping("/detail/{id}")
    @ApiOperation(value = "详情", notes = "传入id")
    @PreAuthorize("@pcs.hasPermissions('activityRegistration/detail')")
    public HttpResponseResult<ActivityRegistrationVo> detail(@PathVariable("id") Long id) {
    	return succeed(activityRegistrationService.detail(id));
	}
    
    /**
     * 参与名单
     */
    @PostMapping("/page")
    @ApiOperation(value = "查询分页", notes = "传入activityRegistrationSearch")
    @PreAuthorize("@pcs.hasPermissions('activityRegistration/page')")
    public HttpResponseResult<PageInfo<ActivityRegistrationVo>> page(@Valid @RequestBody ActivityRegistrationSearch query) {
		IPage<ActivityRegistrationVo> pages = activityRegistrationService.selectPage(PageUtil.getPage(query), query);
        return succeed(PageUtil.pageInfo(pages));
	}

}