package com.td.Dawa.game.complayerbackpack.controller;

import com.td.Dawa.annotation.Encrypt;
import com.td.Dawa.common.controller.*;
import com.td.Dawa.common.pojo.PageInfo;
import com.td.Dawa.common.pojo.Result;
import com.td.Dawa.config.enums.GameEnum;
import com.td.Dawa.config.enums.ResultEnum;
import com.td.Dawa.game.comcharacters.vo.ComCharactersVo;
import com.td.Dawa.game.complayerbackpack.pojo.ComPlayerBackpack;
import com.td.Dawa.game.complayerbackpack.vo.ComPlayerBackpackClientVo;
import com.td.Dawa.game.complayerbackpack.vo.ComPlayerBackpackSimpleVo;
import com.td.Dawa.game.complayerbackpack.vo.ComPlayerBackpackVo;
import com.td.Dawa.game.complayerbackpack.service.ComPlayerBackpackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/game/comPlayerBackpack/")
public class ComPlayerBackpackController extends CommonController<ComPlayerBackpackVo, ComPlayerBackpack, String> {
    @Autowired
    private ComPlayerBackpackService comPlayerBackpackService;


    @PostMapping("getByTag")
    @Encrypt
    public Result<?> getByTag(@RequestParam(value = "userId") String userId,
                              @RequestParam(value = "tag") Integer tag,
                              @RequestParam(value = "page",defaultValue = "1") Integer page,
                              @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) {
        try {
            ComPlayerBackpackVo vo = new ComPlayerBackpackVo();
            vo.setUserId(userId);
            if(!tag.equals(0)){
                vo.setItemTag(tag);
            }
            vo.setPage(page);
            vo.setRows(pageSize);
            vo.setSidx("desc");
            vo.setSord("createTime");
            PageInfo pageInfo = comPlayerBackpackService.getPageAndProp(vo);
            return Result.of(pageInfo);
        } catch (Exception e) {
            return Result.of(null, false, ResultEnum.PLAYER_BACKPACK_ERROR);
        }

    }
}
