-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
靳昌
committed
Jun 3, 2020
1 parent
3c7eecf
commit 187caba
Showing
11 changed files
with
227 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { ProjectId } from 'teambition-types' | ||
|
||
import { ProjectReminderSchema } from '../../schemas/ProjectReminder' | ||
import { SDKFetch } from '../../SDKFetch' | ||
import { SDK, CacheStrategy } from '../../SDK' | ||
|
||
/** | ||
* 获取项目级别的任务提醒规则 | ||
*/ | ||
export function getProjectRemindersFetch( | ||
this: SDKFetch, | ||
projectId: ProjectId | ||
) { | ||
return this.get<ProjectReminderSchema[]>(`projects/${projectId}/reminders`) | ||
} | ||
|
||
declare module '../../SDKFetch' { | ||
interface SDKFetch { | ||
getProjectReminders: typeof getProjectRemindersFetch | ||
} | ||
} | ||
|
||
SDKFetch.prototype.getProjectReminders = getProjectRemindersFetch | ||
|
||
/** | ||
* 获取项目级别的任务提醒规则 | ||
*/ | ||
function getProjectReminders( | ||
this: SDK, | ||
projectId: ProjectId, | ||
) { | ||
return this.lift<ProjectReminderSchema>({ | ||
cacheValidate: CacheStrategy.Request, | ||
query: { where: { _projectId: projectId } }, | ||
request: this.fetch.getProjectReminders(projectId), | ||
tableName: 'ProjectReminder', | ||
}) | ||
} | ||
|
||
declare module '../../SDK' { | ||
interface SDK { | ||
getProjectReminders: typeof getProjectReminders | ||
} | ||
} | ||
|
||
SDK.prototype.getProjectReminders = getProjectReminders |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './get' | ||
import './put' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ProjectId } from 'teambition-types' | ||
|
||
import { ProjectReminderSchema } from '../../schemas/ProjectReminder' | ||
import { SDKFetch } from '../../SDKFetch' | ||
|
||
interface Payload { | ||
addReminders: Pick<ProjectReminderSchema, 'rule' | 'receivers'>[] | ||
delReminders: Pick<ProjectReminderSchema, '_id'>[] | ||
updateReminders: Pick<ProjectReminderSchema, '_id' | 'rule' | 'receivers'>[] | ||
} | ||
|
||
/** | ||
* 更新项目级别的任务提醒规则 | ||
*/ | ||
export function updateProjectRemindersFetch( | ||
this: SDKFetch, | ||
projectId: ProjectId, | ||
payload: Payload, | ||
) { | ||
return this.put<ProjectReminderSchema[]>( | ||
`projects/${projectId}/reminders`, | ||
payload | ||
) | ||
} | ||
|
||
declare module '../../SDKFetch' { | ||
interface SDKFetch { | ||
updateProjectReminders: typeof updateProjectRemindersFetch | ||
} | ||
} | ||
|
||
SDKFetch.prototype.updateProjectReminders = updateProjectRemindersFetch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ProjectReminderId, ProjectId, UserId } from 'teambition-types' | ||
|
||
import { SchemaDef, RDBType } from '../db' | ||
import { schemaColl } from './schemas' | ||
import { TaskReminderReceiverBaseOnRole } from './TaskReminder' | ||
|
||
export interface ProjectReminderSchema { | ||
_id: ProjectReminderId | ||
_creatorId: UserId | ||
_projectId: ProjectId | ||
isDeleted: boolean | ||
receivers: TaskReminderReceiverBaseOnRole[] | ||
rule: string | ||
} | ||
|
||
const schema: SchemaDef<ProjectReminderSchema> = { | ||
_id: { type: RDBType.STRING, primaryKey: true }, | ||
_creatorId: { type: RDBType.STRING }, | ||
_projectId: { type: RDBType.STRING }, | ||
isDeleted: { type: RDBType.BOOLEAN }, | ||
receivers: { type: RDBType.OBJECT }, | ||
rule: { type: RDBType.STRING }, | ||
} | ||
|
||
schemaColl.add({ schema, name: 'ProjectReminder' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { TaskReminderId, TaskId } from 'teambition-types' | ||
|
||
import { RDBType, SchemaDef } from '../db' | ||
import { schemaColl } from './schemas' | ||
import { ProjectReminderSchema } from './ProjectReminder' | ||
|
||
export enum ReminderRuleType { | ||
startDate = 'startDate', | ||
dueDate = 'dueDate', | ||
custom = 'custom', | ||
} | ||
|
||
export enum ReminderUnit { | ||
minute = 'minute', | ||
hour = 'hour', | ||
day = 'day', | ||
} | ||
|
||
export enum TaskReminderReceiverBaseOnRole { | ||
executor = 'role/executor', | ||
involver = 'role/involver', | ||
creator = 'role/creator', | ||
} | ||
|
||
export enum TaskReminderSource { | ||
task = 'source:task', | ||
project = 'source:project', | ||
} | ||
|
||
interface TaskReminderBaseSchema { | ||
_id: TaskReminderId | ||
boundToObjectId: TaskId | ||
boundToObjectType: 'task' | ||
isDeleted: boolean | ||
rule: string | ||
} | ||
|
||
// 来源于项目规则 | ||
interface TaskReminderBaseProjectSchema | ||
extends TaskReminderBaseSchema, | ||
Pick<ProjectReminderSchema, 'receivers'> { | ||
labels: TaskReminderSource.task[] | ||
} | ||
|
||
// 来源于自身的规则 | ||
interface TaskReminderBaseOwnSchema extends TaskReminderBaseSchema { | ||
labels: TaskReminderSource.project[] | ||
receivers: string[] | ||
} | ||
|
||
export type TaskReminderSchema = | ||
| TaskReminderBaseProjectSchema | ||
| TaskReminderBaseOwnSchema | ||
|
||
const schema: SchemaDef<TaskReminderSchema> = { | ||
_id: { type: RDBType.STRING, primaryKey: true }, | ||
boundToObjectId: { type: RDBType.STRING }, | ||
boundToObjectType: { type: RDBType.STRING }, | ||
isDeleted: { type: RDBType.BOOLEAN }, | ||
labels: { type: RDBType.OBJECT }, | ||
receivers: { type: RDBType.OBJECT }, | ||
rule: { type: RDBType.STRING }, | ||
} | ||
|
||
schemaColl.add({ schema, name: 'TaskReminder' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.