Skip to content

Commit 8eb0835

Browse files
committed
style:格式化代码
1 parent dab3336 commit 8eb0835

File tree

6 files changed

+47
-22
lines changed

6 files changed

+47
-22
lines changed

src/guards/rbac.guard.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { CanActivate, ExecutionContext, Injectable, ForbiddenException, } from '@nestjs/common';
1+
import {
2+
CanActivate,
3+
ExecutionContext,
4+
Injectable,
5+
ForbiddenException,
6+
} from '@nestjs/common';
27
import { Observable } from 'rxjs';
38

49
@Injectable()

src/interceptor/rbac.interceptor.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { CallHandler, ExecutionContext, Injectable, NestInterceptor, ForbiddenException, } from '@nestjs/common';
1+
import {
2+
CallHandler,
3+
ExecutionContext,
4+
Injectable,
5+
NestInterceptor,
6+
ForbiddenException,
7+
} from '@nestjs/common';
28
import { Observable } from 'rxjs';
39

410
@Injectable()

src/logical/commodity/commodity.controller.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { Controller, Request, Post, Body, UseGuards, UseInterceptors, } from '@nestjs/common';
1+
import {
2+
Controller,
3+
Request,
4+
Post,
5+
Body,
6+
UseGuards,
7+
UseInterceptors,
8+
} from '@nestjs/common';
29
import { AuthGuard } from '@nestjs/passport';
310
import { CommodityService } from './commodity.service';
411
import { RbacInterceptor } from '../../interceptor/rbac.interceptor';
@@ -21,7 +28,7 @@ export class CommodityController {
2128
// @UseInterceptors(new RbacInterceptor(role.DEVELOPER))
2229
@Post('create')
2330
async createCommodity(@Body() body: any, @Request() req: any) {
24-
console.log(req.user, 'req.user.username')
31+
console.log(req.user, 'req.user.username');
2532
return await this.commodityService.createCommodity(body, req.user.username);
2633
}
2734
// 修改商品

src/logical/commodity/commodity.service.ts

+21-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export class CommodityService {
1313
*/
1414
async queryCommodityList(body: any): Promise<any> {
1515
const { pageIndex = 1, pageSize = 10, keywords = '' } = body; // 分页查询条件
16-
const currentIndex = (pageIndex - 1) * pageSize < 0 ? 0 : (pageIndex - 1) * pageSize;
16+
const currentIndex =
17+
(pageIndex - 1) * pageSize < 0 ? 0 : (pageIndex - 1) * pageSize;
1718
const queryCommodityListSQL = `
1819
SELECT
1920
id,
@@ -33,12 +34,12 @@ export class CommodityService {
3334
ORDER BY
3435
id DESC
3536
LIMIT ${currentIndex}, ${pageSize} `;
36-
const commodityList: any[] = await sequelize.query(queryCommodityListSQL, {
37-
type: Sequelize.QueryTypes.SELECT,
38-
raw: true,
39-
logging: false,
40-
});
41-
// 统计数据条数
37+
const commodityList: any[] = await sequelize.query(queryCommodityListSQL, {
38+
type: Sequelize.QueryTypes.SELECT,
39+
raw: true,
40+
logging: false,
41+
});
42+
// 统计数据条数
4243
const countCommodityListSQL = `
4344
SELECT
4445
COUNT(*) AS total
@@ -69,7 +70,13 @@ export class CommodityService {
6970
* @memberof CommodityService
7071
*/
7172
async createCommodity(body: any, username: string): Promise<any> {
72-
const { columnId = 0, name, description = '', marketPrice = 0, saleMoney = 0, } = body;
73+
const {
74+
columnId = 0,
75+
name,
76+
description = '',
77+
marketPrice = 0,
78+
saleMoney = 0,
79+
} = body;
7380
const createCommoditySQL = `
7481
INSERT INTO commodity
7582
(ccolumn_id, commodity_name, commodity_desc, market_price, sale_money, c_by)
@@ -95,12 +102,12 @@ export class CommodityService {
95102
u_by = '${username}'
96103
WHERE
97104
id = ${id} `;
98-
const transaction = await sequelize.transaction();
99-
await sequelize.query(updateCommoditySQL, { transaction, logging: false });
100-
return {
101-
code: 200,
102-
msg: 'Success',
103-
};
105+
const transaction = await sequelize.transaction();
106+
await sequelize.query(updateCommoditySQL, { transaction, logging: false });
107+
return {
108+
code: 200,
109+
msg: 'Success',
110+
};
104111
}
105112
async deleteCommodity(body: any) {
106113
const { id } = body;

src/logical/user/user.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class UserController {
1616

1717
// JWT验证 - Step 1: 用户请求登录
1818
@Post('login')
19-
@ApiBody({ description: '用户登录', type: LoginDTO, })
19+
@ApiBody({ description: '用户登录', type: LoginDTO })
2020
async login(@Body() loginParmas: LoginDTO) {
2121
console.log('JWT验证 - Step 1: 用户请求登录');
2222
const authResult = await this.authService.validateUser(

src/logical/user/user.dto.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import { IsNotEmpty, IsNumber, IsString } from 'class-validator';
22
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
33

44
export class LoginDTO {
5-
@ApiProperty({ description: '用户名', example: 'koa2', })
5+
@ApiProperty({ description: '用户名', example: 'koa2' })
66
@IsNotEmpty({ message: '用户名不能为空' })
77
readonly username: string;
88
@ApiProperty({ description: '密码', example: 'a123456' })
99
@IsNotEmpty({ message: '密码不能为空' })
1010
readonly password: string;
1111
}
1212
export class RegisterInfoDTO {
13-
1413
@ApiProperty()
1514
@IsNotEmpty({ message: '用户名不能为空' })
1615
readonly accountName: string;
@@ -34,7 +33,8 @@ export class RegisterInfoDTO {
3433
readonly mobile: number;
3534

3635
@ApiPropertyOptional({
37-
description: '[用户角色]: 0-超级管理员 | 1-管理员 | 2-开发&测试&运营 | 3-普通用户 (只能查看)',
36+
description:
37+
'[用户角色]: 0-超级管理员 | 1-管理员 | 2-开发&测试&运营 | 3-普通用户 (只能查看)',
3838
})
3939
readonly role?: string | number;
4040
}

0 commit comments

Comments
 (0)