Skip to content

Commit

Permalink
完善日历组件,完善模态框,完善数据传递,解决组件未导入显示不了问题,调整组件间隙,完成根据重复类型显示重复日期的逻辑。剩余任务:插入其他分…
Browse files Browse the repository at this point in the history
…组的假数据,添加groupItem、planitem的响应事件,需要完成planItem的左滑动画,完成所有api,完善数据库
  • Loading branch information
checkma-xh committed Mar 7, 2024
1 parent baca365 commit 3457f04
Show file tree
Hide file tree
Showing 38 changed files with 930 additions and 365 deletions.
Binary file modified database/database.sqlite
Binary file not shown.
44 changes: 28 additions & 16 deletions database/src/controller/AuthController.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { AppDataSource } from "../data-source";
import { NextFunction, Request, Response } from "express";
import { UserInfo } from "../entity/UserInfo";
Expand All @@ -7,8 +8,8 @@ import * as dotenv from "dotenv";
dotenv.configDotenv();

const SECRET_KEY = process.env.SECRET_KEY;
const ACCESS_TOKEN_EXPIRATION = parseInt( process.env.ACCESS_TOKEN_EXPIRATION );
const REFRESH_TOKEN_EXPIRATION = parseInt( process.env.REFRESH_TOKEN_EXPIRATION );
const ACCESS_TOKEN_EXPIRATION = parseInt(process.env.ACCESS_TOKEN_EXPIRATION);
const REFRESH_TOKEN_EXPIRATION = parseInt(process.env.REFRESH_TOKEN_EXPIRATION);
const ACCESS_TOKEN_OPTIONS = {
expiresIn: ACCESS_TOKEN_EXPIRATION,
};
Expand All @@ -17,39 +18,50 @@ const REFRESH_TOKEN_OPTIONS = {
};

