提交 99370747 编写于 作者: ibizdev's avatar ibizdev

zhangzihan 发布系统代码 [TrainSys,网页端]

上级 fd5756c6
import { AuthService } from '../auth-service';
/**
* 书权限服务对象基类
*
* @export
* @class BookAuthServiceBase
* @extends {AuthService}
*/
export class BookAuthServiceBase extends AuthService {
/**
* 应用实体动态模型文件路径
*
* @protected
* @type {string}
* @memberof BookAuthServiceBase
*/
protected dynaModelFilePath:string = "PSSYSAPPS/Web/PSAPPDATAENTITIES/Book.json";
/**
* Creates an instance of BookAuthServiceBase.
*
* @param {*} [opts={}]
* @memberof BookAuthServiceBase
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 根据当前数据获取实体操作标识
*
* @param {*} activeKey 实体权限数据缓存标识
* @param {*} dataaccaction 操作标识
* @param {*} mainSateOPPrivs 传入数据主状态操作标识集合
* @returns {any}
* @memberof BookAuthServiceBase
*/
public getOPPrivs(activeKey: string,dataaccaction:string, mainSateOPPrivs: any): any {
let result: any = { [dataaccaction]: 1 };
const curDefaultOPPrivs: any = this.getSysOPPrivs();
// 统一资源权限
if (curDefaultOPPrivs && (Object.keys(curDefaultOPPrivs).length > 0) && (curDefaultOPPrivs[dataaccaction] === 0)) {
result[dataaccaction] = 0;
}
// 主状态权限
if (mainSateOPPrivs && (Object.keys(mainSateOPPrivs).length > 0) && mainSateOPPrivs.hasOwnProperty(dataaccaction)) {
result[dataaccaction] = result[dataaccaction] && mainSateOPPrivs[dataaccaction];
}
// 实体级权限
if (!this.getActivedDeOPPrivs(activeKey, dataaccaction)) {
result[dataaccaction] = 0;
}
return result;
}
}
\ No newline at end of file
import { BookAuthServiceBase } from './book-auth-service-base';
/**
* 书权限服务对象
*
* @export
* @class BookAuthService
* @extends {BookAuthServiceBase}
*/
export default class BookAuthService extends BookAuthServiceBase {
/**
* 基础权限服务实例
*
* @private
* @type {BookAuthService}
* @memberof BookAuthService
*/
private static basicUIServiceInstance: BookAuthService;
/**
* 动态模型服务存储Map对象
*
* @private
* @type {Map<string, any>}
* @memberof BookAuthService
*/
private static AuthServiceMap: Map<string, any> = new Map();
/**
* Creates an instance of BookAuthService.
*
* @param {*} [opts={}]
* @memberof BookAuthService
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 通过应用上下文获取实例对象
*
* @public
* @memberof BookAuthService
*/
public static getInstance(context: any): BookAuthService {
if (!this.basicUIServiceInstance) {
this.basicUIServiceInstance = new BookAuthService({context:context});
}
if (!context.srfdynainstid) {
return this.basicUIServiceInstance;
} else {
if (!BookAuthService.AuthServiceMap.get(context.srfdynainstid)) {
BookAuthService.AuthServiceMap.set(context.srfdynainstid, new BookAuthService({context:context}));
}
return BookAuthService.AuthServiceMap.get(context.srfdynainstid);
}
}
}
\ No newline at end of file
import { EntityBase } from 'ibiz-core';
import { IBook } from '../interface';
/**
* 书基类
*
* @export
* @abstract
* @class BookBase
* @extends {EntityBase}
* @implements {IBook}
*/
export abstract class BookBase extends EntityBase implements IBook {
/**
* 实体名称
*
* @readonly
* @type {string}
* @memberof BookBase
*/
get srfdename(): string {
return 'BOOK';
}
get srfkey() {
return this.bookid;
}
set srfkey(val: any) {
this.bookid = val;
}
get srfmajortext() {
return this.bookname;
}
set srfmajortext(val: any) {
this.bookname = val;
}
/**
* 书名称
*/
bookname?: any;
/**
* 建立人
*/
createman?: any;
/**
* 建立时间
*/
createdate?: any;
/**
* 更新人
*/
updateman?: any;
/**
* 更新时间
*/
updatedate?: any;
/**
* 书标识
*/
bookid?: any;
/**
* 组织机构标识
*/
orgid?: any;
/**
* 组织部门标识
*/
deptid?: any;
/**
* 重置实体数据
*
* @private
* @param {*} [data={}]
* @memberof BookBase
*/
reset(data: any = {}): void {
super.reset(data);
this.bookid = data.bookid || data.srfkey;
this.bookname = data.bookname || data.srfmajortext;
}
}
import keys from './book-keys';
import { IContext, IEntityLocalDataService, IParams } from 'ibiz-core';
import { GlobalService } from '../../service';
import { IBook } from '../interface';
/**
* BookDTOdto辅助类
*
* @export
* @class BookDTOHelp
*/
export class BookDTOHelp {
/**
* 获取数据服务
*
* @param {IContext} context 应用上下文对象
* @returns {*}
* @memberof BookDTOHelp
*/
public static async getService(context: IContext): Promise<IEntityLocalDataService<IBook>> {
return new GlobalService().getService('Book',context);
}
/**
* DTO转化成数据对象
*
* @param {IContext} context 应用上下文对象
* @param {IParams} source dto对象
* @returns {*}
* @memberof BookDTOHelp
*/
public static async ToDataObj(context: IContext, source: IParams) {
const _data: any = {};
// 书标识
_data.bookid = source.bookid;
// 书名称
_data.bookname = source.bookname;
// 建立时间
_data.createdate = source.createdate;
// 建立人
_data.createman = source.createman;
// 组织部门标识
_data.deptid = source.deptid;
// 组织机构标识
_data.orgid = source.orgid;
// 更新时间
_data.updatedate = source.updatedate;
// 更新人
_data.updateman = source.updateman;
// 处理预置字段(以srf开头)
if(source && Object.keys(source).length >0){
Object.keys(source).forEach((key:string) =>{
if(key.startsWith('srf')){
_data[key] = source[key];
}
})
}
return _data;
}
/**
* 转化数组(dto转化成数据对象)
*
* @param {IContext} context 应用上下文对象
* @param {any[]} data 数据对象
* @returns {any[]}
* @memberof BookDTOHelp
*/
public static async ToDataObjArray(context: IContext, data: any[]) {
const _data: any[] = [];
if (data && Array.isArray(data) && data.length > 0) {
for (let i = 0; i < data.length; i++) {
const tempdata = await this.ToDataObj(context, data[i]);
_data.push(tempdata);
}
}
return _data;
}
/**
* 数据对象转化成DTO
*
* @param {IContext} context 应用上下文对象
* @param {*} source 数据对象
* @returns {*}
* @memberof BookDTOHelp
*/
public static async ToDto(context: IContext, source: IParams) {
const _data: any = {};
const excludes: string[] = [];
// 书标识
_data.bookid = source.bookid;
// 书名称
_data.bookname = source.bookname;
// 建立时间
_data.createdate = source.createdate;
// 建立人
_data.createman = source.createman;
// 组织部门标识
_data.deptid = source.deptid;
// 组织机构标识
_data.orgid = source.orgid;
// 更新时间
_data.updatedate = source.updatedate;
// 更新人
_data.updateman = source.updateman;
// 附加额外数据
if (source && Object.keys(source).length > 0 && keys) {
Object.keys(source).forEach((key: string) => {
if (!keys.includes(key) && !excludes.includes(key)) {
_data[key] = source[key];
}
})
}
return _data;
}
/**
* 转化数组(数据对象转化成dto)
*
* @param {IContext} context 应用上下文对象
* @param {any[]} data
* @returns {any[]}
* @memberof BookDTOHelp
*/
public static async ToDtoArray(context: IContext, data: any[]) {
const _data: any[] = [];
if (data && Array.isArray(data) && data.length > 0) {
for (let i = 0; i < data.length; i++) {
const tempdata = await this.ToDto(context, data[i]);
_data.push(tempdata);
}
}
return _data;
}
/**
* 处理响应dto对象
*
* @param {*} context 应用上下文对象
* @param {*} data 响应dto对象
* @returns {*}
* @memberof BookDTOHelp
*/
public static async set(context: IContext, data: any) {
const _data: IParams = await this.ToDataObj(context, data);
return _data;
}
/**
* 处理请求数据对象
*
* @param {*} context 应用上下文对象
* @param {*} data 数据对象
* @returns {*}
* @memberof BookDTOHelp
*/
public static async get(context: IContext, data: any = {}) {
return await this.ToDto(context, data);
}
/**
* 获取缓存数据
*
* @param {*} context 应用上下文对象
* @param {*} srfkey 数据主键
* @returns {*}
* @memberof BookDTOHelp
*/
public static async getCacheData(context: IContext, srfkey: string) {
const targetService: IEntityLocalDataService<IBook> = await this.getService(context);
const result = await targetService.getLocal(context, srfkey);
if(result){
return await this.ToDto(context,result);
}
}
/**
* 获取缓存数组
*
* @param {*} context 应用上下文对象
* @returns {any[]}
* @memberof BookDTOHelp
*/
public static async getCacheDataArray(context: IContext) {
const targetService: IEntityLocalDataService<IBook> = await this.getService(context);
const result = await targetService.getLocals(context);
if(result && result.length >0){
return await this.ToDtoArray(context,result);
}else{
return [];
}
}
/**
* 设置缓存数据
*
* @param {*} context 应用上下文对象
* @param {any} data 数据
* @returns {any[]}
* @memberof BookDTOHelp
*/
public static async setCacheData(context: IContext, data: any) {
const targetService: IEntityLocalDataService<IBook> = await this.getService(context);
const _data: any = await this.set(context, data);
await targetService.addLocal(context, _data);
}
/**
* 设置缓存数组
*
* @param {*} context 应用上下文对象
* @param {any[]} data 数据
* @returns {any[]}
* @memberof BookDTOHelp
*/
public static async setCacheDataArray(context: IContext, data: any[]) {
if (data && data.length > 0) {
const targetService: IEntityLocalDataService<IBook> = await this.getService(context);
for (let i = 0; i < data.length; i++) {
const _data = await this.set(context, data[i]);
await targetService.addLocal(context, _data);
}
}
}
}
export default [
'bookname',
'createman',
'createdate',
'updateman',
'updatedate',
'bookid',
'orgid',
'deptid',
];
import { BookBase } from './book-base';
/**
* 书
*
* @export
* @class Book
* @extends {BookBase}
* @implements {IBook}
*/
export class Book extends BookBase {
/**
* 克隆当前实体
*
* @return {*}
* @memberof Book
*/
clone(): Book {
return new Book(this);
}
}
export default Book;
export * from './interface';
export * from './raw-material/raw-material';
export * from './book/book';
import { IEntityBase } from 'ibiz-core';
/**
* 书
*
* @export
* @interface IBook
* @extends {IEntityBase}
*/
export interface IBook extends IEntityBase {
/**
* 书名称
*/
bookname?: any;
/**
* 建立人
*/
createman?: any;
/**
* 建立时间
*/
createdate?: any;
/**
* 更新人
*/
updateman?: any;
/**
* 更新时间
*/
updatedate?: any;
/**
* 书标识
*/
bookid?: any;
/**
* 组织机构标识
*/
orgid?: any;
/**
* 组织部门标识
*/
deptid?: any;
}
export * from './entity';
export * from './iraw-material';
export * from './ibook';
......@@ -54,6 +54,7 @@ export class AuthServiceRegister{
*/
protected init(): void {
AuthServiceRegister.allAuthServiceMap.set('rawmaterial', () => import('../authservice/raw-material/raw-material-auth-service'));
AuthServiceRegister.allAuthServiceMap.set('book', () => import('../authservice/book/book-auth-service'));
}
/**
......
......@@ -55,6 +55,7 @@ export class UIServiceRegister {
*/
protected init(): void {
UIServiceRegister.allUIServiceMap.set('rawmaterial', () => import('../uiservice/raw-material/raw-material-ui-service'));
UIServiceRegister.allUIServiceMap.set('book', () => import('../uiservice/book/book-ui-service'));
}
/**
......
import { CodeListService } from '../app/codelist-service';
import { EntityBaseService, IContext, HttpResponse } from 'ibiz-core';
import { GlobalService } from '../global.service';
import { IBook, Book } from '../../entities';
import keys from '../../entities/book/book-keys';
import { BookDTOHelp } from '../../entities/book/book-dto-help';
/**
* 书服务对象基类
*
* @export
* @class BookBaseService
* @extends {EntityBaseService}
*/
export class BookBaseService extends EntityBaseService<IBook> {
protected get keys(): string[] {
return keys;
}
protected SYSTEMNAME = 'TrainSys';
protected APPNAME = 'Web';
protected APPDENAME = 'Book';
protected APPWFDENAME = 'BOOK';
protected APPDENAMEPLURAL = 'Books';
protected dynaModelFilePath:string = 'PSSYSAPPS/Web/PSAPPDATAENTITIES/Book.json';
protected APPDEKEY = 'bookid';
protected APPDETEXT = 'bookname';
protected quickSearchFields = ['bookname',];
protected selectContextParam = {
};
constructor(opts?: any) {
super(opts, 'Book');
}
newEntity(data: IBook): Book {
return new Book(data);
}
/**
* Create
*
* @param {*} [_context={}]
* @param {*} [_data = {}]
* @returns {Promise<HttpResponse>}
* @memberof BookService
*/
async Create(_context: any = {}, _data: any = {}): Promise<HttpResponse> {
try {
_data = await this.beforeExecuteAction(_context,_data,'Create');
if (!_data.srffrontuf || _data.srffrontuf != 1) {
_data[this.APPDEKEY] = null;
}
if (_data.srffrontuf != null) {
delete _data.srffrontuf;
}
_data = await BookDTOHelp.get(_context,_data);
const res = await this.http.post(`/books`, _data);
res.data = await BookDTOHelp.set(_context,res.data);
return res;
} catch (error) {
return this.handleResponseError(error);
}
}
/**
* Get
*
* @param {*} [_context={}]
* @param {*} [_data = {}]
* @returns {Promise<HttpResponse>}
* @memberof BookService
*/
async Get(_context: any = {}, _data: any = {}): Promise<HttpResponse> {
try {
const res = await this.http.get(`/books/${encodeURIComponent(_context.book)}`, _data);
res.data = await BookDTOHelp.set(_context,res.data);
res.data = await this.afterExecuteAction(_context,res?.data,'Get');
return res;
} catch (error) {
return this.handleResponseError(error);
}
}
/**
* GetDraft
*
* @param {*} [_context={}]
* @param {*} [_data = {}]
* @returns {Promise<HttpResponse>}
* @memberof BookService
*/
async GetDraft(_context: any = {}, _data: any = {}): Promise<HttpResponse> {
try {
_data[this.APPDENAME?.toLowerCase()] = undefined;
_data[this.APPDEKEY] = undefined;
const res = await this.http.get(`/books/getdraft`, _data);
res.data = await BookDTOHelp.set(_context,res.data);
return res;
} catch (error) {
return this.handleResponseError(error);
}
}
/**
* Remove
*
* @param {*} [_context={}]
* @param {*} [_data = {}]
* @returns {Promise<HttpResponse>}
* @memberof BookService
*/
async Remove(_context: any = {}, _data: any = {}): Promise<HttpResponse> {
try {
const res = await this.http.delete(`/books/${encodeURIComponent(_context.book)}`, _data);
return res;
} catch (error) {
return this.handleResponseError(error);
}
}
/**
* Update
*
* @param {*} [_context={}]
* @param {*} [_data = {}]
* @returns {Promise<HttpResponse>}
* @memberof BookService
*/
async Update(_context: any = {}, _data: any = {}): Promise<HttpResponse> {
try {
_data = await this.beforeExecuteAction(_context,_data,'Update');
_data = await BookDTOHelp.get(_context,_data);
const res = await this.http.put(`/books/${encodeURIComponent(_context.book)}`, _data);
res.data = await BookDTOHelp.set(_context,res.data);
return res;
} catch (error) {
return this.handleResponseError(error);
}
}
/**
* FetchDefault
*
* @param {*} [_context={}]
* @param {*} [_data = {}]
* @returns {Promise<HttpResponse>}
* @memberof BookService
*/
async FetchDefault(_context: any = {}, _data: any = {}): Promise<HttpResponse> {
try {
const res = await this.http.post(`/books/fetchdefault`, _data);
res.data = await BookDTOHelp.ToDataObjArray(_context,res.data);
res.data = await this.afterExecuteActionBatch(_context,res?.data,'FetchDefault');
return res;
} catch (error) {
return this.handleResponseError(error);
}
}
/**
* Select
*
* @param {*} [_context={}]
* @param {*} [_data = {}]
* @returns {Promise<HttpResponse>}
* @memberof BookService
*/
async Select(_context: any = {}, _data: any = {}): Promise<HttpResponse> {
try {
const res = await this.http.post(`/books/select`, _data);
return res;
} catch (error) {
return this.handleResponseError(error);
}
}
}
import { BookBaseService } from './book-base.service';
/**
* 书服务
*
* @export
* @class BookService
* @extends {BookBaseService}
*/
export class BookService extends BookBaseService {
/**
* Creates an instance of BookService.
* @memberof BookService
*/
constructor(opts?: any) {
const { context: context, tag: cacheKey } = opts;
super(context);
if (___ibz___.sc.has(cacheKey)) {
return ___ibz___.sc.get(cacheKey);
}
___ibz___.sc.set(cacheKey, this);
}
/**
* 获取实例
*
* @static
* @param 应用上下文
* @return {*} {BookService}
* @memberof BookService
*/
static getInstance(context?: any): BookService {
const cacheKey: string = context?.srfdynainstid ? `${context.srfdynainstid}BookService` : `BookService`;
if (!___ibz___.sc.has(cacheKey)) {
new BookService({ context: context, tag: cacheKey });
}
return ___ibz___.sc.get(cacheKey);
}
}
export default BookService;
......@@ -29,4 +29,14 @@ export class GlobalService {
async getRawMaterialService(context?: any) {
return (await import('./raw-material/raw-material.service')).default.getInstance(context);
}
/**
* 书服务
*
* @param context 应用上下文
* @return {Book}
* @memberof GlobalService
*/
async getBookService(context?: any) {
return (await import('./book/book.service')).default.getInstance(context);
}
}
export { GlobalService } from './global.service';
export * from './raw-material/raw-material.service';
export * from './book/book.service';
import { IPSAppDEUIAction } from '@ibiz/dynamic-model-api';
import { UIServiceBase } from 'ibiz-core';
import { AppLogicFactory } from 'ibiz-vue';
import { AuthServiceRegister } from '../../register';
import { GlobalService } from '../../service';
/**
* 书UI服务对象基类
*
* @export
* @class BookUIServiceBase
*/
export class BookUIServiceBase extends UIServiceBase {
/**
* 应用实体动态模型文件路径
*
* @protected
* @type {string}
* @memberof BookUIServiceBase
*/
protected dynaModelFilePath:string = "PSSYSAPPS/Web/PSAPPDATAENTITIES/Book.json";
/**
* Creates an instance of BookUIServiceBase.
*
* @param {*} [opts={}]
* @memberof BookUIServiceBase
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 加载应用实体模型数据
*
* @memberof BookUIServiceBase
*/
protected async loaded() {
await super.loaded();
this.authService = await AuthServiceRegister.getInstance().getService(this.context,`${this.entityModel?.codeName.toLowerCase()}`);
this.dataService = await new GlobalService().getService(`${this.entityModel?.codeName}`,this.context);
await this.authService.loaded();
}
/**
* 初始化基础数据
*
* @memberof BookUIServiceBase
*/
protected initBasicData(){
this.isEnableDEMainState = false;
this.dynaInstTag = "";
this.tempOrgIdDEField ="orgid";
this.stateValue = 0;
this.multiFormDEField = null;
this.indexTypeDEField = null;
this.stateField = "";
this.mainStateFields = [];
}
/**
* 初始化界面行为数据
*
* @memberof BookUIServiceBase
*/
protected async initActionMap(): Promise<void> {
const actions = this.entityModel?.getAllPSAppDEUIActions() as IPSAppDEUIAction[];
if (actions && actions.length > 0) {
for (const element of actions) {
const targetAction: any = await AppLogicFactory.getInstance(element, this.context);
this.actionMap.set(element.uIActionTag, targetAction);
}
}
}
/**
* 初始化视图功能数据Map
*
* @memberof BookUIServiceBase
*/
protected initViewFuncMap(){
this.allViewFuncMap.set('EDITVIEW:','EDITVIEW');
this.allViewFuncMap.set('MDATAVIEW:','MDATAVIEW');
}
}
\ No newline at end of file
import { BookUIServiceBase } from './book-ui-service-base';
/**
* 书UI服务对象
*
* @export
* @class BookUIService
*/
export default class BookUIService extends BookUIServiceBase {
/**
* 基础UI服务实例
*
* @private
* @type {ORDER1UIServiceBase}
* @memberof BookUIService
*/
private static basicUIServiceInstance: BookUIService;
/**
* 动态模型服务存储Map对象
*
* @private
* @type {Map<string, any>}
* @memberof BookUIService
*/
private static UIServiceMap: Map<string, any> = new Map();
/**
* Creates an instance of BookUIService.
*
* @param {*} [opts={}]
* @memberof BookUIService
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 通过应用上下文获取实例对象
*
* @public
* @memberof BookUIService
*/
public static getInstance(context: any): BookUIService {
if (!this.basicUIServiceInstance) {
this.basicUIServiceInstance = new BookUIService({context:context});
}
if (!context.srfdynainstid) {
return this.basicUIServiceInstance;
} else {
if (!BookUIService.UIServiceMap.get(context.srfdynainstid)) {
BookUIService.UIServiceMap.set(context.srfdynainstid, new BookUIService({context:context}));
}
return BookUIService.UIServiceMap.get(context.srfdynainstid);
}
}
}
\ No newline at end of file
export * from './ui-service';
export * from './raw-material/raw-material-ui-service';
export * from './book/book-ui-service';
export const appMapping: any = {
'rawmaterial': 'rawmaterial'
'rawmaterial': 'rawmaterial',
'book': 'book'
}
\ No newline at end of file
......@@ -56,6 +56,24 @@ const router = new Router({
},
component: AppViewShell
},
{
path: 'books/:book?/views/:view?',
meta: {
captionTag: '',
caption: '',
info:'',
imgPath: '',
iconCls: '',
parameters: [
{ pathName: 'appindex', parameterName: 'appindex' },
{ pathName: 'books', parameterName: 'book' },
{ pathName: 'views', parameterName: 'view' },
],
resource:'book',
requireAuth: false,
},
component: AppViewShell
},
{
path: 'views/:view?',
meta: {
......
......@@ -3,7 +3,7 @@ services:
trainsys-app-web:
image: dstimage
ports:
- "50100:80"
- "80:80"
networks:
- agent_network
deploy:
......
......@@ -46,4 +46,7 @@ sysauthlog:
rawmaterial:
path: /rawmaterials/**,/rawmaterial/**
serviceId: trainsys-trainsys
book:
path: /books/**,/book/**
serviceId: trainsys-trainsys
......@@ -16,4 +16,4 @@ CMD echo "The application will start in ${IBIZ_SLEEP}s..." && \
sleep ${IBIZ_SLEEP} && \
yarn start:prod
EXPOSE 50100
\ No newline at end of file
EXPOSE 8080
\ No newline at end of file
......@@ -3,16 +3,9 @@ services:
trainsys-app-web:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-app-web:latest
ports:
- "50100:50100"
- "8080:8080"
networks:
- agent_network
environment:
- NACOS_DISCOVERY_IP=172.16.240.140
- APPLICATION_PORT=50100
- NACOS_SERVER_ADDR=127.0.0.1:8848
- REDIS_HOST=127.0.0.1
- REDIS_PORT=6379
- SPRING_REDIS_DATABASE=0
deploy:
resources:
limits:
......
export const EntityPathReplace = {
'rawmaterials': 'rawmaterial',
'r8_redirect_rawmaterial': 'rawmaterial',
'books': 'book',
'r8_redirect_book': 'book',
}
\ No newline at end of file
import { Body, Controller, Delete, Get, Param, Post, Put, Req, Res } from '@nestjs/common';
import { FastifyRequest, FastifyReply } from 'fastify';
import { NetService, ControllerBase } from '@/core';
import { Environment } from '@/environment';
@Controller()
export class BookController extends ControllerBase {
protected readonly http: NetService = new NetService('book');
@Post('/books')
async create(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Body() body: any,
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/create`;
this.callAPI(request, response, url, body);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.post(request, response, url, body);
return this.parseResponse(request, response, res);
}
@Get('/books/:book')
async get(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Param('book') book: string,
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/get/${encodeURIComponent(book)}`;
this.callAPI(request, response, url);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.get(request, response, url);
return this.parseResponse(request, response, res);
}
@Delete('/books/:book')
async remove(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Param('book') book: string,
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/remove/${encodeURIComponent(book)}`;
this.callAPI(request, response, url);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.delete(request, response, url);
return this.parseResponse(request, response, res);
}
@Put('/books/:book')
async update(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Param('book') book: string,
@Body() body: any,
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/update/${encodeURIComponent(book)}`;
this.callAPI(request, response, url, body);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.put(request, response, url, body);
return this.parseResponse(request, response, res);
}
@Post('/books/checkkey')
async checkKey(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Body() body: any,
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/checkkey`;
this.callAPI(request, response, url, body);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.post(request, response, url, body);
return this.parseResponse(request, response, res);
}
@Get('/books/getdraft')
async getDraft(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Body() body: any,
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/getdraft`;
this.callAPI(request, response, url);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.get(request, response, url);
return this.parseResponse(request, response, res);
}
@Post('/books/fetchdefault')
async fetchDefault(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Body() body: any,
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/fetchdefault`;
this.callFetchAPI(request, response, url, body);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.post(request, response, url, body);
return this.parseResponse(request, response, res);
}
@Delete('/books/batch')
async removeBatch(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Body() body: any
): Promise<any> {
if (Environment.EnableRuntime) {
let keys = '';
if (body && body instanceof Array) {
keys = body.join(',');
}
const url = `/book/remove/${keys}`;
delete request.headers['content-length'];
this.callAPI(request, response, url);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.delete(request, response, url, { data: body });
return this.parseResponse(request, response, res);
}
@Post('/books/batch')
async saveBatch(
@Req() request: FastifyRequest,
@Res() response: FastifyReply,
@Body() body: any
): Promise<any> {
if (Environment.EnableRuntime) {
const url = `/book/save`;
this.callAPI(request, response, url, body);
return;
}
const url = this.parseUrl(request.url);
const res = await this.http.post(request, response, url, body);
return this.parseResponse(request, response, res);
}
}
import { EntityProxyMiddleware } from '../../core';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { BookController } from './book.controller';
export class BookMiddleware extends EntityProxyMiddleware {
protected serviceTag = 'book';
}
@Module({
controllers: [BookController]
})
export class BookModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer.apply(BookMiddleware).forRoutes('(.*)/importdata', '(.*)/importtemplate', '(.*)/exportdata/(.*)');
}
}
import { RawMaterialModule } from './raw-material/raw-material.module';
import { BookModule } from './book/book.module';
export {
RawMaterialModule,
BookModule,
};
export const AllModules = [
RawMaterialModule,
BookModule,
];
......@@ -55,12 +55,6 @@
git clone -b master $para2 trainsys/
export NODE_OPTIONS=--max-old-space-size=4096
cd trainsys/
mvn clean package -Ptrainsys
mvn install -Ptrainsys
cd trainsys-provider
mvn -Ptrainsys docker:build
mvn -Ptrainsys docker:push
docker -H $para1 stack deploy --compose-file=src/main/docker/trainsys-provider-trainsys.yaml ebsx --with-registry-auth
</command>
</hudson.tasks.Shell>
</builders>
......
......@@ -34,7 +34,7 @@
<profiles>
<profile>
<id>trainsys</id>
<id>runtime</id>
<build>
<resources>
<resource>
......
......@@ -10,6 +10,6 @@ CMD echo "The application will start in ${IBIZ_SLEEP}s..." && \
sleep ${IBIZ_SLEEP} && \
java ${JAVA_OPTS} -Duser.timezone=$TZ -Djava.security.egd=file:/dev/./urandom -jar /trainsys-provider.jar
EXPOSE 50000
EXPOSE 8081
ADD trainsys-provider.jar /trainsys-provider.jar
......@@ -22,32 +22,7 @@ spec:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-provider:latest
imagePullPolicy: Always
ports:
- containerPort: 50000
env:
- name: SPRING_CLOUD_NACOS_DISCOVERY_IP
value: "172.16.240.140"
- name: SERVER_PORT
value: "50000"
- name: SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR
value: "172.16.240.140:8848"
- name: SPRING_REDIS_HOST
value: "127.0.0.1"
- name: SPRING_REDIS_PORT
value: "6379"
- name: SPRING_REDIS_DATABASE
value: "0"
- name: SPRING_DATASOURCE_USERNAME
value: "a_LAB01_d23cc850e"
- name: SPRING_DATASOURCE_PASSWORD
value: "f9Df4556"
- name: SPRING_DATASOURCE_URL
value: "jdbc:mysql://172.16.186.185:3306/a_LAB01_d23cc850e?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&serverTimezone=Asia/Shanghai&allowMultiQueries=true&serverTimezone=GMT%2B8"
- name: SPRING_DATASOURCE_DRIVER-CLASS-NAME
value: "com.mysql.jdbc.Driver"
- name: SPRING_DATASOURCE_DEFAULTSCHEMA
value: "a_LAB01_d23cc850e"
- name: NACOS
value: "172.16.240.140:8848"
- containerPort: 8081
---
apiVersion: v1
......@@ -60,9 +35,9 @@ spec:
type: NodePort
ports:
- name: http
port: 50000
targetPort: 50000
nodePort: 50000
port: 8081
targetPort: 8081
nodePort: 8081
protocol: TCP
selector:
app: trainsys-provider
......
......@@ -3,23 +3,9 @@ services:
trainsys-provider:
image: registry.cn-shanghai.aliyuncs.com/ibizsys/trainsys-provider:latest
ports:
- "50000:50000"
- "8081:8081"
networks:
- agent_network
environment:
- SPRING_CLOUD_NACOS_DISCOVERY_IP=172.16.240.140
- SERVER_PORT=50000
- SPRING_CLOUD_NACOS_DISCOVERY_SERVER-ADDR=172.16.240.140:8848
- SPRING_CLOUD_NACOS_CONFIG_SERVER-ADDR=172.16.240.140:8848
- SPRING_REDIS_HOST=127.0.0.1
- SPRING_REDIS_PORT=6379
- SPRING_REDIS_DATABASE=0
- SPRING_DATASOURCE_USERNAME=a_LAB01_d23cc850e
- SPRING_DATASOURCE_PASSWORD=f9Df4556
- SPRING_DATASOURCE_URL=jdbc:mysql://172.16.186.185:3306/a_LAB01_d23cc850e?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&serverTimezone=Asia/Shanghai&allowMultiQueries=true&serverTimezone=GMT%2B8
- SPRING_DATASOURCE_DRIVER-CLASS-NAME=com.mysql.jdbc.Driver
- SPRING_DATASOURCE_DEFAULTSCHEMA=a_LAB01_d23cc850e
- NACOS=172.16.240.140:8848
deploy:
resources:
limits:
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册