Commit 6fccb157 authored by lcl's avatar lcl

add region

parent 201a8fe2
package com.dsk.web.controller.system;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.system.service.SysRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 地区信息
*
* @author lcl
* @create 2023/6/28
*/
@RestController
@RequestMapping("/system/region")
public class SysRegionController extends BaseController {
@Autowired
private SysRegionService baseService;
/**
* 通过父id获取下级地区信息
*/
@GetMapping("/list/{parentId}")
public AjaxResult listByParentId(@PathVariable Integer parentId) {
return AjaxResult.success(baseService.selectByParentId(parentId));
}
}
package com.dsk.system.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 行政区编码表(SysRegion)实体类
*
* @author makejava
* @since 2023-06-28 11:23:12
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("sys_region")
public class SysRegion implements Serializable {
private static final long serialVersionUID = -17128129449360485L;
/**
* 行政区编码(数字型)
*/
private Integer id;
/**
* 行政区名称
*/
private String regionName;
/**
* 行政区名称(最新)
*/
private String fullName;
/**
* 行政区简称
*/
private String nameSimple;
/**
* 行政区编码(字符型)
*/
private String regionCode;
/**
* 行政区等级:1:省级,2:地市,3:区县,4:乡镇,
*/
private Integer regionLevel;
/**
* 父级id
*/
private Integer parentId;
/**
* 行政区类型:0:其他,1:省,2:直辖市,3:特别行政区,4:自治区
*/
private Integer regionType;
/**
* 权重
*/
private Integer weight;
/**
* 备注
*/
private String remark;
/**
* 0:开启,1:准备中,2:关闭
*/
private Integer status;
private Date createTime;
private Date updateTime;
private Integer updateId;
}
package com.dsk.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsk.system.domain.SysRegion;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 行政区编码表(SysRegion)表数据库访问层
*
* @author makejava
* @since 2023-06-28 11:23:13
*/
@Mapper
public interface SysRegionMapper extends BaseMapper<SysRegion> {
}
package com.dsk.system.service;
import com.dsk.system.domain.SysRegion;
import java.util.List;
/**
* 行政区编码表(SysRegion)表服务接口
*
* @author makejava
* @since 2023-06-28 11:23:12
*/
public interface SysRegionService {
List<SysRegion> selectByParentId(Integer parentId);
}
package com.dsk.system.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.system.domain.SysRegion;
import com.dsk.system.mapper.SysRegionMapper;
import com.dsk.system.service.SysRegionService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.List;
/**
* 行政区编码表(SysRegion)表服务实现类
*
* @author makejava
* @since 2023-06-28 11:23:12
*/
@Service("sysRegionService")
public class SysRegionServiceImpl implements SysRegionService {
@Resource
private SysRegionMapper baseMapper;
private static final Integer ACQUIESCE_PARENT_ID = 100000;
@Override
public List<SysRegion> selectByParentId(Integer parentId) {
return baseMapper.selectList(Wrappers.<SysRegion>lambdaQuery()
.eq(SysRegion::getParentId, ObjectUtils.isEmpty(parentId) ? ACQUIESCE_PARENT_ID : parentId)
.orderByAsc(SysRegion::getId));
}
}
<?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.dsk.system.mapper.SysRegionMapper">
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment