diff --git a/resource/db.sql b/resource/db.sql index e0fb6f8..804bfa9 100644 --- a/resource/db.sql +++ b/resource/db.sql @@ -724,11 +724,6 @@ CREATE TABLE `ejyy_property_company_access` ( `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`content`)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -CREATE TABLE `ejyy_property_company_admin` ( - `id` bigint(20) NOT NULL, - `property_company_user_id` bigint(20) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - CREATE TABLE `ejyy_property_company_auth` ( `id` bigint(20) NOT NULL, `property_company_user_id` bigint(20) NOT NULL, @@ -771,6 +766,7 @@ CREATE TABLE `ejyy_property_company_user` ( `department_id` bigint(20) DEFAULT NULL, `job_id` bigint(20) DEFAULT NULL, `access_id` bigint(20) DEFAULT NULL, + `admin` tinyint(1) NOT NULL DEFAULT 0, `join_company_at` bigint(13) DEFAULT NULL, `leave_office` tinyint(1) NOT NULL DEFAULT 0, `created_by` bigint(20) DEFAULT NULL, diff --git a/server/src/middleware/init.ts b/server/src/middleware/init.ts index bfdced7..35bef2b 100644 --- a/server/src/middleware/init.ts +++ b/server/src/middleware/init.ts @@ -13,6 +13,7 @@ import { Middleware, DefaultState, DefaultContext } from 'koa'; import config from '~/config'; import utils from '~/utils'; +import { TRUE } from '~/constant/status'; import { SYSTEMT_NOT_INIT } from '~/constant/code'; function InitMiddleware(): Middleware { @@ -20,7 +21,12 @@ function InitMiddleware(): Middleware { 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()); + const total = utils.sql.countReader( + await ctx.model + .from('ejyy_property_company_user') + .where('admin', TRUE) + .count() + ); if (total === 0) { if (!isInitAction) { diff --git a/server/src/module/pc/controller/init/run.ts b/server/src/module/pc/controller/init/run.ts index 63e4a46..0c9ca38 100644 --- a/server/src/module/pc/controller/init/run.ts +++ b/server/src/module/pc/controller/init/run.ts @@ -190,7 +190,12 @@ const PcInitRunAction = { }); } - const total = utils.sql.countReader(await ctx.model.from('ejyy_property_company_admin').count()); + const total = utils.sql.countReader( + await ctx.model + .from('ejyy_property_company_user') + .where('admin', TRUE) + .count() + ); if (total > 0) { return (ctx.body = { @@ -211,15 +216,12 @@ const PcInitRunAction = { gender: utils.idcard.gender(idcard), avatar_url, phone, + admin: TRUE, join_company_at: created_at, created_at, leave_office: FALSE }); - await ctx.model.from('ejyy_property_company_admin').insert({ - property_company_user_id: user_id - }); - const [community_id] = await ctx.model.from('ejyy_community_info').insert({ name, banner, diff --git a/server/src/module/pc/controller/user/account_login.ts b/server/src/module/pc/controller/user/account_login.ts index 79a3156..1db9b8d 100644 --- a/server/src/module/pc/controller/user/account_login.ts +++ b/server/src/module/pc/controller/user/account_login.ts @@ -72,11 +72,6 @@ const PcUserAccountLoginAction = { 'ejyy_property_company_access.id', 'ejyy_property_company_user.access_id' ) - .leftJoin( - 'ejyy_property_company_admin', - 'ejyy_property_company_admin.property_company_user_id', - 'ejyy_property_company_user.id' - ) .where('ejyy_property_company_user.leave_office', FALSE) .where('ejyy_property_company_user.account', account) .select( @@ -91,11 +86,11 @@ const PcUserAccountLoginAction = { 'ejyy_property_company_user.department_id', 'ejyy_property_company_user.job_id', 'ejyy_property_company_user.join_company_at', + 'ejyy_property_company_user.admin', 'ejyy_property_company_user.created_at', 'ejyy_wechat_official_accounts_user.subscribed', 'ejyy_property_company_access.content' ) - .select(ctx.model.raw('IF(ejyy_property_company_admin.property_company_user_id, 1, 0) as admin')) .first(); if (!pcUserInfo || pcUserInfo.password !== utils.crypto.md5(password)) { diff --git a/server/src/module/pc/controller/user/mp_login.ts b/server/src/module/pc/controller/user/mp_login.ts index 5a38f82..06ffa8e 100644 --- a/server/src/module/pc/controller/user/mp_login.ts +++ b/server/src/module/pc/controller/user/mp_login.ts @@ -82,11 +82,6 @@ const PcUserMpLoginAction = { 'ejyy_property_company_access.id', 'ejyy_property_company_user.access_id' ) - .leftJoin( - 'ejyy_property_company_admin', - 'ejyy_property_company_admin.property_company_user_id', - 'ejyy_property_company_user.id' - ) .where('ejyy_property_company_user.leave_office', FALSE) .where('ejyy_property_company_user.union_id', pcSessionInfo.data.unionid) .select( @@ -96,12 +91,12 @@ const PcUserMpLoginAction = { 'ejyy_property_company_user.gender', 'ejyy_property_company_user.avatar_url', 'ejyy_property_company_user.phone', + 'ejyy_property_company_user.admin', 'ejyy_property_company_user.join_company_at', 'ejyy_property_company_user.created_at', 'ejyy_wechat_official_accounts_user.subscribed', 'ejyy_property_company_access.content' ) - .select(ctx.model.raw('IF(ejyy_property_company_admin.property_company_user_id, 1, 0) as admin')) .first(); if (!pcUserInfo) { diff --git a/server/src/module/pc/controller/user/wechat_login.ts b/server/src/module/pc/controller/user/wechat_login.ts index 72d020c..08d1b5e 100644 --- a/server/src/module/pc/controller/user/wechat_login.ts +++ b/server/src/module/pc/controller/user/wechat_login.ts @@ -76,11 +76,6 @@ const PcUserWechatLoginAction = { 'ejyy_property_company_access.id', 'ejyy_property_company_user.access_id' ) - .leftJoin( - 'ejyy_property_company_admin', - 'ejyy_property_company_admin.property_company_user_id', - 'ejyy_property_company_user.id' - ) .where('ejyy_property_company_user.leave_office', FALSE) .where('ejyy_property_company_user.open_id', webUserInfo.data.openid) .select( @@ -90,6 +85,7 @@ const PcUserWechatLoginAction = { 'ejyy_property_company_user.gender', 'ejyy_property_company_user.avatar_url', 'ejyy_property_company_user.phone', + 'ejyy_property_company_user.admin', 'ejyy_property_company_user.department_id', 'ejyy_property_company_user.job_id', 'ejyy_property_company_user.join_company_at', @@ -97,7 +93,6 @@ const PcUserWechatLoginAction = { 'ejyy_wechat_official_accounts_user.subscribed', 'ejyy_property_company_access.content' ) - .select(ctx.model.raw('IF(ejyy_property_company_admin.property_company_user_id, 1, 0) as admin')) .first(); if (!pcUserInfo) { diff --git a/server/src/module/pc/index.ts b/server/src/module/pc/index.ts index 11c4cd3..9fa73cb 100644 --- a/server/src/module/pc/index.ts +++ b/server/src/module/pc/index.ts @@ -52,11 +52,6 @@ function PcModule(appRouter: KoaRouter) { 'ejyy_property_company_access.id', 'ejyy_property_company_user.access_id' ) - .leftJoin( - 'ejyy_property_company_admin', - 'ejyy_property_company_admin.property_company_user_id', - 'ejyy_property_company_auth.property_company_user_id' - ) .where('ejyy_property_company_auth.token', token) .where('ejyy_property_company_user.leave_office', FALSE) .select( @@ -69,11 +64,11 @@ function PcModule(appRouter: KoaRouter) { 'ejyy_property_company_user.department_id', 'ejyy_property_company_user.job_id', 'ejyy_property_company_user.join_company_at', + 'ejyy_property_company_user.admin', 'ejyy_property_company_user.created_at', 'ejyy_wechat_official_accounts_user.subscribed', 'ejyy_property_company_access.content' ) - .select(ctx.model.raw('IF(ejyy_property_company_admin.property_company_user_id, 1, 0) as admin')) .first(); if (!pcUserInfo) { diff --git a/server/src/types/model.d.ts b/server/src/types/model.d.ts index 35809b5..c3ddff3 100644 --- a/server/src/types/model.d.ts +++ b/server/src/types/model.d.ts @@ -197,6 +197,7 @@ declare namespace EjyyModel { department_id?: number; job_id?: number; access_id?: number; + admin?: typeof TRUE | typeof FALSE; join_company_at?: number; // 用户可能会有重复的情况,因为涉及到离职问题,只有非离职状态记录为1 leave_office: typeof TRUE | typeof FALSE; @@ -244,11 +245,6 @@ declare namespace EjyyModel { content: string | typeof Role[]; } - interface EjyyPropertyCompanyAdmin { - id?: number; - property_company_user_id: number; - } - interface EjyyPropertyCompanyBuildingRegistered { id?: number; building_id: number; @@ -1331,7 +1327,6 @@ declare module 'knex/types/tables' { ejyy_property_company_user_default_community: EjyyModel.EjyyPropertyCompanyUserDefaultCommunity; ejyy_property_company_user_access_community: EjyyModel.EjyyPropertyCompanyUserAccessCommunity; ejyy_property_company_access: EjyyModel.EjyyPropertyCompanyAccess; - ejyy_property_company_admin: EjyyModel.EjyyPropertyCompanyAdmin; ejyy_property_company_building_registered: EjyyModel.EjyyPropertyCompanyBuildingRegistered; ejyy_community_info: EjyyModel.EjyyCommunityInfo; ejyy_community_setting: EjyyModel.EjyyCommunitySetting; diff --git a/web/src/views/user/login/main.vue b/web/src/views/user/login/main.vue index e16b9da..1e03d7f 100644 --- a/web/src/views/user/login/main.vue +++ b/web/src/views/user/login/main.vue @@ -5,7 +5,7 @@
-

卓瓦科技旗下物业Saas平台

+

卓瓦科技开源产品