This commit is contained in:
77
2024-05-18 17:36:07 +08:00
parent 1b9a0fa4f8
commit f9b2f64a98
5 changed files with 44 additions and 2 deletions

View File

@@ -16,4 +16,9 @@ public class ImTest {
public void refresh(){ public void refresh(){
imOp.refreshIm(false); imOp.refreshIm(false);
} }
@Test
public void refreshImNoSaveToken(){
imOp.refreshImNoSaveToken();
}
} }

View File

@@ -82,12 +82,19 @@ public class SettingAppController {
} }
@GetMapping("/areaCode/tree") @GetMapping("/areaCode/tree")
@Operation(summary = "获取所有省市区编码") @Operation(summary = "获取所有省市区编码(树形结构)")
public R<List<AreaCodeTree>> areaCodeTree(){ public R<List<AreaCodeTree>> areaCodeTree(){
List<AreaCodeTree> node = areaCodeService.tree(); List<AreaCodeTree> node = areaCodeService.tree();
return R.ok(node); return R.ok(node);
} }
@GetMapping("/areaCode/city/tree")
@Operation(summary = "获取所有省市编码(树形结构)")
public R<List<AreaCodeTree>> areaCodeCityTree(){
List<AreaCodeTree> node = areaCodeService.treeCity();
return R.ok(node);
}
@GetMapping("/customerService/pic") @GetMapping("/customerService/pic")
@Operation(summary = "获取客服二维码") @Operation(summary = "获取客服二维码")
@SaIgnore @SaIgnore

View File

@@ -7,7 +7,7 @@ public enum AreaCodeLevelEnum {
COUNTRY("country","国家"), COUNTRY("country","国家"),
PROVINCE("province","省份"), PROVINCE("province","省份"),
CITY("city",""), CITY("city",""),
DISTRICT("city","区县"), DISTRICT("district","区县"),
; ;
private final String code; private final String code;
private final String text; private final String text;

View File

@@ -22,4 +22,6 @@ public interface AreaCodeService extends IService<AreaCode> {
List<AreaCodeTree> tree(); List<AreaCodeTree> tree();
List<AreaCodeTree> treeCity();
} }

View File

@@ -8,6 +8,7 @@ import com.ruoyi.xq.domain.AreaCode;
import com.ruoyi.xq.dto.admin.areacode.AreaCodeAdminTree; import com.ruoyi.xq.dto.admin.areacode.AreaCodeAdminTree;
import com.ruoyi.xq.dto.app.areacode.AreaCodeQuery; import com.ruoyi.xq.dto.app.areacode.AreaCodeQuery;
import com.ruoyi.xq.dto.app.areacode.AreaCodeTree; import com.ruoyi.xq.dto.app.areacode.AreaCodeTree;
import com.ruoyi.xq.enums.common.AreaCodeLevelEnum;
import com.ruoyi.xq.mapper.AreaCodeMapper; import com.ruoyi.xq.mapper.AreaCodeMapper;
import com.ruoyi.xq.service.AreaCodeService; import com.ruoyi.xq.service.AreaCodeService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -83,4 +84,31 @@ public class AreaCodeServiceImpl extends ServiceImpl<AreaCodeMapper,AreaCode> im
} }
return new ArrayList<>(roots); return new ArrayList<>(roots);
} }
@Override
public List<AreaCodeTree> treeCity() {
List<AreaCode> list = this.list(Wrappers.lambdaQuery(AreaCode.class)
.in(AreaCode::getLevel, AreaCodeLevelEnum.PROVINCE,AreaCodeLevelEnum.CITY));
List<AreaCodeTree> nodeList = BeanConvertUtil.convertListTo(list, AreaCodeTree::new);
Map<Integer, AreaCodeTree> nodeMap = new HashMap<>();
Set<AreaCodeTree> roots = new HashSet<>();
// 遍历列表构建节点映射表
for (AreaCodeTree node : nodeList) {
nodeMap.put(node.getCode(), node);
if (node.getPcode() == 0 || !nodeMap.containsKey(node.getPcode())) {
roots.add(node);
}
}
// 建立父子关系
for (AreaCodeTree node : nodeList) {
if (nodeMap.containsKey(node.getPcode())) {
AreaCodeTree parentNode = nodeMap.get(node.getPcode());
parentNode.addChild(node);
}
}
return new ArrayList<>(roots);
}
} }