区域代码查询下级
This commit is contained in:
parent
1b56b32f63
commit
47a1b7747d
@ -0,0 +1,48 @@
|
||||
package com.xinelu.manage.controller.sysarea;
|
||||
|
||||
import com.xinelu.common.core.controller.BaseController;
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.manage.service.sysarea.ISysAreaService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 区域Controller接口
|
||||
*
|
||||
* @author zh
|
||||
* @date 2024-02-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/area")
|
||||
public class SysAreaController extends BaseController {
|
||||
@Resource
|
||||
private ISysAreaService sysAreaService;
|
||||
|
||||
/**
|
||||
* 查询省级区域信息信息
|
||||
*
|
||||
* @return 省级区域信息集合
|
||||
*/
|
||||
@GetMapping("/getFirstLevelInfo")
|
||||
public AjaxResult getFirstLevelInfo() {
|
||||
return sysAreaService.getProvinceAreaInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级id
|
||||
*
|
||||
* @param parentId 父级id
|
||||
* @return 所属下级区域信息集合
|
||||
*/
|
||||
@GetMapping("/getSecondaryLevelInfo")
|
||||
public AjaxResult getSecondaryLevelInfo(Long parentId) {
|
||||
if (Objects.isNull(parentId)) {
|
||||
return AjaxResult.error("上级区域id不能为空");
|
||||
}
|
||||
return sysAreaService.getSubordinateAreaInfo(parentId);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package com.xinelu.manage.domain.sysarea;
|
||||
|
||||
import com.xinelu.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 区域对象 sys_area
|
||||
*
|
||||
* @author jihan
|
||||
* @date 2022-09-02
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ApiModel(value = "区域对象", description = "sys_area")
|
||||
public class SysArea extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -7082314399349945860L;
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
@ApiModelProperty(value = "父级id")
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
@ApiModelProperty(value = "区域编码")
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
*/
|
||||
@ApiModelProperty(value = "区域名称")
|
||||
private String areaName;
|
||||
|
||||
/**
|
||||
* 区域级别
|
||||
*/
|
||||
@ApiModelProperty(value = "区域级别")
|
||||
private Integer areaLevel;
|
||||
|
||||
/**
|
||||
* 当前区域所属上级区域编码,即:父级区域编码
|
||||
*/
|
||||
@ApiModelProperty(value = "当前区域所属上级区域编码")
|
||||
private String parentCode;
|
||||
|
||||
/**
|
||||
* 偏远地区标识,0:否,1:是
|
||||
*/
|
||||
@ApiModelProperty(value = "偏远地区标识")
|
||||
private Integer remoteSigns;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Long sort;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("parentId", getParentId())
|
||||
.append("areaCode", getAreaCode())
|
||||
.append("areaName", getAreaName())
|
||||
.append("areaLevel", getAreaLevel())
|
||||
.append("sort", getSort())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package com.xinelu.manage.mapper.sysarea;
|
||||
|
||||
import com.xinelu.manage.domain.sysarea.SysArea;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 区域Mapper接口
|
||||
*
|
||||
* @author zh
|
||||
* @date 2024-02-26
|
||||
*/
|
||||
public interface SysAreaMapper {
|
||||
|
||||
/**
|
||||
* 查询区域列表
|
||||
*
|
||||
* @param sysArea 区域
|
||||
* @return 区域集合
|
||||
*/
|
||||
List<SysArea> selectSysAreaList(SysArea sysArea);
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.xinelu.manage.service.sysarea;
|
||||
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
|
||||
public interface ISysAreaService {
|
||||
|
||||
/**
|
||||
* 查询省级区域信息信息
|
||||
*
|
||||
* @return 省级区域信息集合
|
||||
*/
|
||||
AjaxResult getProvinceAreaInfo();
|
||||
|
||||
/**
|
||||
* 根据父id查询其下属区域信息
|
||||
*
|
||||
* @param parentId 父级区域id
|
||||
* @return 下属区域信息集合
|
||||
*/
|
||||
AjaxResult getSubordinateAreaInfo(Long parentId);
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.xinelu.manage.service.sysarea.impl;
|
||||
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.manage.domain.sysarea.SysArea;
|
||||
import com.xinelu.manage.mapper.sysarea.SysAreaMapper;
|
||||
import com.xinelu.manage.service.sysarea.ISysAreaService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 区域Service业务层处理
|
||||
*
|
||||
* @author zh
|
||||
* @date 2024-02-26
|
||||
*/
|
||||
@Service
|
||||
public class SysAreaServiceImpl implements ISysAreaService {
|
||||
@Resource
|
||||
private SysAreaMapper sysAreaMapper;
|
||||
|
||||
/**
|
||||
* 查询省级区域信息信息
|
||||
*
|
||||
* @return 省级区域信息集合
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getProvinceAreaInfo() {
|
||||
SysArea area = new SysArea();
|
||||
area.setAreaLevel(1);
|
||||
return AjaxResult.success(sysAreaMapper.selectSysAreaList(area));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父id查询其下属区域信息
|
||||
*
|
||||
* @param parentId 父级区域id
|
||||
* @return 下属区域信息集合
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getSubordinateAreaInfo(Long parentId) {
|
||||
SysArea area = new SysArea();
|
||||
area.setParentId(parentId);
|
||||
return AjaxResult.success(sysAreaMapper.selectSysAreaList(area));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user