diff --git a/package.json b/package.json
index 9cabd49..0e01be3 100644
--- a/package.json
+++ b/package.json
@@ -3,8 +3,8 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
- "start:admin": "ng serve admin --proxy-config ./projects/admin/proxy.conf.json",
- "start:client": "ng serve client",
+ "start:admin": "ng serve admin --proxy-config ./proxy.conf.json",
+ "start:client": "ng serve client --proxy-config ./proxy.conf.json",
"build:admin": "ng build admin",
"build:client": "ng build client",
"watch": "ng build --watch --configuration development",
diff --git a/projects/admin/src/app/components/role-permission/role-permission.component.ts b/projects/admin/src/app/components/role-permission/role-permission.component.ts
index a20b78a..fd1e390 100644
--- a/projects/admin/src/app/components/role-permission/role-permission.component.ts
+++ b/projects/admin/src/app/components/role-permission/role-permission.component.ts
@@ -1,4 +1,4 @@
-import { PermItemDTO, UserRoleDTO } from "@admin/app/dtos/user.dto";
+import { PermItemDTO, UserRoleDTO } from "@cdk/dtos/user.dto";
import { ApiService } from "@admin/app/services";
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
diff --git a/projects/admin/src/app/components/user-list/user-list.component.ts b/projects/admin/src/app/components/user-list/user-list.component.ts
index d64c7a7..fcee467 100644
--- a/projects/admin/src/app/components/user-list/user-list.component.ts
+++ b/projects/admin/src/app/components/user-list/user-list.component.ts
@@ -1,4 +1,4 @@
-import { UserDTO, UserRoleDTO } from "@admin/app/dtos/user.dto";
+import { UserDTO, UserRoleDTO } from "@cdk/dtos/user.dto";
import { ApiService } from "@admin/app/services";
import {
Component,
diff --git a/projects/admin/src/app/pages/food/food.component.ts b/projects/admin/src/app/pages/food/food.component.ts
index f52d6ee..614f9cf 100644
--- a/projects/admin/src/app/pages/food/food.component.ts
+++ b/projects/admin/src/app/pages/food/food.component.ts
@@ -1,5 +1,5 @@
import { FoodFormComponent } from "@admin/app/components";
-import { GlobalEnum } from "@admin/app/dtos";
+import { GlobalEnum } from "@cdk/dtos";
import { ApiService } from "@admin/app/services";
import { Component, OnDestroy, OnInit, TemplateRef, ViewChild } from "@angular/core";
import { FormControl, FormGroup } from "@angular/forms";
diff --git a/projects/admin/src/app/pages/login/login.component.ts b/projects/admin/src/app/pages/login/login.component.ts
index a1ab908..13fcd6f 100644
--- a/projects/admin/src/app/pages/login/login.component.ts
+++ b/projects/admin/src/app/pages/login/login.component.ts
@@ -30,7 +30,7 @@ export class LoginComponent {
if (Utils.validateFormGroup(this.loginForm)) {
const { value } = this.loginForm;
const pwd = value.pwd as string;
- value["pwd"] = MD5(pwd).toString().substring(16).toUpperCase();
+ value["pwd"] = MD5(pwd).toString().slice(-16).toUpperCase();
this.loading = true;
const res = await lastValueFrom(
this.api.login(value).pipe(
diff --git a/projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts b/projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts
index e896e8d..cf75a4a 100644
--- a/projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts
+++ b/projects/admin/src/app/pages/organization/organization-list/organization-list.component.ts
@@ -4,7 +4,7 @@ import { NzDrawerRef, NzDrawerService } from "ng-zorro-antd/drawer";
import { AnyObject, TableListOption } from "@cdk/public-api";
import { DishFormComponent } from "@admin/app/components";
import { ApiService } from "@admin/app/services";
-import { OrgDTO } from "@admin/app/dtos";
+import { OrgDTO } from "@cdk/dtos";
import { Router } from "@angular/router";
import { NzModalService } from "ng-zorro-antd/modal";
import { lastValueFrom } from "rxjs";
diff --git a/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts b/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts
index 55099dd..0a26e4b 100644
--- a/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts
+++ b/projects/admin/src/app/pages/system/user-manage/user-manage.component.ts
@@ -1,5 +1,5 @@
import { FoodFormComponent } from "@admin/app/components";
-import { PermItemDTO, UserDTO, UserRoleDTO } from "@admin/app/dtos/user.dto";
+import { PermItemDTO, UserDTO, UserRoleDTO } from "@cdk/dtos/user.dto";
import { ApiService } from "@admin/app/services";
import { Component, OnChanges, OnInit, SimpleChanges, TemplateRef, ViewChild } from "@angular/core";
import { FormControl, FormGroup, FormGroupName } from "@angular/forms";
diff --git a/projects/admin/src/app/services/api.service.ts b/projects/admin/src/app/services/api.service.ts
index 32f43ea..35f566b 100644
--- a/projects/admin/src/app/services/api.service.ts
+++ b/projects/admin/src/app/services/api.service.ts
@@ -3,8 +3,7 @@ import { Injectable } from "@angular/core";
import { AnyObject, ResponseType } from "@cdk/types";
import { Utils } from "@cdk/utils";
import { Observable, map, of, tap } from "rxjs";
-import { PermItemDTO, UserDTO, UserRoleDTO } from "../dtos/user.dto";
-import { GlobalEnum, OrgDTO } from "../dtos";
+import { PermItemDTO, UserDTO, UserRoleDTO, GlobalEnum, OrgDTO } from "@cdk/public-api";
@Injectable({
providedIn: "root",
diff --git a/projects/admin/src/app/dtos/enum.dto.ts b/projects/cdk/src/dtos/enum.dto.ts
similarity index 100%
rename from projects/admin/src/app/dtos/enum.dto.ts
rename to projects/cdk/src/dtos/enum.dto.ts
diff --git a/projects/admin/src/app/dtos/index.ts b/projects/cdk/src/dtos/index.ts
similarity index 100%
rename from projects/admin/src/app/dtos/index.ts
rename to projects/cdk/src/dtos/index.ts
diff --git a/projects/admin/src/app/dtos/org.dto.ts b/projects/cdk/src/dtos/org.dto.ts
similarity index 100%
rename from projects/admin/src/app/dtos/org.dto.ts
rename to projects/cdk/src/dtos/org.dto.ts
diff --git a/projects/admin/src/app/dtos/user.dto.ts b/projects/cdk/src/dtos/user.dto.ts
similarity index 100%
rename from projects/admin/src/app/dtos/user.dto.ts
rename to projects/cdk/src/dtos/user.dto.ts
diff --git a/projects/cdk/src/public-api.ts b/projects/cdk/src/public-api.ts
index 7c81b53..57335e4 100644
--- a/projects/cdk/src/public-api.ts
+++ b/projects/cdk/src/public-api.ts
@@ -14,3 +14,5 @@ export * from "./table-list";
export * from "./storage";
export * from "./icons/icons-provider.module";
+
+export * from "./dtos";
diff --git a/projects/client/src/app/app-routing.module.ts b/projects/client/src/app/app-routing.module.ts
index dbb4cf5..54a9177 100644
--- a/projects/client/src/app/app-routing.module.ts
+++ b/projects/client/src/app/app-routing.module.ts
@@ -7,6 +7,7 @@ import {
FoodComponent,
LoginComponent,
MealSettingComponent,
+ OrgInfoComponent,
} from "./pages";
import { AppLayoutComponent } from "./components";
@@ -41,6 +42,15 @@ const routes: Routes = [
path: "dish",
component: DishComponent,
},
+ {
+ path: "system",
+ children: [
+ {
+ path: "org",
+ component: OrgInfoComponent,
+ },
+ ],
+ },
],
},
];
diff --git a/projects/client/src/app/app.module.ts b/projects/client/src/app/app.module.ts
index c63954f..4d1de7f 100644
--- a/projects/client/src/app/app.module.ts
+++ b/projects/client/src/app/app.module.ts
@@ -21,7 +21,9 @@ import {
DataVisComponent,
FoodComponent,
DishComponent,
+ OrgInfoComponent,
} from "./pages";
+import { HTTPInterceptor } from "./services/http.interceptor";
registerLocaleData(zh);
@@ -35,6 +37,7 @@ registerLocaleData(zh);
DataVisComponent,
FoodComponent,
DishComponent,
+ OrgInfoComponent,
],
imports: [
BrowserModule,
@@ -46,7 +49,10 @@ registerLocaleData(zh);
SharedModule,
TableListModule,
],
- providers: [{ provide: NZ_I18N, useValue: zh_CN }],
+ providers: [
+ { provide: NZ_I18N, useValue: zh_CN },
+ { provide: HTTP_INTERCEPTORS, useClass: HTTPInterceptor, multi: true },
+ ],
bootstrap: [AppComponent],
})
export class AppModule {}
diff --git a/projects/client/src/app/components/app-layout/app-layout.component.html b/projects/client/src/app/components/app-layout/app-layout.component.html
index 24e3030..f445fa0 100644
--- a/projects/client/src/app/components/app-layout/app-layout.component.html
+++ b/projects/client/src/app/components/app-layout/app-layout.component.html
@@ -59,7 +59,10 @@
-
+
+
diff --git a/projects/client/src/app/components/app-layout/app-layout.component.ts b/projects/client/src/app/components/app-layout/app-layout.component.ts
index 4c4de7b..761ce02 100644
--- a/projects/client/src/app/components/app-layout/app-layout.component.ts
+++ b/projects/client/src/app/components/app-layout/app-layout.component.ts
@@ -1,8 +1,10 @@
import { Component } from "@angular/core";
import { NavigationEnd, Router, RouterModule } from "@angular/router";
+import { NzMessageService } from "ng-zorro-antd/message";
import { NzModalService } from "ng-zorro-antd/modal";
-import { Subject, filter, takeUntil } from "rxjs";
+import { Subject, filter, lastValueFrom, takeUntil } from "rxjs";
+import { ClientApiService } from "../../services";
@Component({
selector: "app-layout",
@@ -10,7 +12,12 @@ import { Subject, filter, takeUntil } from "rxjs";
styleUrls: ["./app-layout.component.less"],
})
export class AppLayoutComponent {
- constructor(private router: Router, private modal: NzModalService) {
+ constructor(
+ private router: Router,
+ private modal: NzModalService,
+ private msg: NzMessageService,
+ private api: ClientApiService
+ ) {
this.router.events
.pipe(
takeUntil(this.unSubscribe$),
@@ -29,7 +36,12 @@ export class AppLayoutComponent {
this.modal.confirm({
nzTitle: "警告",
nzContent: "是否要退出登录?",
- nzOnOk: () => {},
+ nzOnOk: async () => {
+ const res = await lastValueFrom(this.api.logout());
+ this.msg.success(res.desc);
+ localStorage.removeItem(this.api.accountKey);
+ this.router.navigate(["/login"]);
+ },
});
}
}
diff --git a/projects/client/src/app/pages/index.ts b/projects/client/src/app/pages/index.ts
index b3c36fd..9cb6b68 100644
--- a/projects/client/src/app/pages/index.ts
+++ b/projects/client/src/app/pages/index.ts
@@ -4,3 +4,5 @@ export * from "./meal-setting/meal-setting.component";
export * from "./data-vis/data-vis.component";
export * from "./food/food.component";
export * from "./dish/dish.component";
+
+export * from "./system/org-info/org-info.component";
diff --git a/projects/client/src/app/pages/login/login.component.html b/projects/client/src/app/pages/login/login.component.html
index aa204d7..91f5803 100644
--- a/projects/client/src/app/pages/login/login.component.html
+++ b/projects/client/src/app/pages/login/login.component.html
@@ -30,7 +30,7 @@
-
+
diff --git a/projects/client/src/app/pages/login/login.component.ts b/projects/client/src/app/pages/login/login.component.ts
index f29b4fc..dd961e1 100644
--- a/projects/client/src/app/pages/login/login.component.ts
+++ b/projects/client/src/app/pages/login/login.component.ts
@@ -5,6 +5,7 @@ import { NzMessageService } from "ng-zorro-antd/message";
import { FormValidators } from "projects/cdk/src/public-api";
import { Utils } from "projects/cdk/src/utils";
import { finalize, lastValueFrom } from "rxjs";
+import { MD5 } from "crypto-js";
import { ClientApiService } from "../../services";
@Component({
@@ -17,7 +18,7 @@ export class LoginComponent {
public loginForm = new FormGroup({
uid: new FormControl("", [FormValidators.required("请输入账户")]),
- password: new FormControl("", [FormValidators.required("请输入密码")]),
+ pwd: new FormControl("", [FormValidators.required("请输入密码")]),
});
public loading: boolean = false;
@@ -27,6 +28,8 @@ export class LoginComponent {
async onLogin() {
if (Utils.validateFormGroup(this.loginForm)) {
const { value } = this.loginForm;
+ const pwd = value.pwd as string;
+ value["pwd"] = MD5(pwd).toString().slice(-16).toUpperCase();
this.loading = true;
const res = await lastValueFrom(
this.api.login(value).pipe(
@@ -35,6 +38,7 @@ export class LoginComponent {
})
)
);
+ localStorage.setItem(this.api.accountKey, JSON.stringify(res.body));
this.msg.success(res.desc);
this.router.navigate(["/"]);
}
diff --git a/projects/client/src/app/pages/system/org-info/org-info.component.html b/projects/client/src/app/pages/system/org-info/org-info.component.html
new file mode 100644
index 0000000..f633fba
--- /dev/null
+++ b/projects/client/src/app/pages/system/org-info/org-info.component.html
@@ -0,0 +1,158 @@
+
+
+
+
+ 单位基础信息
+
+
+
+ 编辑
+
+
+
+
+
+
+ 单位名称
+
+
+ {{org.name}}
+
+
+
+
+ 单位Logo
+
+
+
+
![]()
+
+
+
+
+
+ 地址
+
+
+ {{org.address ?? '-'}}
+
+
+
+
+ 联系人
+
+
+ {{org.contacts ?? '-'}}
+
+
+
+
+ 联系电话
+
+
+ {{org.phone ?? '-'}}
+
+
+
+
+ 邮箱
+
+
+ {{org.email ?? '-'}}
+
+
+
+
+
+
+
+
+ 账号信息
+
+
+ 仅支持主账号操作
+
+
+
+
+
+ 账号
+
+
+ {{account?.uid}}
+
+ 修改账号
+
+
+
+
+
+
+ 密码
+
+
+
+ 修改密码
+
+
+
+
+
+ 账号到期时间
+
+
+ {{org?.expire | date:'yyyy-MM-dd'}}
+
+ 续费
+
+
+
+
+
+
+
+
+
+
+
+ {{org.contacts ?? '-'}}
+
+
+ {{org.phone ?? '-'}}
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/projects/client/src/app/pages/system/org-info/org-info.component.less b/projects/client/src/app/pages/system/org-info/org-info.component.less
new file mode 100644
index 0000000..e69de29
diff --git a/projects/client/src/app/pages/system/org-info/org-info.component.ts b/projects/client/src/app/pages/system/org-info/org-info.component.ts
new file mode 100644
index 0000000..e63b45d
--- /dev/null
+++ b/projects/client/src/app/pages/system/org-info/org-info.component.ts
@@ -0,0 +1,68 @@
+import { Component, OnInit, TemplateRef } from "@angular/core";
+import { NzModalService } from "ng-zorro-antd/modal";
+import { format } from "date-fns";
+import { ClientApiService } from "../../../services";
+import { FormControl, FormGroup } from "@angular/forms";
+import { FormValidators } from "@cdk/validators";
+import { Utils } from "@cdk/utils";
+import { NzMessageService } from "ng-zorro-antd/message";
+
+@Component({
+ selector: "app-org-info",
+ templateUrl: "./org-info.component.html",
+ styleUrls: ["./org-info.component.less"],
+})
+export class OrgInfoComponent implements OnInit {
+ constructor(private api: ClientApiService, private modal: NzModalService, private msg: NzMessageService) {}
+
+ account: any = null;
+
+ pwdForm = new FormGroup({
+ oldPwd: new FormControl("", [FormValidators.required("请输入原密码")]),
+ newPwd: new FormControl("", [FormValidators.required("请输入新密码")]),
+ rePwd: new FormControl("", [FormValidators.required("请再次输入新密码")]),
+ });
+
+ ngOnInit(): void {
+ try {
+ const strageAccount = localStorage.getItem(this.api.accountKey);
+ if (strageAccount) {
+ this.account = JSON.parse(strageAccount);
+ }
+ } catch (error) {}
+ }
+
+ updateAccount(type: string | number, nzContent: TemplateRef<{}>) {
+ const nzTitle =
+ type === "uid"
+ ? "如需修改超级管理员账号,请联系:"
+ : `账号将于 ${format(type as number, "yyyy-MM-dd")} 到期,续费请联系`;
+ this.modal.info({
+ nzTitle,
+ nzContent,
+ nzOkText: "知道了",
+ });
+ }
+
+ cancelPwdForm() {
+ this.pwdForm.reset();
+ }
+
+ changePassword(nzContent: TemplateRef<{}>) {
+ this.modal.create({
+ nzTitle: "修改密码",
+ nzContent,
+ nzOnOk: async () => {
+ if (Utils.validateFormGroup(this.pwdForm)) {
+ const { value } = this.pwdForm;
+ if (value.newPwd !== value.rePwd) {
+ this.msg.error("两次密码输入不一致");
+ return false;
+ }
+ }
+ return false;
+ },
+ nzOnCancel: this.cancelPwdForm.bind(this),
+ });
+ }
+}
diff --git a/projects/client/src/app/services/client-api.service.ts b/projects/client/src/app/services/client-api.service.ts
index c7516eb..6dbf04f 100644
--- a/projects/client/src/app/services/client-api.service.ts
+++ b/projects/client/src/app/services/client-api.service.ts
@@ -1,5 +1,6 @@
-import { HttpClient } from "@angular/common/http";
+import { HttpClient, HttpParams } from "@angular/common/http";
import { Injectable } from "@angular/core";
+import { Utils, AnyObject, ResponseType, UserRoleDTO, PermItemDTO, UserDTO } from "@cdk/public-api";
import { map } from "rxjs";
@Injectable({
@@ -8,9 +9,7 @@ import { map } from "rxjs";
export class ClientApiService {
constructor(private http: HttpClient) {}
- login(v: {}) {
- return this.http.post("/", v);
- }
+ public accountKey = "CATERING_CLIENT_ACCOUNT";
page(v: {}, q: {}) {
return this.http.get("https://jsonplaceholder.typicode.com/users", v).pipe(
@@ -22,4 +21,58 @@ export class ClientApiService {
})
);
}
+
+ login(v: {}) {
+ const params = Utils.objectToHttpParams(v);
+ return this.http.get("/api/login", { params });
+ }
+
+ logout() {
+ return this.http.get("/api/logout");
+ }
+
+ getRoleList() {
+ return this.http.get>("/api/role");
+ }
+
+ deleteRole(roleId: string) {
+ const params = new HttpParams().set("roleId", roleId);
+ return this.http.delete("/api/role", {
+ params,
+ });
+ }
+
+ updateRole(rule: AnyObject) {
+ const body = Utils.objectToFormData(rule);
+ const method = rule["roleId"] ? "post" : "put";
+ return this.http[method]("/api/role", body);
+ }
+
+ getRolePerms() {
+ return this.http.get>("/api/role/item");
+ }
+
+ getUserList() {
+ return this.http.get>("/api/user");
+ }
+
+ checkUid(uid: string) {
+ const params = new HttpParams().set("uid", uid);
+ return this.http.delete("/api/user/check", {
+ params,
+ });
+ }
+
+ saveUser(user: AnyObject, edit: boolean) {
+ const body = Utils.objectToFormData(user);
+ const method = edit ? "post" : "put";
+ return this.http[method]("/api/user", body);
+ }
+
+ deleteUser(uid: string) {
+ const params = new HttpParams().set("uid", uid);
+ return this.http.delete("/api/user", {
+ params,
+ });
+ }
}
diff --git a/projects/client/src/app/services/http.interceptor.ts b/projects/client/src/app/services/http.interceptor.ts
index 82d9b50..d3951de 100644
--- a/projects/client/src/app/services/http.interceptor.ts
+++ b/projects/client/src/app/services/http.interceptor.ts
@@ -18,10 +18,10 @@ export class HTTPInterceptor implements HttpInterceptor {
private msgFlag = false;
- private localStroageKey = "catering";
+ private tokenKey = "CATERING_CLIENT_TOKEN";
intercept(req: HttpRequest, next: HttpHandler): Observable> {
- const token = localStorage.getItem(this.localStroageKey);
+ const token = localStorage.getItem(this.tokenKey);
if (token) {
req = req.clone({
@@ -39,7 +39,7 @@ export class HTTPInterceptor implements HttpInterceptor {
if (res instanceof HttpResponse) {
const Authorization = res.headers.get("Authorization");
if (Authorization) {
- localStorage.setItem(this.localStroageKey, Authorization);
+ localStorage.setItem(this.tokenKey, Authorization);
}
// if (this.decConfig.triggerError) {
diff --git a/projects/admin/proxy.conf.json b/proxy.conf.json
similarity index 100%
rename from projects/admin/proxy.conf.json
rename to proxy.conf.json