Skip to content

Commit

Permalink
feat: add source type,source for company tag
Browse files Browse the repository at this point in the history
  • Loading branch information
lastsunday committed Dec 20, 2024
1 parent 1b1508a commit 053f402
Show file tree
Hide file tree
Showing 37 changed files with 502 additions and 228 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

1. (Sidepanel)添加数据库删除功能。

### ✏️ Changed

1. 更改公司标签,新增sourceType(来源类型),source(来源)。

## 2.1.1(2024-12-19)

### 🐛 Fixed
Expand Down
20 changes: 15 additions & 5 deletions common/api/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { CompanyBO } from "../data/bo/companyBO";
import { CompanyTagBatchAddOrUpdateBO } from "../data/bo/companyTagBatchAddOrUpdateBO";
import { CompanyTagBO } from "../data/bo/companyTagBO";
import { CompanyTagExportBO } from "../data/bo/companyTagExportBO";
import { JobTagExportBO } from "../data/bo/jobTagExportBO";
import { JobTagSearchBO } from "../data/bo/jobTagSearchBO";
import { SearchCompanyBO } from "../data/bo/searchCompanyBO";
Expand Down Expand Up @@ -33,7 +35,6 @@ import { StatisticJobBrowseDTO } from "../data/dto/statisticJobBrowseDTO";
import { invoke } from "./bridge";
import { CONTENT_SCRIPT } from "./bridgeCommon";


