diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/SysAreaManager.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/SysAreaManager.java new file mode 100644 index 0000000..c861749 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/SysAreaManager.java @@ -0,0 +1,42 @@ +package com.ruoyi.web.controller.manager; + +import com.ruoyi.common.core.domain.Ztree; +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; +import java.util.Objects; + +/** + * 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 getSysAreaList(Long parentId) { + return sysAreaService.lambdaQuery() + .eq(SysArea::getParentId, Objects.isNull(parentId) ? 29 : parentId) + .list(); + } + + + + + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/system/SysAreaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/system/SysAreaController.java new file mode 100644 index 0000000..b0f0529 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/system/SysAreaController.java @@ -0,0 +1,41 @@ +package com.ruoyi.web.controller.system.system; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.system.domain.SysArea; +import com.ruoyi.web.controller.manager.SysAreaManager; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import static com.ruoyi.common.core.domain.AjaxResult.success; + +/** + * packageName com.ruoyi.web.controller.system.system + * + * @author wangxy + * @version JDK 8 + * @className SysAreaController + * @date 2024/5/28 + * @description 区划 + */ +@Api("区划") +@Controller +@RequestMapping("/system/area") +public class SysAreaController { + + @Resource + private SysAreaManager sysAreaManager; + + @ApiOperation("查询区划信息") + @GetMapping("/getSysAreaList") + @ResponseBody + public AjaxResult getSysAreaList(@RequestParam(required = false) Long parentId) { + return success(sysAreaManager.getSysAreaList(parentId)); + } + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysArea.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysArea.java new file mode 100644 index 0000000..60722aa --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysArea.java @@ -0,0 +1,39 @@ +package com.ruoyi.system.domain; +import com.baomidou.mybatisplus.annotation.TableField; +import java.io.Serializable; +import lombok.Data; + +/** + * 行政区域 + * @TableName sys_area + */ +@Data +public class SysArea implements Serializable { + /** + * 区域ID + */ + private Integer id; + + /** + * 上级区域ID + */ + private Integer parentId; + + /** + * 行政区域等级 1-省 2-市 3-区县 4-街道镇 + */ + private Integer areaLevel; + + /** + * 名称 + */ + private String name; + + /** + * 行政区划代码 + */ + private String areaCode; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysAreaMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysAreaMapper.java new file mode 100644 index 0000000..3d4fddc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysAreaMapper.java @@ -0,0 +1,19 @@ +package com.ruoyi.system.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.domain.SysArea; + +/** +* @author 13560 +* @description 针对表【sys_area(行政区域)】的数据库操作Mapper +* @createDate 2024-05-28 14:06:56 +* @Entity generator.domain.SysArea +*/ +public interface SysAreaMapper extends BaseMapper { + +} + + + + diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/SysAreaService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysAreaService.java new file mode 100644 index 0000000..386e237 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/SysAreaService.java @@ -0,0 +1,13 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.system.domain.SysArea; + +/** +* @author 13560 +* @description 针对表【sys_area(行政区域)】的数据库操作Service +* @createDate 2024-05-28 14:06:56 +*/ +public interface SysAreaService extends IService { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysAreaServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysAreaServiceImpl.java new file mode 100644 index 0000000..fab1671 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysAreaServiceImpl.java @@ -0,0 +1,22 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.system.domain.SysArea; +import com.ruoyi.system.mapper.SysAreaMapper; +import com.ruoyi.system.service.SysAreaService; +import org.springframework.stereotype.Service; + +/** +* @author 13560 +* @description 针对表【sys_area(行政区域)】的数据库操作Service实现 +* @createDate 2024-05-28 14:06:56 +*/ +@Service +public class SysAreaServiceImpl extends ServiceImpl + implements SysAreaService { + +} + + + + diff --git a/ruoyi-system/src/main/resources/mapper/system/SysAreaMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysAreaMapper.xml new file mode 100644 index 0000000..acac252 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/SysAreaMapper.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + id,parent_id,area_level, + name,area_code + +