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

import cn.hanghui.outapi.platform.common.controller.BaseController;
import cn.hanghui.outapi.platform.common.entity.rest.RestResult;
import cn.hanghui.outapi.platform.common.utils.EnumUtils;
import cn.hanghui.outapi.platform.tenant.entity.dto.account.AccountDto;
import cn.hanghui.outapi.platform.tenant.entity.dto.account.AccountSearch;
import cn.hanghui.outapi.platform.tenant.entity.dto.account.AccountVo;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceCollectConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceFaceConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceFuncConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceHardwareConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFacePushConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceResultConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceSystemConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceThirdConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.HhFaceUseConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.ModuleTypeEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.PushConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.SystemConfigEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.UseConfigEnum;
import cn.hanghui.outapi.platform.tenant.service.AccountService;
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 io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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;
import java.util.Map;

/**
 * @author shisl
 * @package cn.hanghui.outapi.platform.tenant.controller
 * @class AccountController
 * @date 2024/7/1 下午4:28
 * @description
 */
@Slf4j
@Api(tags = "账号授权管理")
@RestController
@RequestMapping(value = "/api/v1/auth/account")
public class AccountController extends BaseController {

    @Autowired
    private AccountService accountService;

    @ApiOperation(value = "添加或编辑授权账号")
    @PostMapping("/add")
    @ApiOperationSupport(order = 1)
    public RestResult<Boolean> add(@RequestBody AccountDto dto) {
        return accountService.add(dto);
    }

    @ApiOperation(value = "删除授权账号")
    @PostMapping("/del/{accountId}")
    public RestResult<Boolean> del(@PathVariable(value = "accountId") @ApiParam(value = "accountId", required = true) Long accountId) {
        return accountService.del(accountId);
    }

    @ApiOperation(value = "授权账号列表（分页）")
    @PostMapping("/page")
    @ApiOperationSupport(order = 3)
    public RestResult<IPage<AccountVo>> page(@RequestBody AccountSearch dto) {
        return accountService.page(dto);
    }

    @ApiOperation(value = "授权账号列表")
    @PostMapping("/list")
    @ApiOperationSupport(order = 4)
    public RestResult<List<AccountVo>> list() {
        return accountService.list();
    }

    @ApiOperation(value = "获取登录账号信息")
    @PostMapping("/query")
    @ApiOperationSupport(order = 4)
    public RestResult<AccountVo> query() {
        return accountService.query(getAccount());
    }

    @ApiOperation(value = "查询授权模块枚举列表")
    @PostMapping("/module/type/list")
    public RestResult<List<Map<Integer, String>>> queryModuleTypeList() {
        return RestResult.ok(EnumUtils.enumToListMap(ModuleTypeEnum.class));
    }

    @ApiOperation(value = "查询系统配置枚举列表")
    @PostMapping("/system/config/list")
    public RestResult<List<Map<String, String>>> querySystemConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(SystemConfigEnum.class));
    }

    @ApiOperation(value = "查询使用配置枚举列表")
    @PostMapping("/use/config/list")
    public RestResult<List<Map<String, String>>> queryUseConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(UseConfigEnum.class));
    }


    @ApiOperation(value = "查询推送配置枚举列表")
    @PostMapping("/push/config/list")
    public RestResult<List<Map<String, String>>> queryPushConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(PushConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace支付宝人脸采集配置枚举列表")
    @PostMapping("/hhface/face/config/list")
    public RestResult<List<Map<String, String>>> queryHhfaceFaceConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceFaceConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace采集配置枚举列表")
    @PostMapping("/hhface/collect/config/list")
    public RestResult<List<Map<String, String>>> queryHhfaceCollectConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceCollectConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace功能配置枚举列表")
    @PostMapping("/hhface/func/config/list")
    public RestResult<List<Map<String, String>>> queryHhfaceFuncConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceFuncConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace硬件配置枚举列表")
    @PostMapping("/hhface/hardware/config/list")
    public RestResult<List<Map<String, String>>> queryHhfaceHardwareConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceHardwareConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace推送配置枚举列表")
    @PostMapping("/hhface/push/config/list")
    public RestResult<List<Map<String, String>>> queryHhfacePushConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFacePushConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace结果页配置枚举列表")
    @PostMapping("/hhface/result/config/list")
    public RestResult<List<Map<String, String>>> queryHhfaceResultConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceResultConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace系统配置枚举列表")
    @PostMapping("/hhface/system/config/list")
    public RestResult<List<Map<String, String>>> queryHhfaceSystemConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceSystemConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace三方接口配置枚举列表")
    @PostMapping("/hhface/third/config/list")
    public RestResult<List<Map<String, String>>> queryHhFaceThirdConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceThirdConfigEnum.class));
    }

    @ApiOperation(value = "查询HHFace使用配置枚举列表")
    @PostMapping("/hhface/use/config/list")
    public RestResult<List<Map<String, String>>> queryHhFaceUseConfigList() {
        return RestResult.ok(EnumUtils.enumToListMap(HhFaceUseConfigEnum.class));
    }

}
