package com.ruoyi.oa.controller;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.oa.domain.vo.FileUser;
import com.ruoyi.oa.domain.vo.UserFilesVo;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.oa.domain.vo.EmployeeFilesVo;
import com.ruoyi.oa.domain.bo.EmployeeFilesBo;
import com.ruoyi.oa.service.IEmployeeFilesService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文件档案管理
 *
 * @author hdka
 * @date 2025-03-08
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oa/files")
public class EmployeeFilesController extends BaseController {

    private final IEmployeeFilesService iEmployeeFilesService;

    /**
     * 查询文件档案管理列表
     */
    @GetMapping("/list")
    public TableDataInfo<FileUser> list(EmployeeFilesBo bo, PageQuery pageQuery) {
        return iEmployeeFilesService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取文件档案管理详细信息
     *
     * @param userId 主键
     */
    @GetMapping("/{userId}")
    public R<UserFilesVo> getInfo(@NotNull(message = "主键不能为空")
                                  @PathVariable("userId") Long userId) {
        return R.ok(iEmployeeFilesService.
                queryUserFilesVoByUserId(userId));
    }

    /**
     * 新增文件档案管理
     */
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody UserFilesVo filesVo) {
        return toAjax(iEmployeeFilesService.insertByBo(filesVo));
    }
}
