package com.lanyuanxiaoyao.service.ai.knowledge.controller;

import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
import com.lanyuanxiaoyao.service.ai.knowledge.service.GroupService;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 lanyuanxiaoyao
 * @version 20250528
 */
@RestController
@RequestMapping("group")
public class GroupController {
  private static final Logger logger = LoggerFactory.getLogger(GroupController.class);

  private final GroupService groupService;

  public GroupController(GroupService groupService) {
    this.groupService = groupService;
  }

  @GetMapping("list")
  public AmisResponse<?> list(@RequestParam("knowledge_id") Long knowledgeId) {
    return AmisResponse.responseCrudData(groupService.list(knowledgeId));
  }

  @GetMapping("delete")
  public AmisResponse<?> delete(@RequestParam("id") Long id) throws ExecutionException, InterruptedException {
    groupService.remove(id);
    return AmisResponse.responseSuccess();
  }
}
