Skip to content

Commit

Permalink
[ADD] 添加 central-dashboard-view
Browse files Browse the repository at this point in the history
1. 完成基本框架的搭建
2. 完成基本框架的调试

Signed-off-by: Alan Yeh <[email protected]>
  • Loading branch information
alan-yeh committed Mar 31, 2024
1 parent f27f691 commit d330977
Show file tree
Hide file tree
Showing 64 changed files with 819 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ARG STUDIO_VERSION
COPY ${STUDIO_COMPONENT}-${STUDIO_VERSION}.jar application.jar

# 暴露端口
EXPOSE 3100
EXPOSE 8080
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
########################################################
# 使用 Spring Runner 运行本程序
########################################################
FROM image
FROM centralx/spring-runner:17

ARG STUDIO_COMPONENT
ARG STUDIO_VERSION

# 复制应用到工作目录
COPY ${STUDIO_COMPONENT}-${STUDIO_VERSION}.jar application.jar
COPY central-bootstrap-${STUDIO_VERSION}.jar application.jar

# 暴露端口
EXPOSE 3000
EXPOSE 8080
14 changes: 10 additions & 4 deletions central-bootstrap/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ spring:
name: central-studio
secret: AkJSi2kmH7vSO5lJcvY
version: @{ project.version }@
# datasource:
# name: master
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://mysql:3306/centralx?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
# username: root
# password: root
datasource:
name: master
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/centralx?useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
driver-class-name: org.h2.Driver
url: jdbc:h2:./centralx-h2
username: centralx
password: central.x
servlet:
multipart:
# 限制请求的大小和上传文件的大小
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@

package central.studio.dashboard.controller.index;

import central.studio.dashboard.logic.organization.AccountLogic;
import central.data.organization.Account;
import central.lang.Stringx;
import central.studio.dashboard.logic.organization.AccountLogic;
import jakarta.annotation.Nullable;
import lombok.Setter;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -46,7 +47,6 @@
* @since 2023/10/07
*/
@Controller
@RequiresAuthentication
@RequestMapping("/dashboard")
public class IndexController {

Expand All @@ -57,8 +57,7 @@ public class IndexController {
* 返回首页静态页面
*/
@GetMapping("/")
public View index(@RequestAttribute String accountId) {
accountLogic.findById(accountId);
public View index() {
return new InternalResourceView("index.html");
}

Expand All @@ -67,8 +66,10 @@ public View index(@RequestAttribute String accountId) {
*/
@ResponseBody
@GetMapping("/api/account")
public Account getAccount(@RequestAttribute String accountId) {
public @Nullable Account getAccount(@RequestAttribute(required = false) String accountId) {
if (Stringx.isNullOrBlank(accountId)) {
return null;
}
return accountLogic.findById(accountId);
}

}
13 changes: 0 additions & 13 deletions central-identity/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions central-logging/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions central-multicast/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions central-provider/Dockerfile

This file was deleted.

13 changes: 0 additions & 13 deletions central-storage/Dockerfile

This file was deleted.

28 changes: 14 additions & 14 deletions central-studio-views/central-dashboard-view/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>npm-install</id>
<phase>generate-sources</phase>
<configuration>
<workingDirectory>${project.basedir}/src/main/node</workingDirectory>
<executable>npm</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
<!-- <execution>-->
<!-- <id>npm-install</id>-->
<!-- <phase>generate-sources</phase>-->
<!-- <configuration>-->
<!-- <workingDirectory>${project.basedir}/src/main/node</workingDirectory>-->
<!-- <executable>npm</executable>-->
<!-- <arguments>-->
<!-- <argument>install</argument>-->
<!-- </arguments>-->
<!-- </configuration>-->
<!-- <goals>-->
<!-- <goal>exec</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<execution>
<id>npm-run-build</id>
<phase>generate-sources</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
<title>CentralX</title>
</head>
<body>
<div id="app"></div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { sha256 } from 'js-sha256'
import type { Account } from '@centralx/types'
import type { AxiosInstance } from 'axios'

/**
* 认证中心接口
*/
export class IdentityBroker {
private http: AxiosInstance

public constructor(private client: AxiosInstance) {
this.http = client
}

/**
* 登录
* @param account 帐户名
* @param password 密码
*/
public async login(account: string, password: string): Promise<void> {
// 对密码进行 sha256 摘要后再提交
// 防止原始密码被截取
const hash = sha256.create()
hash.update(password)

const response = await this.http.post('/identity/api/login', {
account: account,
password: hash.hex(),
secret: 'lLS4p6skBbBVZX30zR5'
})

if (response.status !== 200) {
throw new Error(response.data.message)
}
}

/**
* 退出登录
*/
public async logout(): Promise<void> {
return this.http.get('/identity/api/logout')
}

/**
* 获取当前已登录用户
*/
public async getAccount(): Promise<Account | null> {
try {
const response = await this.http.get('/identity/api/account')
if (response.status !== 200) {
return null
}
return response.data
} catch (error) {
return null
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./IdentityBroker";
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./identity";
export * from "./portal";
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Account } from '@centralx/types'
import type { AxiosInstance } from 'axios'

/**
* 门户(首页)接口
*/
export class PortalBroker {
private http: AxiosInstance

public constructor(private client: AxiosInstance) {
this.http = client
}

/**
* 获取当前用户信息
*/
public async getAccount(): Promise<Account | null> {
const response = await this.http.get('/dashboard/api/account')
return response.data
}

/**
* 退出登录
*/
public async logout(): Promise<void> {
return this.http.get('/dashboard/__logout')
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./PortalBroker";
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Account, Unit } from "../organization";

export interface Role {
id?: string;
applicationId?: string;
code?: string;
name?: string;
unitId?: string;
unit?: Unit;
enabled?: boolean;
remark?: string;

creatorId?: string;
createDate?: number;
creator?: Account;
modifierId?: string;
modifiedDate?: number;
modifier?: Account;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Role } from "./Role";

export type { Role };
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type {};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from "./authority";
export * from "./gateway";
export * from "./identity";
export * from "./log";
export * from "./multicast";
export * from "./organization";
export * from "./saas";
export * from "./storage";
export * from "./system";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type {};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export interface Account {
id?: string;
username?: string;
email?: string;
mobile?: string;
name?: string;
avatar?: string;
admin?: boolean;
supervisor?: boolean;

enabled?: boolean;
deleted?: boolean;

creatorId?: string;
createDate?: number;
creator?: Account;
modifierId?: string;
modifiedDate?: number;
modifier?: Account;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Account } from "./Account";
import type { Department } from "./Department";
import type { Unit } from "./Unit";
import type { Rank } from "./Rank";

export interface AccountUnit {
id?: string;
accountId?: string;
account?: Account;
unitId?: string;
unit?: Unit;
departments?: Department[];
rankId?: string;
rank?: Rank;
primary?: boolean;

creatorId?: string;
createDate?: number;
creator?: Account;
modifierId?: string;
modifiedDate?: number;
modifier?: Account;
}
Loading

0 comments on commit d330977

Please sign in to comment.