优化admin逻辑
This commit is contained in:
parent
445b66cb24
commit
7393fb6429
@ -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,
|
||||
|
@ -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<DefaultState, DefaultContext> {
|
||||
@ -20,7 +21,12 @@ function InitMiddleware(): Middleware<DefaultState, DefaultContext> {
|
||||
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) {
|
||||
|
@ -190,7 +190,12 @@ const PcInitRunAction = <Action>{
|
||||
});
|
||||
}
|
||||
|
||||
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 = <Action>{
|
||||
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,
|
||||
|
@ -72,11 +72,6 @@ const PcUserAccountLoginAction = <Action>{
|
||||
'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 = <Action>{
|
||||
'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)) {
|
||||
|
@ -82,11 +82,6 @@ const PcUserMpLoginAction = <Action>{
|
||||
'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 = <Action>{
|
||||
'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) {
|
||||
|
@ -76,11 +76,6 @@ const PcUserWechatLoginAction = <Action>{
|
||||
'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 = <Action>{
|
||||
'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 = <Action>{
|
||||
'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) {
|
||||
|
@ -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) {
|
||||
|
7
server/src/types/model.d.ts
vendored
7
server/src/types/model.d.ts
vendored
@ -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;
|
||||
|
@ -5,7 +5,7 @@
|
||||
<img src="../../../assets/logo.svg" alt="logo" class="img-logo" />
|
||||
<div class="title">
|
||||
<img src="../../../assets/logo_txt.svg" alt="e家宜业" class="text-logo" />
|
||||
<h1>卓瓦科技旗下物业Saas平台</h1>
|
||||
<h1><a href="https://github.com/chowa/ejyy" target="_blank">卓瓦科技开源产品</a></h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user