Wrapped up discharge form close #159
This commit is contained in:
@@ -3,6 +3,7 @@ import pool from "../../db";
|
||||
import { Member, MemberCardDetails, MemberLight, memberSettings, MemberState, PaginatedMembers } from '@app/shared/types/member'
|
||||
import { logger } from "../logging/logger";
|
||||
import { memberCache } from "../../routes/auth";
|
||||
import * as mariadb from 'mariadb';
|
||||
|
||||
export async function getFilteredMembers(
|
||||
page: number = 1,
|
||||
@@ -98,12 +99,12 @@ export async function getUserData(userID: number): Promise<Member> {
|
||||
return res[0] ?? null;
|
||||
}
|
||||
|
||||
export async function setUserState(userID: number, state: MemberState) {
|
||||
export async function setUserState(userID: number, state: MemberState, con: mariadb.Pool | mariadb.Connection = pool) {
|
||||
try {
|
||||
const sql = `UPDATE members
|
||||
SET state = ?
|
||||
WHERE id = ?;`;
|
||||
return await pool.query(sql, [state, userID]);
|
||||
return await con.query(sql, [state, userID]);
|
||||
} catch (error) {
|
||||
logger.error('app', 'Error setting user state', error);
|
||||
} finally {
|
||||
|
||||
@@ -3,6 +3,7 @@ import { PromotionDetails, PromotionSummary } from "@app/shared/types/rank"
|
||||
import pool from "../../db";
|
||||
import { PagedData } from "@app/shared/types/pagination";
|
||||
import { toDate, toDateIgnoreZone, toDateTime } from "@app/shared/utils/time";
|
||||
import * as mariadb from 'mariadb';
|
||||
|
||||
export async function getAllRanks() {
|
||||
const rows = await pool.query(
|
||||
@@ -105,4 +106,14 @@ export async function getPromotionsOnDay(day: Date): Promise<PromotionDetails[]>
|
||||
let batchPromotion = await pool.query(sql, [dayString]) as PromotionDetails[];
|
||||
|
||||
return batchPromotion;
|
||||
}
|
||||
|
||||
export async function cancelLatestRank(userID: number, con: mariadb.Pool | mariadb.Connection = pool): Promise<boolean> {
|
||||
try {
|
||||
let sql = `CALL sp_end_member_rank(?,NOW())`;
|
||||
con.query(sql, [userID]);
|
||||
return true;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
13
api/src/services/db/unitService.ts
Normal file
13
api/src/services/db/unitService.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import pool from "../../db";
|
||||
import * as mariadb from 'mariadb';
|
||||
|
||||
|
||||
export async function cancelLatestUnit(userID: number, con: mariadb.Pool | mariadb.Connection = pool): Promise<boolean> {
|
||||
try {
|
||||
let sql = `CALL sp_end_member_unit(?,NOW())`;
|
||||
con.query(sql, [userID]);
|
||||
return true;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user