Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a68c0e66
authored
Mar 18, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整部分逻辑
1 parent
1490ee43
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
19 deletions
src/main/java/com/glsx/smart/controller/ProductController.java
src/main/java/com/glsx/smart/controller/ProductTypeController.java
src/main/java/com/glsx/smart/service/SmartProductService.java
src/main/java/com/glsx/smart/service/SmartProductTypeService.java
src/main/java/com/glsx/smart/service/impl/SmartProductServiceImpl.java
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
src/main/java/com/glsx/smart/controller/ProductController.java
View file @
a68c0e6
...
...
@@ -55,11 +55,12 @@ public class ProductController {
* 保存产品。无则插入,有则更新。
*
* @param product 产品
* @return 是否成功
*/
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
void
save
(
@RequestBody
SmartProduct
product
)
{
public
Boolean
save
(
@RequestBody
SmartProduct
product
)
{
log
.
info
(
"$$$$ /product/save param: {}"
,
JSON
.
toJSONString
(
product
));
productService
.
save
(
product
);
return
productService
.
save
(
product
);
}
/**
...
...
@@ -77,6 +78,7 @@ public class ProductController {
* 校验商城商品 id。
*
* @param shopProductId 商品 id
* @return 商品 id 是否合法
*/
@RequestMapping
(
value
=
"/checkShopProductId"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
Boolean
checkShopProductId
(
String
shopProductId
)
{
...
...
@@ -88,10 +90,11 @@ public class ProductController {
* 上下架产品。
*
* @param id 产品 id
* @return 是否成功
*/
@RequestMapping
(
value
=
"/putOnOff"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
void
putOnOff
(
Long
id
)
{
public
Boolean
putOnOff
(
Long
id
)
{
log
.
info
(
"$$$$ /product/putOnOff param: {}"
,
id
);
productService
.
putOnOff
(
id
);
return
productService
.
putOnOff
(
id
);
}
}
src/main/java/com/glsx/smart/controller/ProductTypeController.java
View file @
a68c0e6
...
...
@@ -65,11 +65,12 @@ public class ProductTypeController {
* 保存产品类型。
*
* @param productType 产品类型
* @return 是否成功
*/
@RequestMapping
(
value
=
"/save"
,
method
=
{
RequestMethod
.
POST
})
public
void
save
(
@RequestBody
SmartProductType
productType
)
{
public
Boolean
save
(
@RequestBody
SmartProductType
productType
)
{
log
.
info
(
"$$$$ /productType/save param: {}"
,
JSON
.
toJSONString
(
productType
));
productTypeService
.
save
(
productType
);
return
productTypeService
.
save
(
productType
);
}
/**
...
...
src/main/java/com/glsx/smart/service/SmartProductService.java
View file @
a68c0e6
...
...
@@ -18,11 +18,11 @@ public interface SmartProductService {
SmartProduct
getById
(
Long
id
);
void
save
(
SmartProduct
product
);
Boolean
save
(
SmartProduct
product
);
List
<
SmartDeviceOrder
>
getCommandSetById
(
Long
id
);
Boolean
checkShopProductId
(
String
shopProductId
);
void
putOnOff
(
Long
id
);
Boolean
putOnOff
(
Long
id
);
}
src/main/java/com/glsx/smart/service/SmartProductTypeService.java
View file @
a68c0e6
...
...
@@ -20,7 +20,7 @@ public interface SmartProductTypeService {
JSONObject
getTypeAndCategory
();
void
save
(
SmartProductType
productType
);
Boolean
save
(
SmartProductType
productType
);
List
<
String
>
getShopTagList
();
}
src/main/java/com/glsx/smart/service/impl/SmartProductServiceImpl.java
View file @
a68c0e6
...
...
@@ -67,10 +67,12 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
* 保存产品。无则插入,有则更新。
*
* @param product 产品
* @return 是否成功
*/
@Override
@Transactional
public
void
save
(
SmartProduct
product
)
{
public
Boolean
save
(
SmartProduct
product
)
{
boolean
success
;
Date
now
=
new
Date
();
product
.
setUpdateTime
(
now
);
product
.
setUpdateBy
(
0L
);
...
...
@@ -82,22 +84,24 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
}
product
.
setCreateTime
(
now
);
product
.
setCreateBy
(
0L
);
productMapper
.
insertSelective
(
product
)
;
success
=
productMapper
.
insertSelective
(
product
)
>
0
;
}
else
{
SmartProduct
record
=
productMapper
.
selectByPrimaryKey
(
product
.
getId
());
if
(
record
!=
null
)
{
productMapper
.
updateByPrimaryKeySelective
(
product
)
;
success
=
productMapper
.
updateByPrimaryKeySelective
(
product
)
>
0
;
}
else
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
}
}
return
success
;
}
/**
* 根据产品 id 获取指令集。
*
*
* @
param id@
return 结果
*
@param id 产品 id
* @return 结果
*/
@Override
public
List
<
SmartDeviceOrder
>
getCommandSetById
(
Long
id
)
{
...
...
@@ -121,14 +125,18 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
* 上下架产品。
*
* @param id 产品 id
* @return 是否成功
*/
@Override
public
void
putOnOff
(
Long
id
)
{
@Transactional
public
Boolean
putOnOff
(
Long
id
)
{
boolean
success
;
SmartProduct
product
=
productMapper
.
selectByPrimaryKey
(
id
);
if
(
product
==
null
)
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_NOT_FOUND
);
}
product
.
setStatus
((
byte
)
(
product
.
getStatus
()
^
0b00000001
));
productMapper
.
updateByPrimaryKeySelective
(
product
);
success
=
productMapper
.
updateByPrimaryKeySelective
(
product
)
>
0
;
return
success
;
}
}
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
View file @
a68c0e6
...
...
@@ -107,10 +107,12 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
* 保存产品类型。
*
* @param productType 产品类型
* @return 是否成功
*/
@Override
@Transactional
public
void
save
(
SmartProductType
productType
)
{
public
Boolean
save
(
SmartProductType
productType
)
{
boolean
success
;
Date
now
=
new
Date
();
productType
.
setUpdateTime
(
now
);
productType
.
setUpdateBy
(
0L
);
...
...
@@ -122,15 +124,17 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
}
productType
.
setCreateTime
(
now
);
productType
.
setCreateBy
(
0L
);
productTypeMapper
.
insertSelective
(
productType
)
;
success
=
productTypeMapper
.
insertSelective
(
productType
)
>
0
;
}
else
{
SmartProductType
record
=
productTypeMapper
.
selectByPrimaryKey
(
productType
.
getId
());
if
(
record
!=
null
)
{
productTypeMapper
.
updateByPrimaryKeySelective
(
productType
)
;
success
=
productTypeMapper
.
updateByPrimaryKeySelective
(
productType
)
>
0
;
}
else
{
throw
new
BusinessException
(
ResultEnum
.
PRODUCT_TYPE_NOT_FOUND
);
}
}
return
success
;
}
/**
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment