package com.openhis.web.document.controller;

import com.core.common.core.domain.R;
import com.openhis.web.document.appservice.IDocDefinitionAppService;
import com.openhis.web.document.appservice.IDocDefinitionOrganizationAppService;
import com.openhis.web.document.dto.DocDefinitionOrganizationDto;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 文书定义 - 科室分配  controller
 *
 * @author wanghaiming
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/document/definition/Organization")
@Slf4j
@AllArgsConstructor
public class DocDefinitionOrganizationController {

    private final IDocDefinitionOrganizationAppService docDefinitionOrganizationAppService;

    /**
     * 新增文书分配科室列表
     *
     * @param organizationDto
     * @return
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody DocDefinitionOrganizationDto organizationDto) {
        return docDefinitionOrganizationAppService.add(organizationDto);
    }

    /**
     * 删除文书分配科室列表
     *
     * @param definitionId
     * @param busNo
     * @return
     */
    @DeleteMapping("/delete")
    public R<?> delete(@RequestParam("definitionId") Long definitionId, @RequestParam("busNo") String busNo) {
        return docDefinitionOrganizationAppService.delete(definitionId, busNo);
    }

    /**
     * 查询文书定义科室列表
     *
     * @param definitionId
     * @param busNo
     * @return
     */
    @GetMapping("/getOrganizationIdlist")
    public R<?> getOrganizationIdlist(@RequestParam("definitionId") Long definitionId, @RequestParam("busNo") String busNo) {
        return docDefinitionOrganizationAppService.getOrganizationIdlist(definitionId, busNo);
    }
}
