add the view of BossLibrary、CompanyLibrary、JobLibrary

This commit is contained in:
geekgeekrun
2024-10-02 17:39:57 +08:00
parent 1001b3fe0a
commit 668df75dc3
13 changed files with 638 additions and 3 deletions

View File

@@ -0,0 +1,30 @@
import { requireTypeorm } from "../utils/module-loader";
const { ViewEntity, ViewColumn } = requireTypeorm();
@ViewEntity({
expression: `SELECT
boss_info.encryptBossId,
boss_info.name,
boss_info.title,
company_info.name as companyName,
company_info.encryptCompanyId as encryptCompanyId
FROM
boss_info
LEFT JOIN company_info ON company_info.encryptCompanyId = boss_info.encryptCompanyId
`,
})
export class VBossLibrary {
@ViewColumn()
encryptBossId: number;
@ViewColumn()
name: string;
@ViewColumn()
title: string;
@ViewColumn()
companyName: number | null;
@ViewColumn()
encryptCompanyId: number | null;
}

View File

@@ -0,0 +1,31 @@
import { requireTypeorm } from "../utils/module-loader";
const { ViewEntity, ViewColumn } = requireTypeorm();
@ViewEntity({
expression: `SELECT
company_info.*
FROM
company_info
`,
})
export class VCompanyLibrary {
@ViewColumn()
encryptCompanyId: string;
@ViewColumn()
name: string;
@ViewColumn()
brandName: string;
@ViewColumn()
scaleLow?: number;
@ViewColumn()
scaleHigh?: number;
@ViewColumn()
stageName?: string;
@ViewColumn()
industryName?: string;
}

View File

@@ -0,0 +1,57 @@
import { requireTypeorm } from "../utils/module-loader";
const { ViewEntity, ViewColumn } = requireTypeorm();
@ViewEntity({
expression: `SELECT
job_info.*,
boss_info.name AS bossName,
boss_info.title AS bossTitle,
company_info.name AS companyName
FROM
job_info
LEFT JOIN boss_info ON boss_info.encryptBossId = job_info.encryptBossId
LEFT JOIN company_info ON company_info.encryptCompanyId = job_info.encryptCompanyId
`,
})
export class VJobLibrary {
@ViewColumn()
encryptJobId: number;
@ViewColumn()
jobName: string;
@ViewColumn()
positionName: string;
@ViewColumn()
salaryLow: number | null;
@ViewColumn()
salaryHigh: number | null;
@ViewColumn()
salaryMonth: number | null;
@ViewColumn()
experienceName: number | null;
@ViewColumn()
publishDate: Date | null;
@ViewColumn()
degreeName: string;
@ViewColumn()
address: string;
@ViewColumn()
description: string;
@ViewColumn()
bossName: string;
@ViewColumn()
bossTitle: string;
@ViewColumn()
companyName: string;
}

View File

@@ -12,6 +12,9 @@ import { JobInfoChangeLog } from "./entity/JobInfoChangeLog";
import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
import { UserInfo } from "./entity/UserInfo";
import { VChatStartupLog } from "./entity/VChatStartupLog";
import { VBossLibrary } from "./entity/VBossLibrary";
import { VJobLibrary } from "./entity/VJobLibrary";
import { VCompanyLibrary } from "./entity/VCompanyLibrary"
import sqlite3 from 'sqlite3';
import * as cliHighlight from 'cli-highlight';
@@ -37,7 +40,10 @@ export function initDb(dbFilePath) {
JobInfoChangeLog,
BossActiveStatusRecord,
UserInfo,
VChatStartupLog
VChatStartupLog,
VBossLibrary,
VJobLibrary,
VCompanyLibrary
],
});
return appDataSource.initialize();

View File

