Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -4,11 +4,17 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.modules.common.pojo.vo.AppCommonRegionsInfoVO;
|
||||
import org.springblade.modules.common.service.ICommonRegionsInfoService;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@@ -17,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class APPCommonController {
|
||||
|
||||
private final IUserService userService;
|
||||
private final ICommonRegionsInfoService commonRegionsInfoService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -29,4 +36,17 @@ public class APPCommonController {
|
||||
return R.data(userService.hasChangedPassword());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取省市区列表
|
||||
*/
|
||||
@GetMapping("/find-region-list")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "获取省市区列表")
|
||||
public R<List<AppCommonRegionsInfoVO>> findRegionList(@RequestParam @Min(value = 0 , message = "父级id不能小于0") Long pid ,
|
||||
@RequestParam @Min(value = 1 , message = "只能选到省") @Max(value = 4 , message = "只能选到街道") Integer level) {
|
||||
return R.data(commonRegionsInfoService.findRegionList(pid , level));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.springblade.modules.common.convert;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.springblade.modules.common.pojo.entity.CommonRegionsInfoEntity;
|
||||
import org.springblade.modules.common.pojo.vo.AppCommonRegionsInfoVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AppCommonConvert {
|
||||
|
||||
AppCommonConvert INSTANCE = Mappers.getMapper(AppCommonConvert.class);
|
||||
|
||||
|
||||
AppCommonRegionsInfoVO convertRegionsInfoVO(CommonRegionsInfoEntity entity);
|
||||
|
||||
List<AppCommonRegionsInfoVO> convertRegionsInfoListVO(List<CommonRegionsInfoEntity> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 地区详情表 视图实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-02-05
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AppCommonRegionsInfoVO implements Serializable {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父主键
|
||||
*/
|
||||
private Integer pid;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
}
|
||||
@@ -26,7 +26,10 @@
|
||||
package org.springblade.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import org.springblade.modules.common.pojo.entity.CommonRegionsInfoEntity;
|
||||
import org.springblade.modules.common.pojo.vo.AppCommonRegionsInfoVO;
|
||||
import org.springblade.modules.common.pojo.vo.CommonRegionsInfoVO;
|
||||
import org.springblade.modules.common.excel.CommonRegionsInfoExcel;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -58,4 +61,5 @@ public interface ICommonRegionsInfoService extends BaseService<CommonRegionsInfo
|
||||
*/
|
||||
List<CommonRegionsInfoExcel> exportRegionsInfo(Wrapper<CommonRegionsInfoEntity> queryWrapper);
|
||||
|
||||
List<AppCommonRegionsInfoVO> findRegionList(@Min(value = 0) Long pid, @Max(value = 4 ) @Min(value = 0) Integer level);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,10 @@
|
||||
*/
|
||||
package org.springblade.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springblade.modules.common.convert.AppCommonConvert;
|
||||
import org.springblade.modules.common.pojo.entity.CommonRegionsInfoEntity;
|
||||
import org.springblade.modules.common.pojo.vo.AppCommonRegionsInfoVO;
|
||||
import org.springblade.modules.common.pojo.vo.CommonRegionsInfoVO;
|
||||
import org.springblade.modules.common.excel.CommonRegionsInfoExcel;
|
||||
import org.springblade.modules.common.mapper.CommonRegionsInfoMapper;
|
||||
@@ -60,4 +63,17 @@ public class CommonRegionsInfoServiceImpl extends BaseServiceImpl<CommonRegionsI
|
||||
return regionsInfoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppCommonRegionsInfoVO> findRegionList(Long pid, Integer level) {
|
||||
|
||||
List<CommonRegionsInfoEntity> regionsInfoList = list(
|
||||
Wrappers.lambdaQuery(CommonRegionsInfoEntity.class)
|
||||
.eq(CommonRegionsInfoEntity::getPid, pid)
|
||||
.eq(CommonRegionsInfoEntity::getLevel, level)
|
||||
);
|
||||
|
||||
|
||||
return AppCommonConvert.INSTANCE.convertRegionsInfoListVO(regionsInfoList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,11 +117,6 @@ public class MallCategoryController extends BladeController {
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入mallCategory")
|
||||
public R update(@Valid @RequestBody MallCategoryEntity mallCategory) {
|
||||
if (mallCategory.getPid() == null){
|
||||
mallCategory.setLevel(1);
|
||||
}else {
|
||||
mallCategory.setLevel(2);
|
||||
}
|
||||
return R.status(mallCategoryService.updateById(mallCategory));
|
||||
}
|
||||
|
||||
@@ -132,6 +127,11 @@ public class MallCategoryController extends BladeController {
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入mallCategory")
|
||||
public R submit(@Valid @RequestBody MallCategoryEntity mallCategory) {
|
||||
if (mallCategory.getPid() == null){
|
||||
mallCategory.setLevel(1);
|
||||
}else {
|
||||
mallCategory.setLevel(2);
|
||||
}
|
||||
return R.status(mallCategoryService.saveOrUpdate(mallCategory));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public class MallCategoryServiceImpl extends BaseServiceImpl<MallCategoryMapper,
|
||||
return list(
|
||||
Wrappers.lambdaQuery(MallCategoryEntity.class)
|
||||
.eq(MallCategoryEntity::getLevel, 1)
|
||||
.orderByDesc(MallCategoryEntity::getId)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user