
package com.lideeyunji.core.framework.controller;

import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
import com.lideeyunji.tool.framework.yunji.adapter.IlideeYunjiAdapter;
import com.lideeyunji.tool.framework.yunji.model.lideeYunjiDept;
import com.lideeyunji.tool.framework.yunji.model.lideeYunJiRole;
import com.lideeyunji.tool.framework.yunji.model.lideeYunJiUser;
import com.lideeyunji.tool.framework.yunji.model.LideeTenant;
import com.lideeyunji.tool.framework.yunji.params.lideeYunJiDeptParam;
import com.lideeyunji.tool.framework.yunji.params.lideeYunJiUserParam;
import com.lideeyunji.tool.framework.yunji.model.global.BaseWebResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "低代码框架-云玑框架接口")
@RestController
@AllArgsConstructor
@RequestMapping(lideeYunJiBaseConstant.REQUEST_URL_START + "/adapter")
public class AdapterController extends BaseController {

    private final IlideeYunjiAdapter lideeYunJiAdapter;

    @GetMapping("/tenant/list")
    @ApiOperationSupport(order = 1)
    @Operation(tags = "云玑适配器",summary = "获取租户列表")
    public BaseWebResult tenantList() {
        List<LideeTenant> tenantList = lideeYunJiAdapter.getTenantList();
        return BaseWebResult.success(tenantList);
    }

    @GetMapping("/dept/list")
    @ApiOperationSupport(order = 1)
    @Operation(tags = "云玑适配器",summary = "获取部门列表")
    public BaseWebResult deptList(lideeYunJiDeptParam param) {
        List<lideeYunjiDept> deptList = lideeYunJiAdapter.getDeptList(param);
        return BaseWebResult.success(deptList);
    }

    @GetMapping("/role/list")
    @ApiOperationSupport(order = 2)
    @Operation(tags = "云玑适配器",summary = "获取角色列表")
    public BaseWebResult roleList() {
        List<lideeYunJiRole> roleList = lideeYunJiAdapter.getRoleList();
        return BaseWebResult.success(roleList);
    }

    @PostMapping("/user/list")
    @ApiOperationSupport(order = 3)
    @Operation(tags = "云玑适配器",summary = "获取用户列表")
    public BaseWebResult userList(@RequestBody lideeYunJiUserParam param) {
        IPage<lideeYunJiUser> userPage =(IPage<lideeYunJiUser>) lideeYunJiAdapter.getUserPage(param.getPageNo(), param.getPageSize(), param);
        return BaseWebResult.success(userPage);
    }
}
