init
This commit is contained in:
50
backend/upms/pom.xml
Normal file
50
backend/upms/pom.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.k12study</groupId>
|
||||
<artifactId>k12study-backend</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>upms</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.k12study</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.k12study</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.k12study</groupId>
|
||||
<artifactId>common-mybatis</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.k12study</groupId>
|
||||
<artifactId>api-upms</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.k12study.upms;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"com.k12study.upms", "com.k12study.common"})
|
||||
public class UpmsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UpmsApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.k12study.upms.config;
|
||||
|
||||
import com.k12study.upms.UpmsApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(
|
||||
basePackages = "com.k12study.upms",
|
||||
excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = UpmsApplication.class)
|
||||
)
|
||||
public class UpmsModuleConfiguration {
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.k12study.upms.controller;
|
||||
|
||||
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.RouteNodeDto;
|
||||
import com.k12study.api.upms.dto.TenantNodeDto;
|
||||
import com.k12study.common.api.response.ApiResponse;
|
||||
import com.k12study.upms.service.UpmsQueryService;
|
||||
import java.util.List;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/upms")
|
||||
public class UpmsController {
|
||||
private final UpmsQueryService upmsQueryService;
|
||||
|
||||
public UpmsController(UpmsQueryService upmsQueryService) {
|
||||
this.upmsQueryService = upmsQueryService;
|
||||
}
|
||||
|
||||
@GetMapping("/routes")
|
||||
public ApiResponse<List<RouteNodeDto>> routes() {
|
||||
return ApiResponse.success(upmsQueryService.routes());
|
||||
}
|
||||
|
||||
@GetMapping("/areas/tree")
|
||||
public ApiResponse<List<AreaNodeDto>> areas() {
|
||||
return ApiResponse.success(upmsQueryService.areas());
|
||||
}
|
||||
|
||||
@GetMapping("/tenants/tree")
|
||||
public ApiResponse<List<TenantNodeDto>> tenants() {
|
||||
return ApiResponse.success(upmsQueryService.tenants());
|
||||
}
|
||||
|
||||
@GetMapping("/depts/tree")
|
||||
public ApiResponse<List<DeptNodeDto>> departments() {
|
||||
return ApiResponse.success(upmsQueryService.departments());
|
||||
}
|
||||
|
||||
@GetMapping("/current-user")
|
||||
public ApiResponse<CurrentRouteUserDto> currentUser() {
|
||||
return ApiResponse.success(upmsQueryService.currentUser());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.k12study.upms.domain;
|
||||
|
||||
public record SysArea(
|
||||
String areaCode,
|
||||
String parentCode,
|
||||
String areaName,
|
||||
String areaLevel,
|
||||
String provinceCode
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.k12study.upms.domain;
|
||||
|
||||
public record SysDept(
|
||||
String deptId,
|
||||
String parentDeptId,
|
||||
String tenantId,
|
||||
String deptName,
|
||||
String deptType,
|
||||
String deptPath
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.k12study.upms.domain;
|
||||
|
||||
public record SysTenant(
|
||||
String tenantId,
|
||||
String parentTenantId,
|
||||
String tenantName,
|
||||
String tenantType,
|
||||
String provinceCode,
|
||||
String areaCode,
|
||||
String tenantPath
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
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;
|
||||
|
||||
@Service
|
||||
public class UpmsQueryService {
|
||||
|
||||
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()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public List<AreaNodeDto> areas() {
|
||||
return List.of(
|
||||
new AreaNodeDto(
|
||||
"330000",
|
||||
"浙江省",
|
||||
"province",
|
||||
"330000",
|
||||
List.of(
|
||||
new AreaNodeDto("330100", "杭州市", "city", "330000", List.of())
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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")
|
||||
);
|
||||
}
|
||||
}
|
||||
23
backend/upms/src/main/resources/application.yml
Normal file
23
backend/upms/src/main/resources/application.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
server:
|
||||
port: 8082
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: k12study-upms
|
||||
autoconfigure:
|
||||
exclude:
|
||||
- org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
|
||||
- org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration
|
||||
- com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
|
||||
auth:
|
||||
enabled: true
|
||||
gateway-mode: true
|
||||
whitelist:
|
||||
- /actuator/**
|
||||
Reference in New Issue
Block a user