package org.jeecg.modules.xcx.team.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.modules.xcx.team.req.ApplyTeamReq;
import org.jeecg.modules.xcx.team.service.ITeamService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Api(tags = "团队接口")
@Slf4j
@RestController
@RequestMapping("/team")
public class TeamController {

    @Resource
    private ITeamService teamService;


    @ApiOperation(value = "获取团队")
    @GetMapping("/list")
    public Result<?> getTeam(){
        return teamService.getTeam();
    }


    @ApiOperation(value = "申请加入团队")
    @PostMapping("/apply")
    public Result<?> applyTeam(HttpServletRequest request , ApplyTeamReq applyTeamReq){
        applyTeamReq.setToken(TokenUtils.getTokenByRequest(request));
        return teamService.applyTeam(applyTeamReq);
    }

}
