package cd.casic.ci.api;


import cd.casic.ci.process.dto.req.group.GroupQueryReq;
import cd.casic.ci.process.dto.req.group.GroupReq;
import cd.casic.ci.process.dto.resp.group.GroupResp;
import cd.casic.framework.commons.pojo.CommonResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.validation.Valid;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName GroupController
 * @Author hopeli
 * @Date 2025/5/10 10:57
 * @Version 1.0
 */

@RestController
@RequestMapping("/group")
public class GroupController {

    @PostMapping(path="/createGroup")
    public CommonResult<String> createGroup(@RequestBody @NotNull @Valid GroupReq groupReq){

//        String pipelineAuthHostId = groupService.createGroup(group);

        String envId = "1";
        return CommonResult.success(envId);
    }


    @PostMapping(path="/deleteGroup")
    public CommonResult<Void> deleteGroup(@NotNull String groupId){

//        groupService.deleteGroup(groupId);

        return CommonResult.success();
    }

    @PostMapping(path="/findGroupList")
    public CommonResult<List<GroupResp>> findGroupList(@NotNull GroupQueryReq query){

//        List<Group> groupList = groupService.findGroupList(groupQuery);
        List<GroupResp> groupRespList = new ArrayList<>(0);
        GroupResp groupResp = new GroupResp();
        groupResp.setId("1");
        groupResp.setGroupName("test数据交互测试");
        groupRespList.add(groupResp);

        return CommonResult.success(groupRespList);
    }



    @PostMapping(path="/updateGroup")
    public CommonResult<Void> updateGroup(@RequestBody @NotNull @Valid GroupReq groupReq){

//        this.groupService.updateGroup(group);

        return CommonResult.success();
    }


    @PostMapping(path="/findGroupPage")
    public CommonResult<Page<GroupResp>> findGroupPage(@RequestBody @NotNull @Valid GroupQueryReq query){

//        Pagination<Group> groupPage = groupService.findGroupPage(groupQuery);
        Page<GroupResp> groupRespPage = new Page<>();
        List<GroupResp> groupRespList = new ArrayList<>(0);
        GroupResp groupResp = new GroupResp();
        groupResp.setId("1");
        groupResp.setGroupName("test数据交互测试");
        groupRespList.add(groupResp);
        groupRespPage.setRecords(groupRespList);
        return CommonResult.success(groupRespPage);
    }

}