@@ -24,6 +24,19 @@ export const parseCompanyScale = (str: string): [number| null, number | null] =>
return [null, null]
}
export function formatCompanyScale(low, high) {
if (low === null && high === null) {
return ''
}
if (low === null && high !== null) {
return `${high}人以下`
}
if (low !== null && high === null) {
return `${low}人以上`
}
return `${low}-${high}`
}
export const parseSalary = (str: string): { low: null | number, high: null | number, month: null | number } => {
const result = {
high: null,

View File

@@ -17,7 +17,12 @@ import { getAnyAvailablePuppeteerExecutable } from '../../../flow/CHECK_AND_DOWN
import { sleep } from '@geekgeekrun/utils/sleep.mjs'
import { AUTO_CHAT_ERROR_EXIT_CODE } from '../../../../common/enums/auto-start-chat'
import { mainWindow } from '../../../window/mainWindow'
import { getAutoStartChatRecord } from '../utils/db/index'
import {
getAutoStartChatRecord,
getBossLibrary,
getCompanyLibrary,
getJobLibrary
} from '../utils/db/index'
import { PageReq } from '../../../../common/types/pagination'
export default function initIpc() {
@@ -264,6 +269,18 @@ export default function initIpc() {
const a = await getAutoStartChatRecord(payload)
return a
})
ipcMain.handle('get-job-library', async (ev, payload: PageReq) => {
const a = await getJobLibrary(payload)
return a
})
ipcMain.handle('get-boss-library', async (ev, payload: PageReq) => {
const a = await getBossLibrary(payload)
return a
})
ipcMain.handle('get-company-library', async (ev, payload: PageReq) => {
const a = await getCompanyLibrary(payload)
return a
})
let subProcessOfOpenBossSite: ChildProcess | undefined
let subProcessOfOpenBossSiteLaunching = false

View File

@@ -58,3 +58,30 @@ export const getAutoStartChatRecord = async ({ pageNo, pageSize }: Partial<PageR
})
return res
}
export const getBossLibrary = async ({ pageNo, pageSize }: Partial<PageReq> = {}) => {
const res = await createWorkerPromise({
type: 'getBossLibrary',
pageNo,
pageSize
})
return res
}
export const getCompanyLibrary = async ({ pageNo, pageSize }: Partial<PageReq> = {}) => {
const res = await createWorkerPromise({
type: 'getCompanyLibrary',
pageNo,
pageSize
})
return res
}
export const getJobLibrary = async ({ pageNo, pageSize }: Partial<PageReq> = {}) => {
const res = await createWorkerPromise({
type: 'getJobLibrary',
pageNo,
pageSize
})
return res
}

View File

@@ -4,6 +4,9 @@ import { initDb } from '@geekgeekrun/sqlite-plugin'
import { type DataSource } from 'typeorm'
import { getPublicDbFilePath } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
import { VChatStartupLog } from '@geekgeekrun/sqlite-plugin/dist/entity/VChatStartupLog'
import { VJobLibrary } from '@geekgeekrun/sqlite-plugin/dist/entity/VJobLibrary'
import { VCompanyLibrary } from '@geekgeekrun/sqlite-plugin/dist/entity/VCompanyLibrary'
import { VBossLibrary } from '@geekgeekrun/sqlite-plugin/dist/entity/VBossLibrary'
import { measureExecutionTime } from '../../../../../../common/utils/performance'
import { PageReq, PagedRes } from '../../../../../../common/types/pagination'
@@ -50,6 +53,73 @@ const payloadHandler = {
pageNo,
totalItemCount
}
},
async getJobLibrary({ pageNo, pageSize }: Partial<PageReq> = {}): Promise<PagedRes<VJobLibrary>> {
if (!pageNo) {
pageNo = 1
}
if (!pageSize) {
pageSize = 10
}
const userRepository = dataSource!.getRepository(VJobLibrary)!
const [data, totalItemCount] = await measureExecutionTime(
userRepository.findAndCount({
skip: (pageNo - 1) * pageSize,
take: pageSize
})
)
return {
data,
pageNo,
totalItemCount
}
},
async getCompanyLibrary({ pageNo, pageSize }: Partial<PageReq> = {}): Promise<
PagedRes<VCompanyLibrary>
> {
if (!pageNo) {
pageNo = 1
}
if (!pageSize) {
pageSize = 10
}
const userRepository = dataSource!.getRepository(VCompanyLibrary)!
const [data, totalItemCount] = await measureExecutionTime(
userRepository.findAndCount({
skip: (pageNo - 1) * pageSize,
take: pageSize
})
)
return {
data,
pageNo,
totalItemCount
}
},
async getBossLibrary({ pageNo, pageSize }: Partial<PageReq> = {}): Promise<
PagedRes<VBossLibrary>
> {
if (!pageNo) {
pageNo = 1
}
if (!pageSize) {
pageSize = 10
}
const userRepository = dataSource!.getRepository(VBossLibrary)!
const [data, totalItemCount] = await measureExecutionTime(
userRepository.findAndCount({
skip: (pageNo - 1) * pageSize,
take: pageSize
})
)
return {
data,
pageNo,
totalItemCount
}
}
}

