package com.yida.data.system.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.system.EduDeptFunction;
import com.yida.data.system.service.EduDeptFunctionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统功能 Controller
 *
 * @author ZYJ
 * @date 2023/2/21
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "系统功能(无鉴权)")
@RequestMapping("/in/function")
public class InDeptFunctionController {

    private final EduDeptFunctionService eduDeptFunctionService;

    @ApiOperation("获取部门是否开通当前功能")
    @GetMapping("/getDeptFunction")
    public ResultBean<EduDeptFunction> getDeptFunction(String functionName, Long deptId) {
        return ResultBean.buildSuccess(eduDeptFunctionService.getOne(Wrappers.lambdaQuery(new EduDeptFunction())
                .eq(EduDeptFunction::getFunctionName, functionName)
                .eq(EduDeptFunction::getDeptId, deptId)
        ));
    }

}
