package com.ruoyi.zhushi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.zhushi.entity.DkCheckInRecordDTO;
import com.ruoyi.zhushi.entity.NjRuleConfigDTO;
import com.ruoyi.zhushi.service.NjRuleConfigService;
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.*;

/**
 * 打卡控制台
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/nj/rule/config")
@Slf4j
public class NjRuleConfigController extends BaseController {

    @Autowired
    private NjRuleConfigService njRuleConfigService;


    // 查询当前用户考勤组
    @GetMapping("/queryRuleConfig")
    public TableDataInfo<NjRuleConfigDTO> queryRule(NjRuleConfigDTO njRuleConfigDTO) {
        return njRuleConfigService.queryRuleConfig(njRuleConfigDTO);
    }

    // 新增规则
    @PostMapping("/addRuleConfig")
    public R<Boolean> addRule(@RequestBody NjRuleConfigDTO njRuleConfigDTO) {
        return R.ok(njRuleConfigService.addRule(njRuleConfigDTO));
    }

    // 删除规则
    @GetMapping("/delRule")
    public R<Integer> delRule(@RequestParam("id") long id) {
        return R.ok(njRuleConfigService.delRule(id));
    }

    // 删除用户
    @DeleteMapping("/delUser/{id}")
    public R<Void> delUser(@PathVariable Long id) {
        return toAjax(njRuleConfigService.delUser(id));
    }
}