View File

@@ -0,0 +1,113 @@
<template>
<div class="page-wrap flex flex-col of-hidden">
<div v-loading="isTableLoading" class="flex-1 of-hidden">
<div ref="tableContainerEl" class="h-100% of-hidden">
<ElTable
ref="tableRef"
:max-height="tableMaxHeight"
:data="tableData"
row-key="encryptBossId"
size="small"
table-layout="auto"
highlight-current-row
>
<ElTableColumn prop="companyName" label="公司" />
<ElTableColumn prop="name" label="BOSS" />
<ElTableColumn prop="title" label="BOSS身份" />
</ElTable>
</div>
</div>
<div class="flex flex-0 flex-justify-between pt10px pb10px">
<div class="w100px">
<el-button :loading="isTableLoading" size="small" @click="getBossLibrary">刷新</el-button>
</div>
<ElPagination
v-model:current-page="pagination.pageNo"
v-model:page-size="pagination.pageSize"
:page-sizes="pageSizeList"
small
:disabled="isTableLoading"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.totalItemCount"
@size-change="getBossLibrary"
@current-change="getBossLibrary"
/>
<div class="w100px" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { ElTable, ElTableColumn, ElButton, ElPagination } from 'element-plus'
import { type VChatStartupLog } from '@geekgeekrun/sqlite-plugin/src/entity/VChatStartupLog'
import { PageReq, PagedRes } from '../../../../common/types/pagination'
const tableData = ref<VChatStartupLog[]>([])
const pageSizeList = ref<number[]>([100, 200, 300, 400])
const pagination = ref<Omit<PageReq & PagedRes<unknown>, 'data'>>({
pageNo: 1,
pageSize: pageSizeList.value[0],
totalItemCount: 0
})
const tableRef = ref<InstanceType<typeof ElTable>>()
const isTableLoading = ref(false)
async function getBossLibrary() {
try {
isTableLoading.value = true
const { data: res } = (await electron.ipcRenderer.invoke('get-boss-library', {
pageNo: pagination.value.pageNo,
pageSize: pagination.value.pageSize
})) as { data: PagedRes<VChatStartupLog> }
tableData.value = res.data
pagination.value = {
totalItemCount: res.totalItemCount,
pageNo: res.pageNo,
pageSize: pagination.value.pageSize
}
} catch (err) {
console.log(err)
tableData.value = []
} finally {
tableRef.value?.setScrollTop(0)
isTableLoading.value = false
}
}
getBossLibrary()
const tableMaxHeight = ref<number | undefined>(undefined)
const tableContainerEl = ref<HTMLElement>()
const setTableMaxHeight = () =>
(tableMaxHeight.value = tableContainerEl.value?.clientHeight ?? undefined)
onMounted(() => {
setTableMaxHeight()
const ro = new ResizeObserver(() => setTableMaxHeight())
ro.observe(tableContainerEl.value!)
onBeforeUnmount(() => {
ro.disconnect()
})
})
</script>
<style scoped lang="scss">
.page-wrap {
margin: 0 auto;
max-width: 1000px;
max-height: 100vh;
overflow: hidden;
padding-left: 20px;
padding-top: 20px;
:deep(.el-drawer) {
.el-drawer__header {
padding: 16px 20px;
margin-bottom: 0;
}
.el-drawer__body {
padding: 0;
margin: 0 0 20px 20px;
padding-right: 20px;
}
}
}
</style>

View File

