Skip to content

Commit

Permalink
add timesheet report value for dingding
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr_Xiao_Zhang committed Jun 30, 2022
1 parent efac4e7 commit 680c7c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
24 changes: 16 additions & 8 deletions src/controllers/dingTalk.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
} from '@dtos/dingTlak';
import { ICreateReport } from '@interfaces/dingTalk';
import { NestRes } from '@interfaces/nestbase';
import { ITimeSheetData } from '@interfaces/timesheet';
import { InjectRedis, Redis } from '@nestjs-modules/ioredis';
import {
Body,
Controller,
Expand All @@ -25,7 +27,10 @@ import * as moment from 'moment';
@UseGuards(AuthGuard('jwt'))
@Controller('dingtalk')
export class DingTalkController {
constructor(private readonly dingTalkService: DingTalkService) {}
constructor(
private readonly dingTalkService: DingTalkService,
@InjectRedis() private readonly redis: Redis,
) {}

@Get('/departments')
async getDepartments() {
Expand Down Expand Up @@ -206,15 +211,18 @@ export class DingTalkController {
return false;
}

@Post('/getReportTemplateByName')
async getReportTemplateByName(
@Body() Body: IGetReportTemplateByNameDto,
@Request() req: NestRes,
) {
@Get('/getReportTemplateByName')
async getReportTemplateByName(@Request() req: NestRes) {
const { dingTalkUserId } = req.user;
const _timesheet = await this.redis.get('timesheets');
const datas = <ITimeSheetData[]>JSON.parse(_timesheet || '[]');
const userTimeSheet = datas.find((x) => x.userid === dingTalkUserId);

const result = await this.dingTalkService.getReportTemplateByName({
template_name: Body.name,
userid: req.user.dingTalkUserId,
template_name: 'TIMESHEET',
userid: dingTalkUserId,
});
result.result.value = userTimeSheet?.value;
return result;
}

Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/dingTalk/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ export interface IReportTemplate {
userid: string;
}

interface IGetReportTemplateResult {
export interface IGetReportTemplateResult {
default_received_convs: Defaultreceivedconv[];
default_receivers: Defaultreceiver[];
fields: Field[];
id: string;
name: string;
user_name: string;
userid: string;
value?: string;
}

interface Field {
Expand Down

0 comments on commit 680c7c5

Please sign in to comment.