package com.YuyeTech.TPlat.game.userData.controller;

import cn.hutool.core.date.DateUtil;
import com.YuyeTech.TPlat.annotation.Decrypt;
import com.YuyeTech.TPlat.annotation.Encrypt;
import com.YuyeTech.TPlat.common.controller.*;
import com.YuyeTech.TPlat.common.pojo.PageInfo;
import com.YuyeTech.TPlat.common.pojo.Result;
import com.YuyeTech.TPlat.enums.ResultEnum;
import com.YuyeTech.TPlat.game.gameInfo.vo.GamePictureSimpleVo;
import com.YuyeTech.TPlat.game.gameInfo.vo.GamePictureVo;
import com.YuyeTech.TPlat.game.imageInfo.vo.PicturesAndGameSimpleVo;
import com.YuyeTech.TPlat.game.imageInfo.vo.PicturesVo;
import com.YuyeTech.TPlat.game.userData.pojo.UserData;
import com.YuyeTech.TPlat.game.userData.vo.UserDataSimpleVo;
import com.YuyeTech.TPlat.game.userData.vo.UserDataVo;
import com.YuyeTech.TPlat.game.userData.service.UserDataService;
import com.YuyeTech.TPlat.utils.CopyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/tPlat/userData/")
public class UserDataController extends CommonController<UserDataVo, UserData, String> {
    @Autowired
    private UserDataService userDataService;

    /**
     * 获取hitCount ，不是同一天，重置信息
     * @param userId
     * @return
     */
    @PostMapping("getHitCount")
    @Encrypt
    public Result<?> getUserDataByUserId(@RequestParam(value = "userId") String userId) {
        try {
            return Result.of(userDataService.getHitCount(userId));
        }catch (Exception e){
            return Result.of(null,false,ResultEnum.USER_DATA_DOES_NOT_EXIST);
        }

    }

    /**
     * 保存hitCount ,如果保存时候，不是同一天，从当前数据算起
     * @param userId
     * @return
     */
    @PostMapping("uploadHitCount")
    @Encrypt
    public Result<?> uploadUserDataByUserId(@RequestParam("userId") String userId,
                                                         @RequestParam("hitCount") Integer hitCount)
    {
        try {
            return Result.of(userDataService.uploadHitCount(userId,hitCount));
        }catch (Exception e){
            return Result.of(null,false,ResultEnum.USER_DATA_DOES_NOT_EXIST);
        }
    }
}