@@ -0,0 +1,123 @@
<template>
<div class="page-wrap flex flex-col of-hidden">
<div v-loading="isTableLoading" class="flex-1 of-hidden">
<div ref="tableContainerEl" class="h-100% of-hidden">
<ElTable
ref="tableRef"
:max-height="tableMaxHeight"
:data="tableData"
row-key="encryptCompanyId"
size="small"
table-layout="auto"
highlight-current-row
>
<ElTableColumn prop="name" label="公司" />
<ElTableColumn
:formatter="(row) => formatCompanyScale(row.scaleLow, row.scaleHigh)"
label="公司规模"
/>
<ElTableColumn prop="industryName" label="所在行业" />
<ElTableColumn prop="stageName" label="融资情况" />
</ElTable>
</div>
</div>
<div class="flex flex-0 flex-justify-between pt10px pb10px">
<div class="w100px">
<el-button :loading="isTableLoading" size="small" @click="getCompanyLibrary"
>刷新</el-button
>
</div>
<ElPagination
v-model:current-page="pagination.pageNo"
v-model:page-size="pagination.pageSize"
:page-sizes="pageSizeList"
small
:disabled="isTableLoading"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.totalItemCount"
@size-change="getCompanyLibrary"
@current-change="getCompanyLibrary"
/>
<div class="w100px" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { ElTable, ElTableColumn, ElButton, ElPagination } from 'element-plus'
import { type VChatStartupLog } from '@geekgeekrun/sqlite-plugin/src/entity/VChatStartupLog'
import { PageReq, PagedRes } from '../../../../common/types/pagination'
import { formatCompanyScale } from '@geekgeekrun/sqlite-plugin/src/utils/parser'
const tableData = ref<VChatStartupLog[]>([])
const pageSizeList = ref<number[]>([100, 200, 300, 400])
const pagination = ref<Omit<PageReq & PagedRes<unknown>, 'data'>>({
pageNo: 1,
pageSize: pageSizeList.value[0],
totalItemCount: 0
})
const getRowKey = (row: VChatStartupLog) => {
return `${row.encryptJobId}@${row.date}`
}
const tableRef = ref<InstanceType<typeof ElTable>>()
const isTableLoading = ref(false)
async function getCompanyLibrary() {
try {
isTableLoading.value = true
const { data: res } = (await electron.ipcRenderer.invoke('get-company-library', {
pageNo: pagination.value.pageNo,
pageSize: pagination.value.pageSize
})) as { data: PagedRes<VChatStartupLog> }
tableData.value = res.data
pagination.value = {
totalItemCount: res.totalItemCount,
pageNo: res.pageNo,
pageSize: pagination.value.pageSize
}
} catch (err) {
console.log(err)
tableData.value = []
} finally {
tableRef.value?.setScrollTop(0)
isTableLoading.value = false
}
}
getCompanyLibrary()
const tableMaxHeight = ref<number | undefined>(undefined)
const tableContainerEl = ref<HTMLElement>()
const setTableMaxHeight = () =>
(tableMaxHeight.value = tableContainerEl.value?.clientHeight ?? undefined)
onMounted(() => {
setTableMaxHeight()
const ro = new ResizeObserver(() => setTableMaxHeight())
ro.observe(tableContainerEl.value!)
onBeforeUnmount(() => {
ro.disconnect()
})
})
</script>
<style scoped lang="scss">
.page-wrap {
margin: 0 auto;
max-width: 1000px;
max-height: 100vh;
overflow: hidden;
padding-left: 20px;
padding-top: 20px;
:deep(.el-drawer) {
.el-drawer__header {
padding: 16px 20px;
margin-bottom: 0;
}
.el-drawer__body {
padding: 0;
margin: 0 0 20px 20px;
padding-right: 20px;
}
}
}
</style>

View File

