Skip to content

Commit 1023b84

Browse files
committed
【修正】2 处细节 bug
1 parent 9066c9c commit 1023b84

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

ReadMe.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
基于 [Koa][1][TypeScript][2][LeanCloud][3]**Node.js 后端**项目脚手架
44

55
[![NPM Dependency](https://david-dm.org/wuhan2020/rest-api.svg)][4]
6-
[![Build Status](https://travis-ci.com/wuhan2020/rest-api.svg?branch=master)][5]
6+
[![CI Status](https://github.com/wuhan2020/WebApp/workflows/PWA%20CI/CD/badge.svg)][5]
77

88
## 主要特性
99

@@ -64,5 +64,5 @@ lean up
6464
[2]: https://www.typescriptlang.org/
6565
[3]: https://leancloud.cn/
6666
[4]: https://david-dm.org/wuhan2020/rest-api
67-
[5]: https://travis-ci.com/wuhan2020/rest-api
67+
[5]: https://github.com/wuhan2020/WebApp/actions
6868
[6]: https://fcc-cd.tk/

source/controller/Clinic.ts

+6-20
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class ClinicController {
2626
@Authorized()
2727
async create(
2828
@Ctx() { currentUser: user }: LCContext,
29-
@Body() { name, startTime, endTime, ...rest }: ClinicModel
29+
@Body() { name, ...rest }: ClinicModel
3030
) {
3131
let clinic = await new Query(Clinic).equalTo('name', name).first();
3232

@@ -42,16 +42,9 @@ export class ClinicController {
4242
acl.setWriteAccess(user, true),
4343
acl.setRoleWriteAccess(await RoleController.getAdmin(), true);
4444

45-
clinic = await new Clinic().setACL(acl).save(
46-
{
47-
...rest,
48-
name,
49-
startTime: new Date(startTime),
50-
endTime: new Date(endTime),
51-
creator: user
52-
},
53-
{ user }
54-
);
45+
clinic = await new Clinic()
46+
.setACL(acl)
47+
.save({ ...rest, name, creator: user }, { user });
5548

5649
return clinic.toJSON();
5750
}
@@ -80,18 +73,11 @@ export class ClinicController {
8073
async edit(
8174
@Ctx() { currentUser: user }: LCContext,
8275
@Param('id') id: string,
83-
@Body() { name, startTime, endTime, ...rest }: ClinicModel
76+
@Body() { name, ...rest }: ClinicModel
8477
) {
8578
let clinic = LCObject.createWithoutData('Clinic', id);
8679

87-
await clinic.save(
88-
{
89-
...rest,
90-
startTime: new Date(startTime),
91-
endTime: new Date(endTime)
92-
},
93-
{ user }
94-
);
80+
await clinic.save(rest, { user });
9581

9682
clinic = await new Query(Clinic).include('creator').get(id);
9783

source/model/Clinic.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Length, IsDateString } from 'class-validator';
1+
import { Length, IsMilitaryTime } from 'class-validator';
22

33
import { OrganizationModel } from './Place';
44

55
export class ClinicModel extends OrganizationModel {
66
@Length(2)
77
name: string;
88

9-
@IsDateString()
9+
@IsMilitaryTime()
1010
startTime: string;
1111

12-
@IsDateString()
12+
@IsMilitaryTime()
1313
endTime: string;
1414
}

0 commit comments

Comments
 (0)