package cn.hanghui.outapi.platform.tenant.controller;

import cn.hanghui.outapi.platform.common.config.log.Log;
import cn.hanghui.outapi.platform.common.controller.BaseController;
import cn.hanghui.outapi.platform.common.entity.po.Account;
import cn.hanghui.outapi.platform.common.entity.rest.RestResult;
import cn.hanghui.outapi.platform.tenant.entity.config.fkj.device.template.FkjDeviceVo;
import cn.hanghui.outapi.platform.tenant.entity.dto.TenantVo;
import cn.hanghui.outapi.platform.tenant.entity.dto.UserLibDto;
import cn.hanghui.outapi.platform.tenant.entity.dto.ampe.HhFaceDeviceDto;
import cn.hanghui.outapi.platform.tenant.entity.dto.auth.fkj.FkjAuthDeviceDto;
import cn.hanghui.outapi.platform.tenant.entity.dto.auth.fkj.FkjAuthDeviceSearch;
import cn.hanghui.outapi.platform.tenant.entity.enums.AuthModuleTypeEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.BusinessTypeEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.LogTagEnum;
import cn.hanghui.outapi.platform.tenant.service.FkjDeviceService;
import cn.hanghui.outapi.platform.tenant.service.SceneService;
import cn.hanghui.outapi.platform.tenant.service.TenantService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;

@Slf4j
@Api(tags = "授权账号的访客机设备管理")
@RestController
@RequestMapping(value = "/api/v1/auth/fkj")
@RequiredArgsConstructor(onConstructor_ = @__(@Autowired))
public class AuthFkjController extends BaseController {


    private final FkjDeviceService fkjDeviceService;


    @ApiOperation(value = "获取FKJ设备列表（分页）")
    @PostMapping("/device/page")
    @ApiOperationSupport(order = 1)
    public RestResult<IPage<FkjDeviceVo>> authPage(@RequestBody FkjAuthDeviceSearch dto) {
        Account account = getAccount();
        return fkjDeviceService.authPage(dto, account);
    }

    @ApiOperation(value = "修改访客机设备配置信息")
    @PostMapping("/device/update")
    @ApiOperationSupport(order = 2)
    @Log(tag = LogTagEnum.FKJ,title = "修改访客机设备配置信息",businessTypeEnum = BusinessTypeEnum.UPDATE)
    public RestResult<Boolean> update(@RequestBody FkjAuthDeviceDto dto) {
        Account account = getAccount();
        return fkjDeviceService.update(dto, account);
    }
}
