package com.yonge.cooleshow.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.yonge.cooleshow.biz.dal.support.PageUtil;
import com.yonge.cooleshow.common.controller.BaseController;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.toolset.mybatis.page.PageInfo;
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 com.yonge.cooleshow.biz.dal.vo.UserAccountRecordVo;
import com.yonge.cooleshow.biz.dal.dto.search.UserAccountRecordSearch;
import com.yonge.cooleshow.biz.dal.service.UserAccountRecordService;

@RestController
@RequestMapping("/userAccountRecord")
@Api(value = "用户账户流水表", tags = "用户账户流水表")
public class UserAccountRecordController extends BaseController {

    @Autowired
    private UserAccountRecordService userAccountRecordService;

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

}