package com.ads.business.api;

import com.ads.business.service.DepartmentService;
import com.ads.business.service.model.request.DepartmentListRequest;
import com.ads.business.service.model.request.DepartmentUserListRequest;
import com.ads.common.data.JsonResult;
import com.ads.common.dingTalk.domain.DepartmentDTO;
import com.ads.common.dingTalk.domain.UserDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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 javax.annotation.Resource;
import java.util.List;

/**
 * @Return
 * @Author hou
 * @Date 2021/9/3 16:16
 * @Destription
 */

@Slf4j
@RestController
@RequestMapping("/api/department")
@Api(tags = "部门信息相关")
public class DepartmentController {

    @Resource
    private DepartmentService departmentService;

    @PostMapping("/list")
    @ApiOperation("查询部门列表")
    public JsonResult<List<DepartmentDTO>> list(@RequestBody DepartmentListRequest request){
        return JsonResult.success(departmentService.list(request));
    }

    @PostMapping("/users")
    @ApiOperation("查询部门下员工信息")
    public JsonResult<List<UserDTO>> getDepartmentUsers(@RequestBody DepartmentUserListRequest request){
        return JsonResult.success(departmentService.getDepartmentUsers(request));
    }
}
