更新+mock部分
This commit is contained in:
@@ -5,6 +5,7 @@ import com.k12study.api.upms.dto.CurrentRouteUserDto;
|
||||
import com.k12study.api.upms.dto.DeptNodeDto;
|
||||
import com.k12study.api.upms.dto.RouteNodeDto;
|
||||
import com.k12study.api.upms.dto.TenantNodeDto;
|
||||
import com.k12study.api.upms.remote.UpmsApiPaths;
|
||||
import com.k12study.common.api.response.ApiResponse;
|
||||
import com.k12study.upms.service.UpmsQueryService;
|
||||
import java.util.List;
|
||||
@@ -13,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/upms")
|
||||
@RequestMapping(UpmsApiPaths.BASE)
|
||||
public class UpmsController {
|
||||
private final UpmsQueryService upmsQueryService;
|
||||
|
||||
@@ -26,22 +27,22 @@ public class UpmsController {
|
||||
return ApiResponse.success(upmsQueryService.routes());
|
||||
}
|
||||
|
||||
@GetMapping("/areas/tree")
|
||||
@GetMapping("/areas")
|
||||
public ApiResponse<List<AreaNodeDto>> areas() {
|
||||
return ApiResponse.success(upmsQueryService.areas());
|
||||
}
|
||||
|
||||
@GetMapping("/tenants/tree")
|
||||
@GetMapping("/tenants")
|
||||
public ApiResponse<List<TenantNodeDto>> tenants() {
|
||||
return ApiResponse.success(upmsQueryService.tenants());
|
||||
}
|
||||
|
||||
@GetMapping("/depts/tree")
|
||||
@GetMapping("/departments")
|
||||
public ApiResponse<List<DeptNodeDto>> departments() {
|
||||
return ApiResponse.success(upmsQueryService.departments());
|
||||
}
|
||||
|
||||
@GetMapping("/current-user")
|
||||
@GetMapping("/users/current")
|
||||
public ApiResponse<CurrentRouteUserDto> currentUser() {
|
||||
return ApiResponse.success(upmsQueryService.currentUser());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.k12study.upms.domain;
|
||||
|
||||
public record SysArea(
|
||||
String areaCode,
|
||||
String parentCode,
|
||||
long id,
|
||||
long pid,
|
||||
long adcode,
|
||||
String areaName,
|
||||
String areaLevel,
|
||||
String provinceCode
|
||||
String areaType,
|
||||
String areaStatus,
|
||||
String delFlag
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ public record SysDept(
|
||||
String tenantId,
|
||||
String deptName,
|
||||
String deptType,
|
||||
String adcode,
|
||||
String tenantPath,
|
||||
String deptPath
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ public record SysTenant(
|
||||
String parentTenantId,
|
||||
String tenantName,
|
||||
String tenantType,
|
||||
String provinceCode,
|
||||
String areaCode,
|
||||
String tenantPath
|
||||
String adcode,
|
||||
String tenantPath,
|
||||
String status
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -3,109 +3,17 @@ package com.k12study.upms.service;
|
||||
import com.k12study.api.upms.dto.AreaNodeDto;
|
||||
import com.k12study.api.upms.dto.CurrentRouteUserDto;
|
||||
import com.k12study.api.upms.dto.DeptNodeDto;
|
||||
import com.k12study.api.upms.dto.LayoutType;
|
||||
import com.k12study.api.upms.dto.RouteMetaDto;
|
||||
import com.k12study.api.upms.dto.RouteNodeDto;
|
||||
import com.k12study.api.upms.dto.TenantNodeDto;
|
||||
import com.k12study.common.security.context.RequestUserContextHolder;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
public interface UpmsQueryService {
|
||||
List<RouteNodeDto> routes();
|
||||
|
||||
@Service
|
||||
public class UpmsQueryService {
|
||||
List<AreaNodeDto> areas();
|
||||
|
||||
public List<RouteNodeDto> routes() {
|
||||
return List.of(
|
||||
new RouteNodeDto(
|
||||
"dashboard",
|
||||
"/",
|
||||
"dashboard",
|
||||
"dashboard",
|
||||
LayoutType.SIDEBAR,
|
||||
new RouteMetaDto("控制台", "layout-dashboard", List.of("dashboard:view"), false),
|
||||
List.of()
|
||||
),
|
||||
new RouteNodeDto(
|
||||
"tenant-management",
|
||||
"/tenant",
|
||||
"tenant-management",
|
||||
"tenant",
|
||||
LayoutType.SIDEBAR,
|
||||
new RouteMetaDto("租户组织", "building-2", List.of("tenant:view"), false),
|
||||
List.of()
|
||||
)
|
||||
);
|
||||
}
|
||||
List<TenantNodeDto> tenants();
|
||||
|
||||
public List<AreaNodeDto> areas() {
|
||||
return List.of(
|
||||
new AreaNodeDto(
|
||||
"330000",
|
||||
"浙江省",
|
||||
"province",
|
||||
"330000",
|
||||
List.of(
|
||||
new AreaNodeDto("330100", "杭州市", "city", "330000", List.of())
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
List<DeptNodeDto> departments();
|
||||
|
||||
public List<TenantNodeDto> tenants() {
|
||||
return List.of(
|
||||
new TenantNodeDto(
|
||||
"SCH-HQ",
|
||||
"K12Study 总校",
|
||||
"head_school",
|
||||
"330000",
|
||||
"330100",
|
||||
"/SCH-HQ/",
|
||||
List.of(
|
||||
new TenantNodeDto(
|
||||
"SCH-ZJ-HZ-01",
|
||||
"杭州分校",
|
||||
"city_school",
|
||||
"330000",
|
||||
"330100",
|
||||
"/SCH-HQ/SCH-ZJ-HZ-01/",
|
||||
List.of()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public List<DeptNodeDto> departments() {
|
||||
return List.of(
|
||||
new DeptNodeDto(
|
||||
"DEPT-HQ",
|
||||
"总校教学部",
|
||||
"grade",
|
||||
"SCH-HQ",
|
||||
"/DEPT-HQ/",
|
||||
List.of(
|
||||
new DeptNodeDto(
|
||||
"DEPT-HQ-MATH",
|
||||
"数学学科组",
|
||||
"subject",
|
||||
"SCH-HQ",
|
||||
"/DEPT-HQ/DEPT-HQ-MATH/",
|
||||
List.of()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public CurrentRouteUserDto currentUser() {
|
||||
var context = RequestUserContextHolder.get();
|
||||
return new CurrentRouteUserDto(
|
||||
context == null ? "U10001" : context.userId(),
|
||||
context == null ? "admin" : context.username(),
|
||||
context == null ? "K12Study 管理员" : context.displayName(),
|
||||
context == null ? "SCH-HQ" : context.tenantId(),
|
||||
context == null ? "DEPT-HQ-ADMIN" : context.deptId(),
|
||||
List.of("dashboard:view", "tenant:view", "dept:view")
|
||||
);
|
||||
}
|
||||
CurrentRouteUserDto currentUser();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.k12study.upms.service.impl;
|
||||
|
||||
import com.k12study.api.upms.dto.AreaNodeDto;
|
||||
import com.k12study.api.upms.dto.CurrentRouteUserDto;
|
||||
import com.k12study.api.upms.dto.DeptNodeDto;
|
||||
import com.k12study.api.upms.dto.LayoutType;
|
||||
import com.k12study.api.upms.dto.RouteMetaDto;
|
||||
import com.k12study.api.upms.dto.RouteNodeDto;
|
||||
import com.k12study.api.upms.dto.TenantNodeDto;
|
||||
import com.k12study.common.security.context.RequestUserContextHolder;
|
||||
import com.k12study.upms.service.UpmsQueryService;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UpmsQueryServiceImpl implements UpmsQueryService {
|
||||
|
||||
@Override
|
||||
public List<RouteNodeDto> routes() {
|
||||
return List.of(
|
||||
new RouteNodeDto(
|
||||
"dashboard",
|
||||
"/",
|
||||
"dashboard",
|
||||
"dashboard",
|
||||
LayoutType.SIDEBAR,
|
||||
new RouteMetaDto("控制台", "layout-dashboard", List.of("dashboard:view"), false),
|
||||
List.of()
|
||||
),
|
||||
new RouteNodeDto(
|
||||
"tenant-management",
|
||||
"/tenant",
|
||||
"tenant-management",
|
||||
"tenant",
|
||||
LayoutType.SIDEBAR,
|
||||
new RouteMetaDto("租户组织", "building-2", List.of("tenant:view"), false),
|
||||
List.of()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AreaNodeDto> areas() {
|
||||
return List.of(
|
||||
new AreaNodeDto(
|
||||
"330000",
|
||||
"100000",
|
||||
"浙江省",
|
||||
"PROVINCE",
|
||||
List.of(
|
||||
new AreaNodeDto(
|
||||
"330100",
|
||||
"330000",
|
||||
"杭州市",
|
||||
"CITY",
|
||||
List.of()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TenantNodeDto> tenants() {
|
||||
return List.of(
|
||||
new TenantNodeDto(
|
||||
"SCH-HQ",
|
||||
null,
|
||||
"K12Study 总校",
|
||||
"HEAD_SCHOOL",
|
||||
"330100",
|
||||
"/SCH-HQ/",
|
||||
List.of(
|
||||
new TenantNodeDto(
|
||||
"SCH-ZJ-HZ-01",
|
||||
"SCH-HQ",
|
||||
"杭州分校",
|
||||
"CITY_SCHOOL",
|
||||
"330100",
|
||||
"/SCH-HQ/SCH-ZJ-HZ-01/",
|
||||
List.of()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptNodeDto> departments() {
|
||||
return List.of(
|
||||
new DeptNodeDto(
|
||||
"DEPT-HQ",
|
||||
null,
|
||||
"总校教学部",
|
||||
"GRADE",
|
||||
"SCH-HQ",
|
||||
"330100",
|
||||
"/SCH-HQ/",
|
||||
"/DEPT-HQ/",
|
||||
List.of(
|
||||
new DeptNodeDto(
|
||||
"DEPT-HQ-MATH",
|
||||
"DEPT-HQ",
|
||||
"数学学科组",
|
||||
"SUBJECT",
|
||||
"SCH-HQ",
|
||||
"330100",
|
||||
"/SCH-HQ/",
|
||||
"/DEPT-HQ/DEPT-HQ-MATH/",
|
||||
List.of()
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrentRouteUserDto currentUser() {
|
||||
var context = RequestUserContextHolder.get();
|
||||
return new CurrentRouteUserDto(
|
||||
context == null ? "U10001" : context.userId(),
|
||||
context == null ? "admin" : context.username(),
|
||||
context == null ? "K12Study 管理员" : context.displayName(),
|
||||
"330100",
|
||||
context == null ? "SCH-HQ" : context.tenantId(),
|
||||
"/SCH-HQ/",
|
||||
context == null ? "DEPT-HQ-ADMIN" : context.deptId(),
|
||||
"/DEPT-HQ/DEPT-HQ-ADMIN/",
|
||||
List.of("dashboard:view", "tenant:view", "dept:view")
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user