1
This commit is contained in:
parent
242265d54d
commit
d63358527b
@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.ruoyi.base.vo.BaseCityVO;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -29,14 +30,13 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 城市Controller
|
* 城市Controller
|
||||||
*
|
*
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 2025-03-18
|
* @date 2025-03-18
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/base/city")
|
@RequestMapping("/base/city")
|
||||||
public class BaseCityController extends BaseController
|
public class BaseCityController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBaseCityService baseCityService;
|
private IBaseCityService baseCityService;
|
||||||
|
|
||||||
@ -45,20 +45,31 @@ public class BaseCityController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:city:list')")
|
@PreAuthorize("@ss.hasPermi('base:city:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult list(BaseCity baseCity)
|
public AjaxResult list(BaseCity baseCity) {
|
||||||
{
|
|
||||||
List<BaseCity> list = baseCityService.list();
|
List<BaseCity> list = baseCityService.list();
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询城市数列表
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:11 2025/4/2
|
||||||
|
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||||
|
**/
|
||||||
|
@GetMapping("/treeCity")
|
||||||
|
public AjaxResult treeCity() {
|
||||||
|
List<BaseCityVO> list = baseCityService.treeCity();
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出城市列表
|
* 导出城市列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:city:export')")
|
@PreAuthorize("@ss.hasPermi('base:city:export')")
|
||||||
@Log(title = "城市", businessType = BusinessType.EXPORT)
|
@Log(title = "城市", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, BaseCity baseCity)
|
public void export(HttpServletResponse response, BaseCity baseCity) {
|
||||||
{
|
|
||||||
List<BaseCity> list = baseCityService.list();
|
List<BaseCity> list = baseCityService.list();
|
||||||
ExcelUtil<BaseCity> util = new ExcelUtil<BaseCity>(BaseCity.class);
|
ExcelUtil<BaseCity> util = new ExcelUtil<BaseCity>(BaseCity.class);
|
||||||
util.exportExcel(response, list, "城市数据");
|
util.exportExcel(response, list, "城市数据");
|
||||||
@ -69,8 +80,7 @@ public class BaseCityController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:city:query')")
|
@PreAuthorize("@ss.hasPermi('base:city:query')")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
{
|
|
||||||
return success(baseCityService.getById(id));
|
return success(baseCityService.getById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,8 +90,7 @@ public class BaseCityController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('base:city:add')")
|
@PreAuthorize("@ss.hasPermi('base:city:add')")
|
||||||
@Log(title = "城市", businessType = BusinessType.INSERT)
|
@Log(title = "城市", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody BaseCity baseCity)
|
public AjaxResult add(@RequestBody BaseCity baseCity) {
|
||||||
{
|
|
||||||
return toAjax(baseCityService.save(baseCity));
|
return toAjax(baseCityService.save(baseCity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,8 +100,7 @@ public class BaseCityController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('base:city:edit')")
|
@PreAuthorize("@ss.hasPermi('base:city:edit')")
|
||||||
@Log(title = "城市", businessType = BusinessType.UPDATE)
|
@Log(title = "城市", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody BaseCity baseCity)
|
public AjaxResult edit(@RequestBody BaseCity baseCity) {
|
||||||
{
|
|
||||||
return toAjax(baseCityService.updateById(baseCity));
|
return toAjax(baseCityService.updateById(baseCity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,27 +109,26 @@ public class BaseCityController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('base:city:remove')")
|
@PreAuthorize("@ss.hasPermi('base:city:remove')")
|
||||||
@Log(title = "城市", businessType = BusinessType.DELETE)
|
@Log(title = "城市", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
public AjaxResult remove(@PathVariable Long[] ids)
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
{
|
|
||||||
List<Long> list = new ArrayList<>(Arrays.asList(ids));
|
List<Long> list = new ArrayList<>(Arrays.asList(ids));
|
||||||
return toAjax(baseCityService.removeByIds(list));
|
return toAjax(baseCityService.removeByIds(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询子级城市
|
* 查询子级城市
|
||||||
* @author vinjor-M
|
*
|
||||||
* @date 18:09 2025/3/18
|
|
||||||
* @param parentId 父级id
|
* @param parentId 父级id
|
||||||
* @return com.ruoyi.common.core.domain.AjaxResult
|
* @return com.ruoyi.common.core.domain.AjaxResult
|
||||||
**/
|
* @author vinjor-M
|
||||||
|
* @date 18:09 2025/3/18
|
||||||
|
**/
|
||||||
@GetMapping("/listByPid")
|
@GetMapping("/listByPid")
|
||||||
public AjaxResult listByPid(@RequestParam(value = "parentId",required = false) Long parentId)
|
public AjaxResult listByPid(@RequestParam(value = "parentId", required = false) Long parentId) {
|
||||||
{
|
if (null == parentId) {
|
||||||
if(null==parentId){
|
|
||||||
parentId = 0L;
|
parentId = 0L;
|
||||||
}
|
}
|
||||||
List<BaseCity> list = baseCityService.list(new LambdaQueryWrapper<BaseCity>().eq(BaseCity::getParentId,parentId).orderByAsc(BaseCity::getAreaCode));
|
List<BaseCity> list = baseCityService.list(new LambdaQueryWrapper<BaseCity>().eq(BaseCity::getParentId, parentId).orderByAsc(BaseCity::getAreaCode));
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,28 @@
|
|||||||
package com.ruoyi.base.service;
|
package com.ruoyi.base.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.base.domain.BaseCity;
|
import com.ruoyi.base.domain.BaseCity;
|
||||||
|
import com.ruoyi.base.vo.BaseCityVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 城市Service接口
|
* 城市Service接口
|
||||||
*
|
*
|
||||||
* @author vinjor-m
|
* @author vinjor-m
|
||||||
* @date 2025-03-18
|
* @date 2025-03-18
|
||||||
*/
|
*/
|
||||||
public interface IBaseCityService extends IService<BaseCity>
|
public interface IBaseCityService extends IService<BaseCity> {
|
||||||
{
|
|
||||||
IPage<BaseCity> queryListPage(BaseCity pageReqVO, Page<BaseCity> page);
|
IPage<BaseCity> queryListPage(BaseCity pageReqVO, Page<BaseCity> page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询树列表
|
||||||
|
*
|
||||||
|
* @return java.util.List<com.ruoyi.base.vo.BaseCityVO>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:12 2025/4/2
|
||||||
|
**/
|
||||||
|
List<BaseCityVO> treeCity();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.ruoyi.base.service.impl;
|
package com.ruoyi.base.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ruoyi.base.vo.BaseCityVO;
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@ -27,4 +30,22 @@ public class BaseCityServiceImpl extends ServiceImpl<BaseCityMapper,BaseCity> i
|
|||||||
public IPage<BaseCity> queryListPage(BaseCity pageReqVO, Page<BaseCity> page) {
|
public IPage<BaseCity> queryListPage(BaseCity pageReqVO, Page<BaseCity> page) {
|
||||||
return baseCityMapper.queryListPage(pageReqVO, page);
|
return baseCityMapper.queryListPage(pageReqVO, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询树列表
|
||||||
|
*
|
||||||
|
* @return java.util.List<com.ruoyi.base.vo.BaseCityVO>
|
||||||
|
* @author PQZ
|
||||||
|
* @date 15:12 2025/4/2
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public List<BaseCityVO> treeCity() {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<BaseCityVO> buildCityTree(List<BaseCityVO> list) {
|
||||||
|
List<BaseCityVO> tree = new ArrayList<>();
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
11
ruoyi-admin/src/main/java/com/ruoyi/base/vo/BaseCityVO.java
Normal file
11
ruoyi-admin/src/main/java/com/ruoyi/base/vo/BaseCityVO.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package com.ruoyi.base.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BaseCityVO {
|
||||||
|
String text;
|
||||||
|
String value;
|
||||||
|
List<BaseCityVO> children;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user