Newer
Older
taehui / taehui-fe / src / app / www / logic / commentary.ts
@Taehui Taehui on 20 Apr 974 bytes 2024-04-20 오후 2:05
import {
  doModifyCommentary as dbModifyCommentary,
  getCommentary as dbGetCommentary,
  postCommentary as dbPostCommentary,
  wipeCommentary as dbWipeCommentary,
} from "@/app/www/system/DB";
import { getDatetime } from "taehui-lib/date";

export const getCommentary = async () => {
  return dbGetCommentary();
};

export const postCommentary = async (
  avatarName: string,
  avatarCipher: string,
  avatarIP: string,
  text: string,
) => {
  return (
    !!text &&
    !!avatarCipher &&
    dbPostCommentary(avatarName, avatarCipher, avatarIP, getDatetime(), text)
  );
};

export const doModifyCommentary = async (
  commentaryID: number,
  avatarCipher: string,
  text: string,
) => {
  return (
    !!avatarCipher &&
    !!text &&
    dbModifyCommentary(commentaryID, avatarCipher, text)
  );
};

export const wipeCommentary = async (
  commentaryID: number,
  avatarCipher: string,
) => {
  return !!avatarCipher && dbWipeCommentary(commentaryID, avatarCipher);
};