package com.ruoyi.web.controller.clock;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.clock.domain.BasicInfo;
import com.ruoyi.clock.domain.bo.BasicInfoBo;
import com.ruoyi.clock.domain.vo.BasicInfoVo;
import com.ruoyi.clock.service.IBasicInfoService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
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.page.TableDataInfo;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 基础设置Controller
 *
 * @author pengc
 * @date 2026-03-04
 */
@Validated
@Api(value = "基础设置控制器", tags = {"基础设置管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/clock/basicInfo")
public class BasicInfoController extends BaseController {

    private final IBasicInfoService iBasicInfoService;

    /**
     * 获取基础设置详细信息
     * @return
     */
    @ApiOperation("用户协议配置-通过id查询")
    @GetMapping(value = "/queryInfo")
    public R<BasicInfo> queryInfo() {
        return R.ok(iBasicInfoService.queryBasicInfo());
    }

    /**
     * 新增基础设置
     */
    @ApiOperation("新增基础设置")
    @SaCheckPermission("clock:basicInfo:add")
    @Log(title = "基础设置", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/add")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody BasicInfoBo bo) {
        return toAjax(iBasicInfoService.saveBasicInfo(bo) ? 1 : 0);
    }

}
