浏览代码

中国行政地区

24282 1 年之前
父节点
当前提交
5ebe1017e2

+ 38 - 0
sd-business/src/main/java/com/sd/business/controller/area/AreaController.java

@@ -0,0 +1,38 @@
+package com.sd.business.controller.area;
+
+import com.sd.business.entity.area.dto.AreaSelectDto;
+import com.sd.business.entity.area.vo.AreaVo;
+import com.sd.business.service.area.AreaService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 中国行政地区表 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@RestController
+@RequestMapping("/area")
+public class AreaController {
+
+    @Autowired
+    private AreaService areaService;
+
+    /**
+     * 中国行政地区表列表
+     */
+    @PostMapping("/list")
+    public List<AreaVo> list(@Validated @RequestBody AreaSelectDto dto) {
+        return areaService.getList(dto);
+    }
+
+}

+ 17 - 0
sd-business/src/main/java/com/sd/business/entity/area/dto/AreaDto.java

@@ -0,0 +1,17 @@
+package com.sd.business.entity.area.dto;
+
+import com.sd.business.entity.area.po.Area;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 中国行政地区表新增编辑入参实体
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+public class AreaDto extends Area {
+
+}

+ 25 - 0
sd-business/src/main/java/com/sd/business/entity/area/dto/AreaSelectDto.java

@@ -0,0 +1,25 @@
+package com.sd.business.entity.area.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * 中国行政地区表列表查询入参实体
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+public class AreaSelectDto extends BaseSelectDto {
+
+    /**
+     * 父级行政代码
+     */
+    @NotNull(message = "父级行政代码不能为空")
+    private Long parentCode;
+
+}

+ 78 - 0
sd-business/src/main/java/com/sd/business/entity/area/po/Area.java

@@ -0,0 +1,78 @@
+package com.sd.business.entity.area.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BaseIdPo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 中国行政地区表
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+@TableName("area")
+public class Area extends BaseIdPo {
+
+    /**
+     * 层级
+     */
+    private Integer levelCode;
+
+    /**
+     * 父级行政代码
+     */
+    private Long parentCode;
+
+    /**
+     * 行政代码
+     */
+    private Long areaCode;
+
+    /**
+     * 邮政编码
+     */
+    private String zipCode;
+
+    /**
+     * 区号
+     */
+    private String cityCode;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 简称
+     */
+    private String shortName;
+
+    /**
+     * 组合名
+     */
+    private String mergerName;
+
+    /**
+     * 拼音
+     */
+    private String pinyin;
+
+    /**
+     * 经度
+     */
+    private BigDecimal lng;
+
+    /**
+     * 纬度
+     */
+    private BigDecimal lat;
+
+}

+ 26 - 0
sd-business/src/main/java/com/sd/business/entity/area/vo/AreaVo.java

@@ -0,0 +1,26 @@
+package com.sd.business.entity.area.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 中国行政地区表列表查询返回值实体
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Getter
+@Setter
+public class AreaVo {
+
+    /**
+     * 行政代码
+     */
+    private Long areaCode;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+}

+ 16 - 0
sd-business/src/main/java/com/sd/business/mapper/area/AreaMapper.java

@@ -0,0 +1,16 @@
+package com.sd.business.mapper.area;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.sd.business.entity.area.po.Area;
+
+/**
+ * <p>
+ * 中国行政地区表 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+public interface AreaMapper extends BaseMapper<Area> {
+
+}

+ 25 - 0
sd-business/src/main/java/com/sd/business/service/area/AreaService.java

@@ -0,0 +1,25 @@
+package com.sd.business.service.area;
+
+import com.ruoyi.common.core.service.BaseService;
+import com.sd.business.entity.area.dto.AreaSelectDto;
+import com.sd.business.entity.area.po.Area;
+import com.sd.business.entity.area.vo.AreaVo;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 中国行政地区表 服务类
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+public interface AreaService extends BaseService<Area> {
+
+    /**
+     * 中国行政地区表列表
+     */
+    List<AreaVo> getList(AreaSelectDto dto);
+
+}

+ 35 - 0
sd-business/src/main/java/com/sd/business/service/area/impl/AreaServiceImpl.java

@@ -0,0 +1,35 @@
+package com.sd.business.service.area.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sd.business.entity.area.dto.AreaSelectDto;
+import com.sd.business.entity.area.po.Area;
+import com.sd.business.entity.area.vo.AreaVo;
+import com.sd.business.mapper.area.AreaMapper;
+import com.sd.business.service.area.AreaService;
+import com.sd.framework.util.sql.Sql;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 中国行政地区表 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2023-11-20
+ */
+@Service
+public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {
+
+    @Override
+    public List<AreaVo> getList(AreaSelectDto dto) {
+
+        return Sql.create(AreaVo.class)
+                .select(Area::getAreaCode, Area::getName)
+                .from(Area.class)
+                .eq(Area::getParentCode, dto.getParentCode())
+                .list();
+    }
+
+}

+ 5 - 0
sd-business/src/main/resources/mapper/area/AreaMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sd.business.mapper.area.AreaMapper">
+
+</mapper>

+ 1 - 1
sd-framework/src/main/java/com/sd/framework/util/sql/Select.java

@@ -154,7 +154,7 @@ public class Select<T> {
 
     public From<T> from(String alias, Class<?> cls) {
         String tableName = Sql.getTableName(cls);
-        sql.fromList.add(" FROM " + tableName + StringPool.EMPTY + alias);
+        sql.fromList.add(" FROM " + tableName + StringPool.SPACE + alias);
         return new From<>(sql);
     }