package com.ruoyi.web.controller.manager;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysArea;
import com.ruoyi.system.service.SysAreaService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * packageName com.ruoyi.web.controller.manager
 *
 * @author wangxy
 * @version JDK 8
 * @className SysAreaManager
 * @date 2024/5/28
 * @description 区划
 */
@Component
public class SysAreaManager {
    @Resource
    private SysAreaService sysAreaService;

    public List<SysArea> getSysAreaList(String parentId) {
        return sysAreaService.lambdaQuery()
                .eq(SysArea::getParentId, StringUtils.isEmpty(parentId) ? "29" : parentId)
                .orderByAsc(SysArea::getAreaCode)
                .list();
    }
    public String getAreaName(String id) {
        return sysAreaService.lambdaQuery()
                .eq(SysArea::getId,id).one().getName();
    }


    public List<SysArea> getAllList() {
        return sysAreaService.lambdaQuery()
                .orderByAsc(SysArea::getAreaCode)
                .list();
    }

}
