package com.retdata.yaoyibi.web;

import com.retdata.yaoyibi.domain.*;
import com.retdata.yaoyibi.service.CsoSysUserService;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cso-sys-users")
public class CsoSysUserController {

    private final CsoSysUserService csoSysUserService;

    public CsoSysUserController(CsoSysUserService csoSysUserService) {
        this.csoSysUserService = csoSysUserService;
    }

    @GetMapping
    public Page<CsoSysUserSearchDto> search(@ParameterObject CsoSysUserSearchParams searchParams,
                                            @ParameterObject Pageable pageable) {
        return csoSysUserService.search(searchParams, pageable);
    }

    @GetMapping("/{userId}")
    public CsoSysUserDetailDto getDetailById(@PathVariable("userId") Integer userId) {
        return csoSysUserService.getDetailById(userId);
    }

    @GetMapping("/depts")
    public List<CsoSysDeptSummary> listDeptSummary() {
        return csoSysUserService.listDeptSummary();
    }

    @GetMapping("/drug-ents")
    public List<WmDaDrugEnt> listDrugEnt() {
        return csoSysUserService.listDrugEnt();
    }

}
