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.SysOperLogSearch;
import cn.hanghui.outapi.platform.tenant.entity.dto.SysOperLogVo;
import cn.hanghui.outapi.platform.tenant.entity.dto.blacklist.*;
import cn.hanghui.outapi.platform.tenant.entity.enums.BusinessTypeEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.LogTagEnum;
import cn.hanghui.outapi.platform.tenant.entity.enums.ModuleTypeEnum;
import cn.hanghui.outapi.platform.tenant.service.SysOperLogService;
import cn.hanghui.outapi.platform.tenant.service.UserBlacklistService;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Slf4j
@Api(tags = "操作日志")
@RestController
@RequestMapping(value = "/api/oper")
@Validated
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SysOperLogController extends BaseController {

    private final SysOperLogService sysOperLogService;


    @ApiOperation(value = "所属模块枚举列表")
    @PostMapping("/tag/list")
    @ApiOperationSupport(order = 1)
    public RestResult<List<Map<Integer, String>>> logTagEnumList() {
        return RestResult.ok(EnumUtils.enumToListMap(LogTagEnum.class));
    }
    @ApiOperation(value = "业务类型枚举列表")
    @PostMapping("/Business/type/list")
    @ApiOperationSupport(order = 2)
    public RestResult<List<Map<Integer, String>>> businessTypeEnumList() {
        return RestResult.ok(EnumUtils.enumToListMap(BusinessTypeEnum.class));
    }

    @ApiOperation(value = "操作记录（分页）")
    @PostMapping("/page")
    @ApiOperationSupport(order = 20)
    public RestResult<IPage<SysOperLogVo>> page(@RequestBody SysOperLogSearch dto) {
        return sysOperLogService.page(dto);
    }

}