export class AuthController {
private UserInfoRepository = AppDataSource.getRepository( UserInfo );
private UserInfoRepository = AppDataSource.getRepository(UserInfo);
private ORMToObject(ORM: any) {
const object = {};
const entries = Object.entries(ORM);
entries.forEach((item: any) => {
object[item[0]] = item[1];
});
return object;
}

async login ( request: Request, response: Response, next: NextFunction ) {
async login(request: Request, response: Response, next: NextFunction) {
const email = request.body.email;
const passwordHash = request.body.passwordHash;
const user = await this.UserInfoRepository.findOneBy( { email: email, passwordHash: passwordHash } );
if ( !user ) {
response.status( 404 ).json( { message: "userInfo not found" } );
const user = await this.UserInfoRepository
.createQueryBuilder("user")
.where("user.email = :email AND user.passwordHash = :passwordHash", { email, passwordHash })
.getOne();
if (!user) {
response.status(404).json({ message: "userInfo not found" });
return;
}
response.json(
{
currentUser: user,
accessToken: jwt.sign( { id: user.id }, SECRET_KEY, ACCESS_TOKEN_OPTIONS ),
refreshToken: jwt.sign( { id: user.id }, SECRET_KEY, REFRESH_TOKEN_OPTIONS ),
} );
accessToken: jwt.sign(this.ORMToObject(user), SECRET_KEY, ACCESS_TOKEN_OPTIONS),
refreshToken: jwt.sign(this.ORMToObject(user), SECRET_KEY, REFRESH_TOKEN_OPTIONS),
});
}

async logout ( request: Request, response: Response, next: NextFunction ) { }
async logout(request: Request, response: Response, next: NextFunction) { }

async refresh ( request: Request, response: Response, next: NextFunction ) { }
async refresh(request: Request, response: Response, next: NextFunction) { }

async deactivate ( request: Request, response: Response, next: NextFunction ) { }
async deactivate(request: Request, response: Response, next: NextFunction) { }

async register ( request: Request, response: Response, next: NextFunction ) { }
async register(request: Request, response: Response, next: NextFunction) { }

async VerificationCodeRequest (
async VerificationCodeRequest(
request: Request,
response: Response,
next: NextFunction,
) { }

async VerificationCodeVerify (
async VerificationCodeVerify(
request: Request,
response: Response,
next: NextFunction,
Expand Down
72 changes: 44 additions & 28 deletions database/src/controller/PlanManagementController.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { AppDataSource } from "../data-source";
import { NextFunction, Request, Response } from "express";
import { UserInfo } from "../entity/UserInfo";
Expand All @@ -6,74 +7,89 @@ import { PriorityInfo } from "../entity/PriorityInfo";
import { PlanInfo } from "../entity/PlanInfo";
import * as jwt from "jsonwebtoken";
import * as dotenv from "dotenv";
import { userInfo } from "os";

dotenv.configDotenv();

const SECRET_KEY = process.env.SECRET_KEY
const SECRET_KEY = process.env.SECRET_KEY;

export class PlanManagementController {
private UserInfoRepository = AppDataSource.getRepository( UserInfo );
private GroupInfoRepository = AppDataSource.getRepository( GroupInfo );
private PriorityInfoRepository = AppDataSource.getRepository( PriorityInfo );
private PlanInfoRepository = AppDataSource.getRepository( PlanInfo );
private UserInfoRepository = AppDataSource.getRepository(UserInfo);
private GroupInfoRepository = AppDataSource.getRepository(GroupInfo);
private PriorityInfoRepository = AppDataSource.getRepository(PriorityInfo);
private PlanInfoRepository = AppDataSource.getRepository(PlanInfo);

async createPlan ( request: Request, response: Response, next: NextFunction ) { }
async createPlan(request: Request, response: Response, next: NextFunction) { }

async completePlan (
async completePlan(
request: Request,
response: Response,
next: NextFunction,
) { }

async deletePlan ( request: Request, response: Response, next: NextFunction ) { }
async deletePlan(request: Request, response: Response, next: NextFunction) { }

async setPlan ( request: Request, response: Response, next: NextFunction ) { }
async setPlan(request: Request, response: Response, next: NextFunction) { }

async createGroup ( request: Request, response: Response, next: NextFunction ) { }
async createGroup(request: Request, response: Response, next: NextFunction) { }

async getGroups ( request: Request, response: Response, next: NextFunction ) {
async getGroups(request: Request, response: Response, next: NextFunction) {
const decodeToken = jwt.verify(request.headers.authorization.split(" ")[1], SECRET_KEY);
if (!decodeToken) {
response.status(404).json({ message: "no permission" });
return;
response.status(404).json({ message: "no permission" });
return;
}
const groups = await this.GroupInfoRepository.find();
if ( !groups ) {
response.status( 404 ).json( { message: "groups information not found" } );
if (!groups) {
response.status(404).json({ message: "groups information not found" });
return;
}
response.json( groups );
response.json(groups);
}

async deleteGroup ( request: Request, response: Response, next: NextFunction ) { }
async deleteGroup(request: Request, response: Response, next: NextFunction) { }

async setGroup ( request: Request, response: Response, next: NextFunction ) { }
async setGroup(request: Request, response: Response, next: NextFunction) { }

async getPlansByDeleted (
async getPlansByDeleted(
request: Request,
response: Response,
next: NextFunction,
) { }

async getPlansByGroupName (
async getPlansByGroupName(
request: Request,
response: Response,
next: NextFunction,
) { }
) {
// const decodeToken = jwt.verify(request.headers.authorization.split(" ")[1], SECRET_KEY);
// if (!decodeToken) {
// response.status(404).json({ message: "no permission" });
// return;
// }
const plans = await this.PlanInfoRepository
.createQueryBuilder("plan")
.leftJoinAndSelect("plan.user", "user")
.leftJoinAndSelect("plan.group", "group")
.where("user.id = :id", { id: 1 })
.andWhere("group.name = :groupName", { groupName: request.query.groupName })
.getMany();
if (!plans) {
response.status(404).json({ message: "plan information not found" });
return;
}
response.json(plans);
}

async getPlansByPeriod (
request: Request,
response: Response,
next: NextFunction,
) { }

async getCompletedPlans (
async getPlansByPeriod(
request: Request,
response: Response,
next: NextFunction,
) { }

async getPlansByContent (

async getPlansByContent(
request: Request,
response: Response,
next: NextFunction,
Expand Down
6 changes: 6 additions & 0 deletions database/src/controller/UserInfoController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AppDataSource } from "../data-source";
import { NextFunction, Request, Response } from "express";
import { UserInfo } from "../entity/UserInfo";
import * as dotenv from "dotenv";
import * as jwt from "jsonwebtoken";

dotenv.configDotenv();

Expand All @@ -10,6 +11,11 @@ export class UserInfoController {
private UserInfoRepository = AppDataSource.getRepository( UserInfo );

async getUserInfo ( request: Request, response: Response, next: NextFunction ) {
const decodeToken = jwt.verify(request.headers.authorization.split(" ")[1], SECRET_KEY);
if (!decodeToken) {
response.status(404).json({ message: "no permission" });
return;
}
const id = parseInt( request.params.id );
const user = await this.UserInfoRepository.findOneBy( { id } );
if ( !user ) {
Expand Down
11 changes: 6 additions & 5 deletions database/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { PriorityInfo } from "./entity/PriorityInfo";
import { RepeatInfo } from "./entity/RepeatInfo";

export const AppDataSource = new DataSource({
type: "sqlite",
database: "database.sqlite",
type : "sqlite",
database : "database.sqlite",
synchronize: true,
logging: false,
entities: [UserInfo, PlanInfo, GroupInfo, PriorityInfo, RepeatInfo],
migrations: [],
logging : false,
entities : [UserInfo, PlanInfo, GroupInfo, PriorityInfo, RepeatInfo],
migrations : [],
subscribers: [],
cache : false,
});
Loading

0 comments on commit 3457f04

Please sign in to comment.