package com.ningdatech.pmapi.organization.controller;


import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.organization.manage.OrganizationManage;
import com.ningdatech.pmapi.organization.model.po.ReqOrganizationListPO;
import com.ningdatech.pmapi.organization.model.vo.OrganizationTreeVO;
import com.ningdatech.pmapi.organization.model.vo.ResOrganizationListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Lierbao
 * @since 2023-02-09
 */

@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@Api(value = "DingOrganizationController", tags = "单位管理")
@RequestMapping("/api/v1/organization")
public class DingOrganizationController {

    private final OrganizationManage organizationManage;

    @ApiModelProperty("单位列表筛选")
    @PostMapping("/list")
    public PageVo<ResOrganizationListVO> organizationList(@Valid @RequestBody ReqOrganizationListPO reqOrganizationListPO) {
        return organizationManage.organizationList(reqOrganizationListPO);
    }

    @PostMapping("/get-child-list")
    @ApiOperation("获取组织架构的树状结构（单位筛选列表）")
    public List<OrganizationTreeVO> getChildOrganizationList(@RequestParam(value = "parentCode", required = false) String parentCode) {
        return organizationManage.getChildOrganizationList(parentCode);
    }

}
