package com.xueyi.modules.auth.controller;


import com.xueyi.common.core.constant.basic.SecurityConstants;
import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.web.controller.BaseApiController;
import com.xueyi.modules.auth.api.domain.vo.IntentionReqDto;
import com.xueyi.modules.auth.api.feign.RemoteSkillAuthService;
import com.xueyi.system.api.device.domain.vo.DeviceTenantSourceMergeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@RestController
@RequestMapping("/skill/api")
public class SkillAuthApiController extends BaseApiController {


    @Autowired
    private RemoteSkillAuthService skillAuthService;

    /**
     * @Author yangkai
     * @Description 技能权限验证，判断的意图对应的技能和传递的人员进行权限比对
     * @Date 2023/7/31
     * @Param IntentionReqDto对象
     * @return AjaxResult
     **/
    @RequestMapping(value = "/skillAuth", method = {RequestMethod.POST})
    @ResponseBody
    public AjaxResult auth(@Valid @RequestBody IntentionReqDto reqDto, HttpServletResponse response) {
        DeviceTenantSourceMergeVo vo = super.getDeviceTenantSourceMergeVo(reqDto.getDevId());

        return skillAuthService.skillAuth(reqDto, vo.getTenantId(), vo.getSourceSlave(), SecurityConstants.INNER);

    }


}
