package com.ruoyi.pay.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

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.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.pay.domain.vo.PayButieEmplyeeVo;
import com.ruoyi.pay.domain.bo.PayButieEmplyeeBo;
import com.ruoyi.pay.service.IPayButieEmplyeeService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补贴和员工联系
 *
 * @author ruoyi
 * @date 2025-05-12
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/pay/butieEmplyee")
public class PayButieEmplyeeController extends BaseController {

    private final IPayButieEmplyeeService iPayButieEmplyeeService;

    /**
     * 查询补贴和员工联系列表
     */
    @SaCheckPermission("pay:butieEmplyee:list")
    @GetMapping("/list")
    public TableDataInfo<PayButieEmplyeeVo> list(PayButieEmplyeeBo bo, PageQuery pageQuery) {
        return iPayButieEmplyeeService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出补贴和员工联系列表
     */
    @SaCheckPermission("pay:butieEmplyee:export")
    @Log(title = "补贴和员工联系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(PayButieEmplyeeBo bo, HttpServletResponse response) {
        List<PayButieEmplyeeVo> list = iPayButieEmplyeeService.queryList(bo);
        ExcelUtil.exportExcel(list, "补贴和员工联系", PayButieEmplyeeVo.class, response);
    }

    /**
     * 获取补贴和员工联系详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("pay:butieEmplyee:query")
    @GetMapping("/{id}")
    public R<PayButieEmplyeeVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iPayButieEmplyeeService.queryById(id));
    }

    /**
     * 新增补贴和员工联系
     */
    @SaCheckPermission("pay:butieEmplyee:add")
    @Log(title = "补贴和员工联系", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody PayButieEmplyeeBo bo) {
        return toAjax(iPayButieEmplyeeService.insertByBo(bo));
    }

    /**
     * 修改补贴和员工联系
     */
    @SaCheckPermission("pay:butieEmplyee:edit")
    @Log(title = "补贴和员工联系", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody PayButieEmplyeeBo bo) {
        return toAjax(iPayButieEmplyeeService.updateByBo(bo));
    }

    /**
     * 删除补贴和员工联系
     *
     * @param ids 主键串
     */
    @SaCheckPermission("pay:butieEmplyee:remove")
    @Log(title = "补贴和员工联系", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iPayButieEmplyeeService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