@@ -0,0 +1,124 @@
<template>
<div class="page-wrap flex flex-col of-hidden">
<div v-loading="isTableLoading" class="flex-1 of-hidden">
<div ref="tableContainerEl" class="h-100% of-hidden">
<ElTable
ref="tableRef"
:max-height="tableMaxHeight"
:data="tableData"
row-key="encryptJobId"
size="small"
table-layout="auto"
highlight-current-row
>
<ElTableColumn prop="companyName" label="公司" />
<ElTableColumn prop="jobName" label="职位名称" />
<ElTableColumn prop="positionName" label="职位分类" />
<ElTableColumn prop="experienceName" label="工作经验" />
<ElTableColumn
label="薪资"
:formatter="
(row, _col, _val) =>
`${row.salaryLow}-${row.salaryHigh}k` +
(row.salaryMonth ? `* ${row.salaryMonth}薪` : '')
"
/>
<ElTableColumn prop="bossName" label="BOSS" />
<ElTableColumn prop="bossTitle" label="BOSS身份" />
</ElTable>
</div>
</div>
<div class="flex flex-0 flex-justify-between pt10px pb10px">
<div class="w100px">
<el-button :loading="isTableLoading" size="small" @click="getJobLibrary">刷新</el-button>
</div>
<ElPagination
v-model:current-page="pagination.pageNo"
v-model:page-size="pagination.pageSize"
:page-sizes="pageSizeList"
small
:disabled="isTableLoading"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.totalItemCount"
@size-change="getJobLibrary"
@current-change="getJobLibrary"
/>
<div class="w100px" />
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onBeforeUnmount } from 'vue'
import { ElTable, ElTableColumn, ElButton, ElPagination } from 'element-plus'
import { type VChatStartupLog } from '@geekgeekrun/sqlite-plugin/src/entity/VChatStartupLog'
import { PageReq, PagedRes } from '../../../../common/types/pagination'
const tableData = ref<VChatStartupLog[]>([])
const pageSizeList = ref<number[]>([100, 200, 300, 400])
const pagination = ref<Omit<PageReq & PagedRes<unknown>, 'data'>>({
pageNo: 1,
pageSize: pageSizeList.value[0],
totalItemCount: 0
})
const tableRef = ref<InstanceType<typeof ElTable>>()
const isTableLoading = ref(false)
async function getJobLibrary() {
try {
isTableLoading.value = true
const { data: res } = (await electron.ipcRenderer.invoke('get-job-library', {
pageNo: pagination.value.pageNo,
pageSize: pagination.value.pageSize
})) as { data: PagedRes<VChatStartupLog> }
tableData.value = res.data
pagination.value = {
totalItemCount: res.totalItemCount,
pageNo: res.pageNo,
pageSize: pagination.value.pageSize
}
} catch (err) {
console.log(err)
tableData.value = []
} finally {
tableRef.value?.setScrollTop(0)
isTableLoading.value = false
}
}
getJobLibrary()
const tableMaxHeight = ref<number | undefined>(undefined)
const tableContainerEl = ref<HTMLElement>()
const setTableMaxHeight = () =>
(tableMaxHeight.value = tableContainerEl.value?.clientHeight ?? undefined)
onMounted(() => {
setTableMaxHeight()
const ro = new ResizeObserver(() => setTableMaxHeight())
ro.observe(tableContainerEl.value!)
onBeforeUnmount(() => {
ro.disconnect()
})
})
</script>
<style scoped lang="scss">
.page-wrap {
margin: 0 auto;
max-width: 1000px;
max-height: 100vh;
overflow: hidden;
padding-left: 20px;
padding-top: 20px;
:deep(.el-drawer) {
.el-drawer__header {
padding: 16px 20px;
margin-bottom: 0;
}
.el-drawer__body {
padding: 0;
margin: 0 0 20px 20px;
padding-right: 20px;
}
}
}
</style>

View File

@@ -3,8 +3,11 @@
<div class="flex flex-col w160px pt30px pl30px aside-nav of-hidden">
<div class="nav-list flex-1 of-auto">
<RouterLink to="./GeekAutoStartChatWithBoss">Boss炸弹</RouterLink>
<RouterLink to="./StartChatRecord">开聊记录</RouterLink>
<a href="javascript:void(0)" @click="handleLaunchBossSite">手动逛Boss</a>
<RouterLink to="./StartChatRecord">开聊记录</RouterLink>
<RouterLink to="./JobLibrary">职位库</RouterLink>
<RouterLink to="./BossLibrary">Boss库</RouterLink>
<RouterLink to="./CompanyLibrary">公司库</RouterLink>
</div>
<div class="pt-16px pb-16px flex-0 font-size-12px">
<div>当前版本: {{ buildInfo.version }}({{ buildInfo.buildVersion }})</div>

View File

@@ -34,6 +34,27 @@ const routes: Array<RouteRecordRaw> = [
meta: {
title: '开聊记录'
}
},
{
path: 'JobLibrary',
component: () => import('@renderer/page/Configuration/JobLibrary.vue'),
meta: {
title: '职位库'
}
},
{
path: 'BossLibrary',
component: () => import('@renderer/page/Configuration/BossLibrary.vue'),
meta: {
title: 'Boss库'
}
},
{
path: 'CompanyLibrary',
component: () => import('@renderer/page/Configuration/CompanyLibrary.vue'),
meta: {
title: '公司库'
}
}
]
},