package com.dayou.controller;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.controller.BaseController;
import com.dayou.service.IUserArchiveService;
import com.dayou.entity.UserArchive;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;
import com.dayou.utils.ConvertUtil;
import com.dayou.utils.HttpKit;
import com.dayou.exception.ErrorCode;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.http.MediaType;
import org.springframework.web.multipart.MultipartFile;
/**
 * 员工档案
 *
 * @author wucl
 * @since 2024-09-02
 */
@RestController
@RequestMapping("userArchive")
@Slf4j
public class UserArchiveController extends BaseController {
    @Autowired
    private IUserArchiveService userArchiveService;

    /**
    * 员工档案列表
    */
    @GetMapping("")
    public RestResponse<Page<UserArchive>> page(UserArchive userArchive, Page page){
        Page<UserArchive> pages=userArchiveService.selectPage(page,userArchive);
        return RestResponse.data(pages);
    }

    /**
     * 员工档案详情
     */
    @GetMapping("/{id}")
    public RestResponse<UserArchive> detail(@PathVariable Long id){
        UserArchive xUserArchive =userArchiveService.detail(id);
        return RestResponse.data(xUserArchive);
     }

    /**
     * 员工档案新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody UserArchive userArchive) {
        Boolean ret = userArchiveService.add(userArchive);
        return RestResponse.data(ret);
    }

    /**
     * 员工档案更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody UserArchive userArchive) {
        Boolean ret = userArchiveService.update(userArchive);
        return RestResponse.data(ret);
    }

    /**
     * 员工档案删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = userArchiveService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 查询估价师注册号
     * @param userId
     * @return
     */
    @GetMapping("/registrationNo/{userId}")
    public RestResponse<UserArchive> getRegistrationNoByUserId(@PathVariable("userId") Long userId) {
        UserArchive userRegistrationNos = userArchiveService.getRegistrationNoByUserId(userId);
        return RestResponse.data(userRegistrationNos);
    }

}

