package com.ruoyi.cms.controller.cms;


import com.ruoyi.cms.service.BussinessDictJobCategoryService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.domain.entity.BussinessDictJobCategory;


/**
 * 技能字典表
 *
 * @author 
 * @email 
 * @date 2025-10-30 19:25:48
 */
@RestController
@RequestMapping("/cms/dict")
@Anonymous
public class BussinessDictJobCategoryController {
    @Autowired
    private BussinessDictJobCategoryService bussinessDictJobCategoryService;

    /**
     * 列表
     */
    @GetMapping("/jobCategory")
    public AjaxResult jobCategory(BussinessDictJobCategory bussinessDictJobCategory){
        if (!hasAnyQueryCondition(bussinessDictJobCategory)) {
            return AjaxResult.error("请传递至少一个查询条件（大类、中类、小类、名称），避免数据量过大!");
        }
        return AjaxResult.success(bussinessDictJobCategoryService.getList(bussinessDictJobCategory));
    }

    /**
     * 判断是否包含至少一个有效的查询条件
     */
    private boolean hasAnyQueryCondition(BussinessDictJobCategory queryParam) {
        // 避免空指针（若 queryParam 可能为 null，需先判断）
        if (queryParam == null) {
            return false;
        }
        // 检查四个字段中是否有非空值
        return StringUtils.isNotEmpty(queryParam.getLabd())
                || StringUtils.isNotEmpty(queryParam.getLabz())
                || StringUtils.isNotEmpty(queryParam.getLabx())
                || StringUtils.isNotEmpty(queryParam.getName());
    }
}
