@@ -13,7 +13,8 @@ export class CommodityService {
13
13
*/
14
14
async queryCommodityList ( body : any ) : Promise < any > {
15
15
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 ;
17
18
const queryCommodityListSQL = `
18
19
SELECT
19
20
id,
@@ -33,12 +34,12 @@ export class CommodityService {
33
34
ORDER BY
34
35
id DESC
35
36
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
+ // 统计数据条数
42
43
const countCommodityListSQL = `
43
44
SELECT
44
45
COUNT(*) AS total
@@ -69,7 +70,13 @@ export class CommodityService {
69
70
* @memberof CommodityService
70
71
*/
71
72
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 ;
73
80
const createCommoditySQL = `
74
81
INSERT INTO commodity
75
82
(ccolumn_id, commodity_name, commodity_desc, market_price, sale_money, c_by)
@@ -95,12 +102,12 @@ export class CommodityService {
95
102
u_by = '${ username } '
96
103
WHERE
97
104
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
+ } ;
104
111
}
105
112
async deleteCommodity ( body : any ) {
106
113
const { id } = body ;
0 commit comments