package com.ads.business.api;

import com.ads.business.service.RoleService;
import com.ads.business.service.model.request.RoleUserListRequest;
import com.ads.common.data.JsonResult;
import com.dingtalk.api.response.OapiRoleListResponse;
import com.dingtalk.api.response.OapiRoleSimplelistResponse;
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/7 13:16
 * @Destription
 */

@Slf4j
@RestController
@RequestMapping("/api/role")
@Api(tags = "角色相关")
public class RoleController {

    @Resource
    private RoleService roleService;

    @PostMapping("/list")
    @ApiOperation("查询角色列表")
    public JsonResult<List<OapiRoleListResponse.OpenRole>> list(){
        return roleService.list();
    }

    @PostMapping("/users")
    @ApiOperation("查询对应角色下员工信息")
    public JsonResult<List<OapiRoleSimplelistResponse.OpenEmpSimple>> getDepartmentUsers(@RequestBody RoleUserListRequest request){
        return roleService.users(request);
    }
}
