"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCountTindakanRepository = exports.deleteTindakanRepository = exports.updateTindakanDataAllRepository = exports.getDataTindakanAll = exports.getDataTindakanId = exports.createTindakanRepository = void 0; const db_1 = require("../../../db"); const database_handler_1 = require("../../../db/database.handler"); const time_1 = require("../../../middlewares/time"); const dotenv = __importStar(require("dotenv")); dotenv.config(); const createTindakanRepository = (namatindakan, tariftindakan) => __awaiter(void 0, void 0, void 0, function* () { const maxTindakanId = yield (0, database_handler_1.generateMaxDb1)("ms_tindakan_id_seq", "tindakan_id"); const createTindakan = yield db_1.prismaDb1.mstindakan.create({ data: { idtindakan: maxTindakanId, created_at: (0, time_1.dateNow)(), created_by: 1, namatindakan: namatindakan, tariftindakan: tariftindakan }, select: { idtindakan: true, created_at: true, created_by: true, namatindakan: true, tariftindakan: true }, }); return createTindakan; }); exports.createTindakanRepository = createTindakanRepository; const getDataTindakanId = (tindakan_id) => __awaiter(void 0, void 0, void 0, function* () { const tindakan = yield db_1.prismaDb1.mstindakan.findFirst({ where: { idtindakan: tindakan_id, deleted_at: null, }, select: { idtindakan: true, created_at: true, created_by: true, namatindakan: true, tariftindakan: true }, }); return tindakan; }); exports.getDataTindakanId = getDataTindakanId; const getDataTindakanAll = () => __awaiter(void 0, void 0, void 0, function* () { const tindakan = yield db_1.prismaDb1.mstindakan.findMany({ where: { deleted_by: null, }, select: { idtindakan: true, created_at: true, created_by: true, namatindakan: true, tariftindakan: true }, }); return tindakan; }); exports.getDataTindakanAll = getDataTindakanAll; const updateTindakanDataAllRepository = (namatindakan, tariftindakan, tindakan_id) => __awaiter(void 0, void 0, void 0, function* () { const updateTindakan = yield db_1.prismaDb1.mstindakan.update({ where: { idtindakan: tindakan_id, }, data: { modified_at: (0, time_1.dateNow)(), modified_by: 1, namatindakan: namatindakan, tariftindakan: tariftindakan }, select: { idtindakan: true, created_at: true, created_by: true, namatindakan: true, tariftindakan: true }, }); return updateTindakan; }); exports.updateTindakanDataAllRepository = updateTindakanDataAllRepository; const deleteTindakanRepository = (tindakan_id) => __awaiter(void 0, void 0, void 0, function* () { const deleteUser = yield db_1.prismaDb1.mstindakan.update({ where: { idtindakan: tindakan_id, }, data: { deleted_at: (0, time_1.dateNow)(), deleted_by: 1, }, select: { idtindakan: true, created_at: true, created_by: true, namatindakan: true, tariftindakan: true }, }); return deleteUser; }); exports.deleteTindakanRepository = deleteTindakanRepository; const getCountTindakanRepository = () => __awaiter(void 0, void 0, void 0, function* () { const tindakanCount = yield db_1.prismaDb1.mstindakan.count({ where: { deleted_by: null, }, }); return tindakanCount; }); exports.getCountTindakanRepository = getCountTindakanRepository;