fix code merge bug

This commit is contained in:
xuecong 2021-11-17 01:00:43 +08:00
parent 8683f956ab
commit 6217b8e1f3
3 changed files with 47 additions and 7 deletions

View File

@ -1169,10 +1169,6 @@ ALTER TABLE `ejyy_ask_for_leave_flow`
ADD KEY `parent_id` (`parent_id`),
ADD KEY `step` (`step`);
ALTER TABLE `ejyy_building_access`
ADD PRIMARY KEY (`id`),
ADD KEY `building_id` (`building_id`);
ALTER TABLE `ejyy_building_info`
ADD PRIMARY KEY (`id`),
ADD KEY `community_id` (`community_id`);
@ -1628,9 +1624,6 @@ ALTER TABLE `ejyy_ask_for_leave`
ALTER TABLE `ejyy_ask_for_leave_flow`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
ALTER TABLE `ejyy_building_access`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
ALTER TABLE `ejyy_building_info`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

View File

@ -33,6 +33,7 @@ import ModelMiddleware from '~/middleware/model';
import IpMiddleware from '~/middleware/ip';
import HeaderMiddleware from '~/middleware/header';
import WatcherMiddleware from '~/middleware/watcher';
import InitMiddleware from '~/middleware/init';
import * as iot from '~/iot';
if (cluster.isMaster) {
@ -87,6 +88,7 @@ if (cluster.isMaster) {
.use(ModelMiddleware())
.use(IpMiddleware())
.use(HeaderMiddleware())
.use(InitMiddleware())
.use(router.routes())
.use(WatcherMiddleware());

View File

@ -0,0 +1,45 @@
/**
* +----------------------------------------------------------------------
* | e家宜业
* +----------------------------------------------------------------------
* | Copyright (c) 2020~2021 https://www.chowa.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed e家宜业
* +----------------------------------------------------------------------
* | Author: jixuecong@chowa.cn
* +----------------------------------------------------------------------
*/
import { Middleware, DefaultState, DefaultContext } from 'koa';
import config from '~/config';
import utils from '~/utils';
import { SYSTEMT_NOT_INIT } from '~/constant/code';
function InitMiddleware(): Middleware<DefaultState, DefaultContext> {
return async (ctx: DefaultContext, next) => {
const isInitAction = /^\/pc\/init\/\w+$/.test(ctx.request.path);
if (!config.inited && !/^\/pc\/upload\/sign$/.test(ctx.request.path)) {
const total = utils.sql.countReader(await ctx.model.from('ejyy_property_company_admin').count());
if (total === 0) {
if (!isInitAction) {
return (ctx.body = {
code: SYSTEMT_NOT_INIT,
message: '系统未初始化'
});
}
} else {
config.inited = true;
}
} else {
if (isInitAction) {
ctx.redirect('https://www.chowa.cn');
}
}
await next();
};
}
export default InitMiddleware;