7 changed files with 338 additions and 1 deletions
@ -0,0 +1,127 @@
|
||||
package com.air.common.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.cinderella.framework.common.core.util.R; |
||||
import com.cinderella.framework.common.data.mybatis.QueryPage; |
||||
import com.air.common.entity.CityArea; |
||||
import com.air.common.service.CityAreaService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
|
||||
/** |
||||
* 城市区域配置管理 |
||||
* |
||||
* @author peihao |
||||
* @date 2021-09-06 19:11:29 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/cityArea") |
||||
@Api(value = "cityArea", tags = "城市区域配置管理") |
||||
public class CityAreaController { |
||||
|
||||
private final CityAreaService cityAreaService; |
||||
|
||||
/** |
||||
* 分页查询城市区域配置 |
||||
* @param page 分页对象 |
||||
* @param cityArea |
||||
* @return |
||||
*/ |
||||
@ApiOperation(value = "分页查询城市区域配置", notes = "分页查询城市区域配置") |
||||
@GetMapping("/page") |
||||
public R getCityAreaPage(QueryPage page, CityArea cityArea) { |
||||
return R.ok(cityAreaService.page(page.toPage(), Wrappers.query(cityArea))); |
||||
} |
||||
|
||||
/** |
||||
* 查询所有城市 |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "查询所有城市", notes = "查询所有城市") |
||||
@GetMapping("/city") |
||||
public R getCity() { |
||||
return R.ok(cityAreaService.getCity(),"查询成功"); |
||||
} |
||||
|
||||
/** |
||||
* 查询城市的行政区 |
||||
* @param city id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "查询城市的行政区", notes = "查询城市的行政区") |
||||
@GetMapping("/getArea/{city}") |
||||
public R getArea(@PathVariable("city") String city) { |
||||
return R.ok(cityAreaService.getArea(city),"查询成功"); |
||||
} |
||||
|
||||
/** |
||||
* 查询行政区下的大组团 |
||||
* @param area id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "查询行政区下的大组团", notes = "查询行政区下的大组团") |
||||
@GetMapping("/getBigGroup") |
||||
public R getBigGroup(@RequestParam("area") String area,@RequestParam("city") String city) { |
||||
return R.ok(cityAreaService.getBigGroup(area,city),"查询成功"); |
||||
} |
||||
|
||||
/** |
||||
* 查询大组团下的小组团 |
||||
* @param bigGroup id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "查询大组团下的小组团", notes = "查询大组团下的小组团") |
||||
@GetMapping("/getSmallGroup") |
||||
public R getSmallGroup(@RequestParam("bigGroup") String bigGroup,@RequestParam("area") String area,@RequestParam("city") String city) { |
||||
return R.ok(cityAreaService.getSmallGroup(bigGroup,area,city),"查询成功"); |
||||
} |
||||
|
||||
/** |
||||
* 通过id查询城市区域配置 |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id查询城市区域配置", notes = "通过id查询城市区域配置") |
||||
@GetMapping("/{id}") |
||||
public R getById(@PathVariable("id") Integer id) { |
||||
return R.ok(cityAreaService.getById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 新增城市区域配置 |
||||
* @param cityArea |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "新增城市区域配置", notes = "新增城市区域配置") |
||||
@PostMapping |
||||
public R save(@RequestBody CityArea cityArea) { |
||||
return R.ok(cityAreaService.save(cityArea)); |
||||
} |
||||
|
||||
/** |
||||
* 修改城市区域配置 |
||||
* @param cityArea |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "修改城市区域配置", notes = "修改城市区域配置") |
||||
@PutMapping |
||||
public R updateById(@RequestBody CityArea cityArea) { |
||||
return R.ok(cityAreaService.updateById(cityArea)); |
||||
} |
||||
|
||||
/** |
||||
* 通过id删除城市区域配置 |
||||
* @param id id |
||||
* @return R |
||||
*/ |
||||
@ApiOperation(value = "通过id删除城市区域配置", notes = "通过id删除城市区域配置") |
||||
@DeleteMapping("/{id}") |
||||
public R removeById(@PathVariable Integer id) { |
||||
return R.ok(cityAreaService.removeById(id)); |
||||
} |
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.air.common.cotroller; |
||||
package com.air.common.controller; |
||||
|
||||
import com.air.common.service.SysFileUploadService; |
||||
import com.air.common.vo.SysFileUploadVo; |
@ -0,0 +1,38 @@
|
||||
package com.air.common.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.extension.activerecord.Model; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import java.io.Serializable; |
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* |
||||
* 城市区域配置 |
||||
* @author peihao |
||||
* @date 2021-09-06 19:11:29 |
||||
*/ |
||||
@Data |
||||
@TableName("city_area") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "城市区域配置") |
||||
public class CityArea extends Model<CityArea> { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@TableId |
||||
@ApiModelProperty(value="主键") |
||||
private Integer id; |
||||
@ApiModelProperty(value="城市") |
||||
private String city; |
||||
@ApiModelProperty(value="行政区") |
||||
private String area; |
||||
@ApiModelProperty(value="大组团") |
||||
private String bigGroup; |
||||
@ApiModelProperty(value="小组团") |
||||
private String smallGroup; |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.air.common.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.air.common.entity.CityArea; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 城市区域配置 |
||||
* |
||||
* @author peihao |
||||
* @date 2021-09-06 19:11:29 |
||||
*/ |
||||
public interface CityAreaMapper extends BaseMapper<CityArea> { |
||||
|
||||
/** |
||||
* 查询城市 |
||||
* @author peihao |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getCity(); |
||||
|
||||
/** |
||||
* 查询城市的行政区 |
||||
* @author peihao |
||||
* @param city 城市 |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getArea(String city); |
||||
|
||||
/** |
||||
* 查询行政区下的大组团 |
||||
* @author peihao |
||||
* @param area 行政区 |
||||
* @param city 城市 |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getBigGroup(@Param("area") String area,@Param("city") String city); |
||||
|
||||
/** |
||||
* 查询大组团下的小组团 |
||||
* @author peihao |
||||
* @param bigGroup 大组团 |
||||
* @param city 城市 |
||||
* @param area 行政区 |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getSmallGroup(@Param("bigGroup") String bigGroup, @Param("area") String area, @Param("city") String city); |
||||
|
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.air.common.service; |
||||
|
||||
import com.air.common.entity.CityArea; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 城市区域配置 |
||||
* |
||||
* @author peihao |
||||
* @date 2021-09-06 19:11:29 |
||||
*/ |
||||
public interface CityAreaService extends IService<CityArea> { |
||||
|
||||
|
||||
/** |
||||
* 查询城市 |
||||
* @author peihao |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getCity(); |
||||
|
||||
/** |
||||
* 查询城市的行政区 |
||||
* @author peihao |
||||
* @param city 城市 |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getArea(String city); |
||||
|
||||
/** |
||||
* 查询行政区下的大组团 |
||||
* @author peihao |
||||
* @param area 行政区 |
||||
* @param city 城市 |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getBigGroup(String area,String city); |
||||
|
||||
/** |
||||
* 查询大组团下的小组团 |
||||
* @author peihao |
||||
* @param bigGroup 大组团 |
||||
* @param area 行政区 |
||||
* @param city 城市 |
||||
* @date 2021/9/6 |
||||
* @return |
||||
**/ |
||||
List<String> getSmallGroup(String bigGroup,String area,String city); |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.air.common.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.air.common.entity.CityArea; |
||||
import com.air.common.mapper.CityAreaMapper; |
||||
import com.air.common.service.CityAreaService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 城市区域配置 |
||||
* |
||||
* @author peihao |
||||
* @date 2021-09-06 19:11:29 |
||||
*/ |
||||
@Service |
||||
public class CityAreaServiceImpl extends ServiceImpl<CityAreaMapper, CityArea> implements CityAreaService { |
||||
|
||||
|
||||
@Override |
||||
public List<String> getCity() { |
||||
return baseMapper.getCity(); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getArea(String city) { |
||||
return baseMapper.getArea(city); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getBigGroup(String area,String city) { |
||||
return baseMapper.getBigGroup(area,city); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getSmallGroup(String bigGroup,String area,String city) { |
||||
return baseMapper.getSmallGroup(bigGroup,area,city); |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
<?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.air.common.mapper.CityAreaMapper"> |
||||
|
||||
<select id="getCity" resultType="java.lang.String"> |
||||
select distinct city from city_area group by city |
||||
</select> |
||||
|
||||
<select id="getArea" resultType="java.lang.String"> |
||||
select distinct area from city_area where city = #{city} group by area |
||||
</select> |
||||
|
||||
<select id="getBigGroup" resultType="java.lang.String"> |
||||
select distinct big_group from city_area where area = #{area} and city = #{city} group by big_group |
||||
</select> |
||||
|
||||
<select id="getSmallGroup" resultType="java.lang.String"> |
||||
select distinct small_group from city_area where big_group = #{bigGroup} and area = #{area} and city = #{city} group by small_group |
||||
</select> |
||||
</mapper> |
Loading…
Reference in new issue