corregido estado, estatus osp

This commit is contained in:
2026-04-12 20:59:15 -04:00
parent ce1727525b
commit 8f207e675c
6 changed files with 67 additions and 90 deletions

View File

@@ -158,7 +158,7 @@ export const trainingSurveys = t.pgTable(
updatedBy: t
.integer('updated_by')
.references(() => users.id, { onDelete: 'cascade' }),
surveyStatus: t.text('survey_status').notNull().default('PUBLICADO'),
surveyStatus: t.text('survey_status').notNull().default('COMPLETADA'),
...timestamps,
},
(trainingSurveys) => ({

View File

@@ -2,7 +2,7 @@ import { DRIZZLE_PROVIDER } from '@/database/drizzle-provider';
import * as schema from '@/database/index';
import { states } from '@/database/schema/general';
import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
import { eq } from 'drizzle-orm';
import { and, eq, ne } from 'drizzle-orm';
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
import { CreateStateDto } from './dto/create-state.dto';
import { UpdateStateDto } from './dto/update-state.dto';
@@ -15,14 +15,17 @@ export class StatesService {
) {}
async findAll(): Promise<State[]> {
return await this.drizzle.select().from(states);
return await this.drizzle
.select()
.from(states)
.where(ne(states.name, 'EMBAJADA'));
}
async findOne(id: number): Promise<State> {
const state = await this.drizzle
.select()
.from(states)
.where(eq(states.id, id));
.where(and(eq(states.id, id), ne(states.name, 'EMBAJADA')));
if (state.length === 0) {
throw new HttpException('State not found', HttpStatus.NOT_FOUND);

View File

@@ -1,29 +1,30 @@
import { DRIZZLE_PROVIDER } from 'src/database/drizzle-provider';
// import { Env, validateString } from '@/common/utils';
import { Inject, Injectable, HttpException, HttpStatus, NotFoundException, UnauthorizedException } from '@nestjs/common';
import { Inject, Injectable } from '@nestjs/common';
import { eq, ne } from 'drizzle-orm';
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
import * as schema from 'src/database/index';
import { states, municipalities, parishes } from 'src/database/index';
import { eq, like, or, SQL, sql, and, not } from 'drizzle-orm';
import * as bcrypt from 'bcryptjs';
import { State, Municipality, Parish } from './entities/user.entity';
import { municipalities, parishes, states } from 'src/database/index';
import { Municipality, Parish, State } from './entities/user.entity';
// import { PaginationDto } from '../../common/dto/pagination.dto';
@Injectable()
export class UsersService {
constructor(
@Inject(DRIZZLE_PROVIDER) private drizzle: NodePgDatabase<typeof schema>,
) { }
) {}
async StateAll(): Promise< State[]> {
async StateAll(): Promise<State[]> {
const find = await this.drizzle
.select()
.from(states)
.where(ne(states.name, 'EMBAJADA'));
return find;
}
async MunicioalityAll(id: string): Promise< Municipality[]> {
async MunicioalityAll(id: string): Promise<Municipality[]> {
const find = await this.drizzle
.select()
.from(municipalities)
@@ -32,7 +33,7 @@ export class UsersService {
return find;
}
async ParishAll(id: string): Promise< Parish[]> {
async ParishAll(id: string): Promise<Parish[]> {
const find = await this.drizzle
.select()
.from(parishes)
@@ -41,4 +42,3 @@ export class UsersService {
return find;
}
}