first commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import {
|
||||
PaginateCompaniesResults,
|
||||
SysAdminPaginateCompaniesParams,
|
||||
SysAdminUpdateCompanyParams,
|
||||
SysAdminSetCompanyBannedParams,
|
||||
} from "../../../Models/Companies/Companies.Interface";
|
||||
import { ApiValidationError } from "../../../Models/Server.Error.model";
|
||||
import { ApiVoidResult } from "../../../Models/Api.VoidResult.type";
|
||||
import { Body, Controller, Middlewares, Post, Response, Route, SuccessResponse } from "tsoa";
|
||||
import { SA_CompaniesService } from "./SysAdminCompanies.Service";
|
||||
import { sysAdminAuthMiddleware } from "../../../middleware/sysadminAuth";
|
||||
|
||||
@Route("sysadmin/companies")
|
||||
export class SysAdminCompaniesController extends Controller {
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post("paginate")
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
public async sysAdminPaginate(
|
||||
@Body() requestBody: SysAdminPaginateCompaniesParams,
|
||||
): Promise<PaginateCompaniesResults | ApiValidationError> {
|
||||
try {
|
||||
const { payload, ...cleanRequestBody } = requestBody as any;
|
||||
const result = await new SA_CompaniesService().sysAdminPaginate(cleanRequestBody);
|
||||
this.setStatus(200);
|
||||
return result;
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post("update")
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
public async sysAdminUpdate(
|
||||
@Body() requestBody: SysAdminUpdateCompanyParams,
|
||||
): Promise<ApiVoidResult | ApiValidationError> {
|
||||
try {
|
||||
await new SA_CompaniesService().sysAdminUpdate(requestBody);
|
||||
this.setStatus(200);
|
||||
return { success: true, message: "ok" };
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post("set-banned")
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
public async sysAdminSetBanned(
|
||||
@Body() requestBody: SysAdminSetCompanyBannedParams,
|
||||
): Promise<ApiVoidResult | ApiValidationError> {
|
||||
try {
|
||||
await new SA_CompaniesService().sysAdminSetBanned(requestBody);
|
||||
this.setStatus(200);
|
||||
return { success: true, message: "ok" };
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { connect } from "mongoose";
|
||||
import {
|
||||
PaginateCompaniesResults,
|
||||
SysAdminPaginateCompaniesParams,
|
||||
SysAdminUpdateCompanyParams,
|
||||
SysAdminSetCompanyBannedParams,
|
||||
} from "../../../Models/Companies/Companies.Interface";
|
||||
import CompaniesList from "../../../Models/Companies/Companies";
|
||||
|
||||
export class SA_CompaniesService {
|
||||
public async sysAdminPaginate(data: SysAdminPaginateCompaniesParams): Promise<PaginateCompaniesResults> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await CompaniesList.sysAdminPaginate(data);
|
||||
}
|
||||
|
||||
public async sysAdminUpdate(data: SysAdminUpdateCompanyParams): Promise<void> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await CompaniesList.sysAdminUpdate(data);
|
||||
}
|
||||
|
||||
public async sysAdminSetBanned(data: SysAdminSetCompanyBannedParams): Promise<void> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await CompaniesList.sysAdminSetBanned(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
PaginateServicesResults,
|
||||
SysAdminPaginateServicesParams,
|
||||
SysAdminSetServiceBannedParams,
|
||||
} from "../../../Models/Services/Service.Interface";
|
||||
import { ApiValidationError } from "../../../Models/Server.Error.model";
|
||||
import { ApiVoidResult } from "../../../Models/Api.VoidResult.type";
|
||||
import { Body, Controller, Middlewares, Post, Response, Route, SuccessResponse } from "tsoa";
|
||||
import { SA_ServicesService } from "./SysAdminServices.Service";
|
||||
import { sysAdminAuthMiddleware } from "../../../middleware/sysadminAuth";
|
||||
|
||||
@Route("sysadmin/services")
|
||||
export class SysAdminServicesController extends Controller {
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post("paginate")
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
public async sysAdminPaginate(
|
||||
@Body() requestBody: SysAdminPaginateServicesParams,
|
||||
): Promise<PaginateServicesResults | ApiValidationError> {
|
||||
try {
|
||||
const { payload, ...cleanRequestBody } = requestBody as any;
|
||||
const result = await new SA_ServicesService().sysAdminPaginate(cleanRequestBody);
|
||||
this.setStatus(200);
|
||||
return result;
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post("set-banned")
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
public async sysAdminSetBanned(
|
||||
@Body() requestBody: SysAdminSetServiceBannedParams,
|
||||
): Promise<ApiVoidResult | ApiValidationError> {
|
||||
try {
|
||||
await new SA_ServicesService().sysAdminSetBanned(requestBody);
|
||||
this.setStatus(200);
|
||||
return { success: true, message: "ok" };
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { connect } from "mongoose";
|
||||
import {
|
||||
PaginateServicesResults,
|
||||
SysAdminPaginateServicesParams,
|
||||
SysAdminSetServiceBannedParams,
|
||||
} from "../../../Models/Services/Service.Interface";
|
||||
import ServiceList from "../../../Models/Services/Service";
|
||||
|
||||
export class SA_ServicesService {
|
||||
public async sysAdminPaginate(data: SysAdminPaginateServicesParams): Promise<PaginateServicesResults> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await ServiceList.sysAdminPaginate(data);
|
||||
}
|
||||
|
||||
public async sysAdminSetBanned(data: SysAdminSetServiceBannedParams): Promise<void> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await ServiceList.sysAdminSetBanned(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Middlewares,
|
||||
Post,
|
||||
Response,
|
||||
Route,
|
||||
SuccessResponse,
|
||||
} from "tsoa";
|
||||
|
||||
import { ApiValidationError } from "../../../Models/Server.Error.model";
|
||||
import { ApiVoidResult } from "../../../Models/Api.VoidResult.type";
|
||||
import { sysAdminAuthMiddleware } from "../../../middleware/sysadminAuth";
|
||||
import { SysAdminUsersService } from "./SysAdminUsers.Service";
|
||||
import {
|
||||
SysAdminPaginateUsersParams,
|
||||
SysAdminUpdateProfileParams,
|
||||
SysAdminSetVerifiedParams,
|
||||
SysAdminDeleteUserParams,
|
||||
SysAdminOrganizationsStatusParams,
|
||||
SysAdminUserOrganizationsResult,
|
||||
PaginateUsersResults,
|
||||
} from "../../../Models/Users/Users.Interface";
|
||||
|
||||
@Route("sysadmin/users")
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
export class SysAdminUsersController extends Controller {
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post("paginate")
|
||||
public async paginateUsers(
|
||||
@Body() requestBody: SysAdminPaginateUsersParams
|
||||
): Promise<PaginateUsersResults | ApiValidationError> {
|
||||
try {
|
||||
const users = await new SysAdminUsersService().paginateUsers(requestBody);
|
||||
this.setStatus(200);
|
||||
return users;
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "El perfil fue modificado con éxito")
|
||||
@Post("update")
|
||||
public async updateProfile(
|
||||
@Body() requestBody: SysAdminUpdateProfileParams
|
||||
): Promise<ApiVoidResult | ApiValidationError> {
|
||||
try {
|
||||
await new SysAdminUsersService().updateProfile(requestBody);
|
||||
this.setStatus(200);
|
||||
return {
|
||||
success: true,
|
||||
message: "Done",
|
||||
};
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "El estado fue modificado con éxito")
|
||||
@Post("set-verified")
|
||||
public async setVerifiedStatus(
|
||||
@Body() requestBody: SysAdminSetVerifiedParams
|
||||
): Promise<ApiVoidResult | ApiValidationError> {
|
||||
try {
|
||||
await new SysAdminUsersService().setVerifiedStatus(requestBody);
|
||||
this.setStatus(200);
|
||||
return {
|
||||
success: true,
|
||||
message: "Done",
|
||||
};
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post("organizations-status")
|
||||
public async organizationsStatus(
|
||||
@Body() requestBody: SysAdminOrganizationsStatusParams
|
||||
): Promise<SysAdminUserOrganizationsResult | ApiValidationError> {
|
||||
try {
|
||||
const result = await new SysAdminUsersService().organizationsStatus(requestBody);
|
||||
this.setStatus(200);
|
||||
return result;
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "El usuario fue eliminado")
|
||||
@Post("delete")
|
||||
public async deleteUser(
|
||||
@Body() requestBody: SysAdminDeleteUserParams
|
||||
): Promise<ApiVoidResult | ApiValidationError> {
|
||||
try {
|
||||
await new SysAdminUsersService().deleteUser(requestBody);
|
||||
this.setStatus(200);
|
||||
return {
|
||||
success: true,
|
||||
message: "Done",
|
||||
};
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import UserList from "../../../Models/Users/Users";
|
||||
import { connect } from "mongoose";
|
||||
import {
|
||||
SysAdminPaginateUsersParams,
|
||||
SysAdminUpdateProfileParams,
|
||||
SysAdminSetVerifiedParams,
|
||||
SysAdminDeleteUserParams,
|
||||
SysAdminOrganizationsStatusParams,
|
||||
SysAdminUserOrganizationsResult,
|
||||
PaginateUsersResults,
|
||||
} from "../../../Models/Users/Users.Interface";
|
||||
|
||||
export class SysAdminUsersService {
|
||||
public async paginateUsers(
|
||||
params: SysAdminPaginateUsersParams
|
||||
): Promise<PaginateUsersResults> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await UserList.sysAdminPaginateUsers(params);
|
||||
}
|
||||
|
||||
public async updateProfile(params: SysAdminUpdateProfileParams): Promise<void> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
await UserList.sysAdminUpdateProfile(params);
|
||||
}
|
||||
|
||||
public async setVerifiedStatus(params: SysAdminSetVerifiedParams): Promise<void> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
await UserList.sysAdminSetVerifiedStatus(params);
|
||||
}
|
||||
|
||||
public async organizationsStatus(
|
||||
params: SysAdminOrganizationsStatusParams
|
||||
): Promise<SysAdminUserOrganizationsResult> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await UserList.sysAdminOrganizationsStatus(params);
|
||||
}
|
||||
|
||||
public async deleteUser(params: SysAdminDeleteUserParams): Promise<void> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
await UserList.sysAdminDeleteUser(params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import {
|
||||
PaginateWapServerResults,
|
||||
SysAdminGetWapServerParams,
|
||||
} from "../../../Models/WapServer/WapServer.Interface";
|
||||
import { ApiValidationError } from "../../../Models/Server.Error.model";
|
||||
import { Body, Controller, Middlewares, Post, Response, Route, SuccessResponse } from "tsoa";
|
||||
import { SA_WapServerService } from "./SysAdminWapServer.Service";
|
||||
import { sysAdminAuthMiddleware } from "../../../middleware/sysadminAuth";
|
||||
|
||||
@Route("sysadmin/wapserver/get")
|
||||
export class SysAdminWapServerGetController extends Controller {
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@SuccessResponse(200, "Done")
|
||||
@Post()
|
||||
@Middlewares(sysAdminAuthMiddleware)
|
||||
public async sysAdminGetWapServers(
|
||||
@Body() requestBody: SysAdminGetWapServerParams,
|
||||
): Promise<PaginateWapServerResults | ApiValidationError> {
|
||||
try {
|
||||
const result = await new SA_WapServerService().sysAdminGetWapServers(requestBody);
|
||||
this.setStatus(200);
|
||||
return result;
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { connect } from "mongoose";
|
||||
|
||||
import {
|
||||
PaginateWapServerParams,
|
||||
PaginateWapServerResults,
|
||||
} from "../../../Models/WapServer/WapServer.Interface";
|
||||
import WapServerList from "../../../Models/WapServer/WapServer";
|
||||
|
||||
export class SA_WapServerService {
|
||||
public async sysAdminGetWapServers(data: PaginateWapServerParams): Promise<PaginateWapServerResults> {
|
||||
await connect(`${process.env.DATABASE_CONNECTION}`);
|
||||
return await WapServerList.sysAdminGetWapServers(data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user