package com.xindazhou.user.controller.app.point;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.framework.common.pojo.PageParam;
import com.xindazhou.framework.common.pojo.PageResult;
import com.xindazhou.framework.common.util.object.BeanUtils;
import com.xindazhou.user.controller.app.point.vo.AppMemberPointRecordPageReqVO;
import com.xindazhou.user.controller.app.point.vo.AppMemberPointRecordRespVO;
import com.xindazhou.user.convert.point.MemberPointRecordConvert;
import com.xindazhou.user.dal.dataobject.point.MemberPointRecordDO;
import com.xindazhou.user.service.point.MemberPointRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import static com.xindazhou.framework.common.pojo.CommonResult.success;
import static com.xindazhou.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

@Tag(name = "用户 App - 签到记录")
@RestController
@RequestMapping("/member/point/record")
@Validated
public class AppMemberPointRecordController {

    @Resource
    private MemberPointRecordService pointRecordService;

    @GetMapping("/page")
    @Operation(summary = "获得用户积分记录分页")
    public CommonResult<PageResult<AppMemberPointRecordRespVO>> getPointRecordPage(
            @Valid AppMemberPointRecordPageReqVO pageReqVO) {
        PageResult<MemberPointRecordDO> pageResult = pointRecordService.getPointRecordPage(getLoginUserId(), pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppMemberPointRecordRespVO.class));
    }

}
