
package com.tmerclub.cloud.user.controller.app;

import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.user.service.UserScoreLogService;
import com.tmerclub.cloud.user.vo.UserScoreLogVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户积分记录
 *
 * @author YXF
 * @date 2020-12-08 10:16:53
 */
@RestController("appUserScoreLogController")
@RequestMapping("/userScoreLog")
@Tag(name = "app-用户积分记录")
public class UserScoreLogController {

    @Autowired
    private UserScoreLogService userScoreLogService;

    @GetMapping("/page")
    @Operation(summary = "获取用户积分记录列表", description = "根据用户id分页获取用户积分记录列表")
    @Parameters({
            @Parameter(name = "ioType", description = "出入类型 0:支出 1:收入"),
            @Parameter(name = "source", description = "积分类型 0.注册送积分1.购物 2.会员等级提升加积分 3.签到加积分 4.购物抵扣使用积分 5.积分过期 6.余额充值 7.系统更改积分 8.购物抵扣使用积分退还")
    })
    public ServerResponseEntity<PageVO<UserScoreLogVO>> page(@Valid PageDTO pageDTO,
                                                             @RequestParam(value = "ioType", required = false) Integer ioType,
                                                             @RequestParam(value = "source", required = false) Integer source) {
        PageVO<UserScoreLogVO> userScoreLogPage = userScoreLogService.pageByIoTypeAndSource(pageDTO, ioType, source);
        return ServerResponseEntity.success(userScoreLogPage);
    }

    @GetMapping("/scoreProdPage")
    @Operation(summary = "获取用户积分商品兑换记录列表", description = "分页获取用户积分商品兑换记录列表")
    public ServerResponseEntity<PageVO<UserScoreLogVO>> scoreProdPage(@Valid PageDTO pageDTO) {
        PageVO<UserScoreLogVO> userScoreLogPage = userScoreLogService.scoreProdPage(pageDTO);
        return ServerResponseEntity.success(userScoreLogPage);
    }
}
