package top.continew.admin.controller.business;

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.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.continew.admin.business.model.entity.TgUser;
import top.continew.admin.business.model.query.TgUserQuery;
import top.continew.admin.business.model.req.TgUserReq;
import top.continew.admin.business.service.ITgUserService;
import top.continew.starter.extension.crud.model.resp.BasePageResp;

import java.util.List;

@RestController()
@RequestMapping("/tgUser")
@AllArgsConstructor
@Tag(name = "tg用户管理 API")
public class TgUserController {
    private final ITgUserService userService;

    @RequestMapping("/getTgUserList")
    @Operation(summary = "获取tg用户列表", description = "获取tg用户列表")
    public BasePageResp<TgUser> getTgUserList(TgUserQuery query) {
        return userService.pageQuery(query);
    }

    @Operation(summary = "修改数据", description = "修改数据")
    @Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
    @PutMapping({"/{id}"})
    //@Validated({CrudValidationGroup.Update.class})
    public void update(@RequestBody TgUserReq req, @PathVariable("id") Long id) {
        this.userService.updateTgUserInfo(id, req);
    }

    @Operation(summary = "禁用账号", description = "禁用账号")
    @GetMapping("/disable/{ids}")
    @Parameter(name = "ids", description = "ids", example = "1,2,3,4", in = ParameterIn.PATH)
    public void disableTgUser(@PathVariable("ids") List<Long> ids) {
        userService.disableTgUserByIds(ids);
    }

    @Operation(summary = "获取团队成员列表", description = "获取团队成员列表")
    @GetMapping("/getMyTeamUserList/{id}")
    @Parameters({
            @Parameter(name = "id", description = "用户id", example = "10004", in = ParameterIn.PATH),
            @Parameter(name = "teamType", description = "团队类型", example = "A", in = ParameterIn.QUERY)
    })
    public List<TgUser> getMyTeamUserList(@PathVariable("id") Long id, @RequestParam("teamType") String teamType) {
        return userService.getMyTeamUserListByType(id, teamType);
    }
}
