package com.fzzy.igds.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.fzzy.igds.domain.DicArea; import com.fzzy.igds.mapper.DicAreaMapper; import com.ruoyi.common.utils.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; /** * @Description * @Author CZT * @Date 2025/11/25 16:23 */ @Service public class DicAreaService { @Resource private DicAreaMapper dicAreaMapper; public void listPageData(Page page, String key) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotBlank(key)) { queryWrapper.like("name", key); } dicAreaMapper.selectPage(page, queryWrapper); } /** * 根据父编码查询区域信息 * * @param parentCode * @return */ public List listData(String parentCode, String name, String code) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotBlank(parentCode)) { queryWrapper.like("parent_code", parentCode); } if (StringUtils.isNotBlank(name)) { queryWrapper.like("name", name); } if (StringUtils.isNotBlank(code)) { queryWrapper.like("code", code); } return dicAreaMapper.selectList(queryWrapper); } /** * 保存数据 * * @param data * @return */ public String saveDicArea(DicArea data) { dicAreaMapper.insert( data); return null; } /** * 删除数据 * * @param data * @return */ public String delDicArea(DicArea data) { dicAreaMapper.deleteById(data); return null; } /** * 根据名称获取区域编码 * * @param name * @return */ public DicArea listDicAreaByName(String name) { List list = this.listData(null, name, null); if(null == list || list.isEmpty()){ return null; } return list.get(0); } /** * 根据区域编码获取名称 * * @param code * @return */ public DicArea listDicAreaByCode(String code) { List list = this.listData(null, null, code); if(null == list || list.isEmpty()){ return null; } return list.get(0); } /** * 模糊查询 * * @param key * @return */ public List listDicArea(String key) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (StringUtils.isNotBlank(key)) { queryWrapper.like("name", key); } List dicAreas = dicAreaMapper.selectList(queryWrapper); if (null == dicAreas || dicAreas.isEmpty()) { queryWrapper = new QueryWrapper<>(); queryWrapper.like("code", key); dicAreas = dicAreaMapper.selectList(queryWrapper); } return dicAreas; } }