|
@@ -34,6 +34,7 @@ import {
|
|
|
ApiTags,
|
|
|
} from '@midwayjs/swagger';
|
|
|
import { Validate } from '@midwayjs/validate';
|
|
|
+import { UserUtilService } from '../service/util/user.util';
|
|
|
import { JwtService } from '@midwayjs/jwt';
|
|
|
@ApiTags(['用户'])
|
|
|
@Controller('/user')
|
|
@@ -44,6 +45,9 @@ export class UserController extends BaseController {
|
|
|
@Inject()
|
|
|
jwtService: JwtService;
|
|
|
|
|
|
+ @Inject()
|
|
|
+ userUtil: UserUtilService;
|
|
|
+
|
|
|
@Config('jwt.secret')
|
|
|
jwtSecret;
|
|
|
|
|
@@ -54,11 +58,7 @@ export class UserController extends BaseController {
|
|
|
@Validate()
|
|
|
async login(@Body() body: LoginDTO) {
|
|
|
const data = await this.service.findUserToLogin(body);
|
|
|
- let vo = new LoginVO(data);
|
|
|
- vo = JSON.parse(JSON.stringify(vo));
|
|
|
- const token = await this.jwtService.sign(vo, this.jwtSecret, {
|
|
|
- expiresIn: this.jwtExpiresIn,
|
|
|
- });
|
|
|
+ const token = new LoginVO(data);
|
|
|
return token;
|
|
|
}
|
|
|
|
|
@@ -81,6 +81,8 @@ export class UserController extends BaseController {
|
|
|
@Validate()
|
|
|
@ApiResponse({ type: CVO_user })
|
|
|
async create(@Body() data: CDTO_user) {
|
|
|
+
|
|
|
+ await this.userUtil.checkPhoneAndPid(data);
|
|
|
const dbData = await this.service.create(data);
|
|
|
const result = new CVO_user(dbData);
|
|
|
return result;
|
|
@@ -115,6 +117,8 @@ export class UserController extends BaseController {
|
|
|
@Validate()
|
|
|
@ApiResponse({ type: UVAO_user })
|
|
|
async update(@Param('id') id: string, @Body() body: UDTO_user) {
|
|
|
+
|
|
|
+ await this.userUtil.checkUpdateCardAndPid(id, body);
|
|
|
const result = await this.service.updateOne(id, body);
|
|
|
return result;
|
|
|
}
|