export const JobApi = {
/**
*
Expand Down Expand Up @@ -276,8 +277,7 @@ export const JobApi = {
* @returns []
*/
jobTagExport: async function (param, { invokeEnv } = { invokeEnv: CONTENT_SCRIPT }) {
let result = await invoke(this.jobTagExport
.name, param, { invokeEnv: invokeEnv });
let result = await invoke(this.jobTagExport.name, param, { invokeEnv: invokeEnv });
return result.data;
},

Expand Down Expand Up @@ -372,15 +372,15 @@ export const CompanyApi = {

/**
*
* @param {CompanyTagBO[]} param
* @param {CompanyTagBatchAddOrUpdateBO} param
*/
batchAddOrUpdateCompanyTag: async function (param, { invokeEnv } = { invokeEnv: CONTENT_SCRIPT }) {
return await invoke(this.batchAddOrUpdateCompanyTag.name, param, { invokeEnv: invokeEnv });
},

/**
*
* @param {CompanyTagBO[]} param
* @param {CompanyTagBatchAddOrUpdateBO} param
*/
batchAddOrUpdateCompanyTagWithTransaction: async function (param, { invokeEnv } = { invokeEnv: CONTENT_SCRIPT }) {
return await invoke(this.batchAddOrUpdateCompanyTagWithTransaction.name, param, { invokeEnv: invokeEnv });
Expand Down Expand Up @@ -455,6 +455,16 @@ export const CompanyApi = {
return result.data;
},

/**
*
* @param {CompanyTagExportBO} param
* @returns []
*/
companyTagExport: async function (param, { invokeEnv } = { invokeEnv: CONTENT_SCRIPT }) {
let result = await invoke(this.companyTagExport
.name, param, { invokeEnv: invokeEnv });
return result.data;
},
};

export const TagApi = {
Expand Down
4 changes: 4 additions & 0 deletions common/data/bo/companyTagBO.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { TAG_SOURCE_TYPE_CUSTOM } from "../../index";
export class CompanyTagBO{
companyName;
tags;
sourceType = TAG_SOURCE_TYPE_CUSTOM;
source = null;
updateDatetime;
}
4 changes: 4 additions & 0 deletions common/data/bo/companyTagBatchAddOrUpdateBO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export class CompanyTagBatchAddOrUpdateBO{
items;
overrideUpdateDatetime;
}
7 changes: 7 additions & 0 deletions common/data/bo/companyTagExportBO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class CompanyTagExportBO {
companyIds;
source;
startDatetimeForUpdate;
endDatetimeForUpdate;
isPublic = 1;
}
1 change: 1 addition & 0 deletions common/data/bo/jobTagExportBO.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export class JobTagExportBO {
source;
startDatetimeForUpdate;
endDatetimeForUpdate;
isPublic = 1;
}
54 changes: 31 additions & 23 deletions common/data/domain/companyTag.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
export class CompanyTag {
/**
* 编号
*/
companyTagId;
/**
* 公司编号
*/
companyId;
/**
* 公司名
*/
companyName;
/**
* 标签编号
*/
tagId;
/**
* 排列序号
*/
seq;
createDatetime;
updateDatetime;
}
/**
* 编号
*/
companyTagId;
/**
* 公司编号
*/
companyId;
/**
* 公司名
*/
companyName;
/**
* 标签编号
*/
tagId;
/**
* 排列序号
*/
seq;
createDatetime;
updateDatetime;
/**
* 来源类型,0:CUSTOM;1:PLATFORM
*/
sourceType;
/**
* CUSTOM:null代表本地应用程序,【其他值】代表其他用户;PLATFORM:代表第三方平台;
*/
source;
}
1 change: 1 addition & 0 deletions common/data/dto/companyDTO.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { Company } from "../domain/company";
export class CompanyDTO extends Company {
tagNameArray;
tagIdArray;
tagDTOList;
}
5 changes: 5 additions & 0 deletions common/data/dto/companyTagExportDTO.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export class JobTagExportDTO{
companyId;
tagNameArray;
updateDatetime;
}
26 changes: 24 additions & 2 deletions common/excel.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,30 +294,52 @@ export const COMPANY_TAG_FILE_HEADER = [
[
"公司",
"标签",
],
[
"公司",
"标签",
"记录更新日期",
]
];

export const companyTagDataToExcelJSONArray = (list) => {
export const companyTagDataToExcelJSONArrayForView = (list) => {
let result = [];
for (let i = 0; i < list.length; i++) {
let item = list[i];
let obj = {
公司: item.companyName,
标签: item.tagNameArray.join(","),
记录更新日期: item.updateDatetime,
}
fillDataVersion(obj, JOB_TAG_FILE_HEADER);
result.push(obj);
}
return result;
}

export const companyTagDataToExcelJSONArray = (list) => {
let result = [];
for (let i = 0; i < list.length; i++) {
let item = list[i];
let obj = {
公司: item.companyName,
标签: item.tagNameArray,
记录更新日期: item.updateDatetime,
};
fillDataVersion(obj, COMPANY_TAG_FILE_HEADER);
result.push(obj);
}
return result;
}

export const companyTagExcelDataToObjectArray = (data) => {
export const companyTagExcelDataToObjectArray = (data, datetime) => {
let companyTagBOList = [];
for (let i = 0; i < data.length; i++) {
let dataItem = data[i];
let item = new CompanyTagBO();
item.companyName = dataItem['公司'];
item.tags = dataItem['标签'].split(",");
item.updateDatetime = convertDateStringToDateObject(dataItem['记录更新日期']) ?? convertDateStringToDateObject(datetime);
companyTagBOList.push(item);
}
return companyTagBOList;
Expand Down
9 changes: 4 additions & 5 deletions common/hooks/jobTag.js → common/hooks/tag.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
export function useJobTag() {
import { TAG_SOURCE_TYPE_CUSTOM } from "@/common";
export function useTag() {

const convertToTagData = (items) => {
let result = new Array;
let tagIdAndSourceListMap = new Map();
let tagIdAndItemMap = new Map();
let tagIdAndSourceStringListMap = new Map();
items.forEach(item => {
const tagId = item.tagId;
if (!tagIdAndSourceListMap.has(tagId)) {
tagIdAndSourceListMap.set(tagId, []);
tagIdAndItemMap.set(tagId, item);
tagIdAndSourceStringListMap.set(tagId, []);
}
tagIdAndSourceListMap.get(tagId).push({
sourceType: item.sourceType,
source: item.source,
createDatetime: item.createDatetime,
updateDatetime: item.updateDatetime,
});
tagIdAndSourceStringListMap.get(tagId).push(item.source);
});
tagIdAndItemMap.forEach(value => {
result.push({
tagId: value.tagId,
tagName: value.tagName,
isPublic: value.isPublic,
sourceList: tagIdAndSourceListMap.get(value.tagId),
self: tagIdAndSourceStringListMap.get(value.tagId).includes(null)
self: tagIdAndSourceListMap.get(value.tagId).filter(item => item.source == null && item.sourceType == TAG_SOURCE_TYPE_CUSTOM).length > 0
});
})
return result;
Expand Down
2 changes: 1 addition & 1 deletion common/service/dataSyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export async function getMergeDataListForCompanyTag(items, getByIdsCallback) {
return targetList;
}

export async function getMergeDataListForJobTag(items,idColumn, getByIdsCallback) {
export async function getMergeDataListForTag(items,idColumn, getByIdsCallback) {
return await getMergeDataList(items, idColumn, getByIdsCallback, (existsRecord, newRecord) => {
if (dayjs(newRecord.updateDatetime).isAfter(dayjs(existsRecord.updateDatetime))) {
return newRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Icon } from "@iconify/react";
import { Tag, Tooltip } from "antd";
import React from "react";
import { TagData } from "../data/TagData";
import styles from "./JobTag.module.css";
import styles from "./CustomTag.module.css";

interface JobTagProps {
interface CustomTagProps {
color?: string,
item: TagData,
}

const JobTag: React.FC<JobTagProps> = ({
const CustomTag: React.FC<CustomTagProps> = ({
color, item
}) => {

Expand All @@ -20,4 +20,4 @@ const JobTag: React.FC<JobTagProps> = ({
);
};

export default JobTag;
export default CustomTag;
31 changes: 20 additions & 11 deletions entrypoints/admin/src/components/JobItemCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import Card from "antd/es/card/Card";
import Paragraph from "antd/es/typography/Paragraph";
import dayjs from "dayjs";
import { useJob } from "../hooks/job";
import { useJobTag } from "../hooks/jobTag";
import { useTag } from "../hooks/tag";

import { TAG_SOURCE_TYPE_CUSTOM } from "@/common";
import { QuestionCircleOutlined } from "@ant-design/icons";
import { JobData } from "../data/JobData";
import CustomTag from "./CustomTag";
import "./JobItemCard.css";
import JobTag from "./JobTag";

const { platformLogo, platformFormat } = useJob();
const { convertToTagData } = useJobTag();
const { convertToTagData } = useTag();

const getTimeColorByOffsetTimeDay = (datetime) => {
let offsetTimeDay = -1;
Expand Down Expand Up @@ -75,9 +75,23 @@ const JobItemCard: React.FC<JobItemCardProps> = (props) => {
const genJobTag = (jobTagList) => {
if (jobTagList) {
const result = [];
convertToTagData(jobTagList?.filter(item => item.sourceType == TAG_SOURCE_TYPE_CUSTOM)).map((item) => {
convertToTagData(jobTagList?.filter(item => item.sourceType == TAG_SOURCE_TYPE_CUSTOM)).map((item,index) => {
result.push(
<JobTag item={item} color="#1677ff"></JobTag>
<CustomTag item={item} color="#1677ff" key={index}></CustomTag>
);
})
return result;
} else {
return null;
}
}

const genCompanyTag = (companyTagList) => {
if (companyTagList && companyTagList.length > 0) {
const result = [];
convertToTagData(companyTagList).map((item,index) => {
result.push(
<CustomTag item={item} color="#faad14" key={index}></CustomTag>
);
})
return result;
Expand Down Expand Up @@ -118,12 +132,7 @@ const JobItemCard: React.FC<JobItemCardProps> = (props) => {
</Text>
</Flex>
<Flex className={styles.marginTop} wrap={true} gap={2}>
{companyTagList &&
companyTagList.map((item, index) => (
<Tag className={styles.tag} key={index} color="warning">
{item.tagName}
</Tag>
))}
{genCompanyTag(companyTagList)}
</Flex>
<Flex className={styles.marginTop}>
{companyUrl ? (
Expand Down
Loading

0 comments on commit 053f402

Please sign in to comment.