正在显示
1 个修改的文件
包含
7 行增加
和
1 行删除
| @@ -14,6 +14,7 @@ import io.swagger.annotations.Api; | @@ -14,6 +14,7 @@ import io.swagger.annotations.Api; | ||
| 14 | import io.swagger.annotations.ApiOperation; | 14 | import io.swagger.annotations.ApiOperation; |
| 15 | import org.springframework.security.access.prepost.PreAuthorize; | 15 | import org.springframework.security.access.prepost.PreAuthorize; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | +import org.springframework.transaction.annotation.Transactional; | ||
| 17 | import org.springframework.web.bind.annotation.GetMapping; | 18 | import org.springframework.web.bind.annotation.GetMapping; |
| 18 | import org.springframework.web.bind.annotation.PostMapping; | 19 | import org.springframework.web.bind.annotation.PostMapping; |
| 19 | import org.springframework.web.bind.annotation.PutMapping; | 20 | import org.springframework.web.bind.annotation.PutMapping; |
| @@ -42,6 +43,8 @@ public class IotProductController extends BaseController | @@ -42,6 +43,8 @@ public class IotProductController extends BaseController | ||
| 42 | { | 43 | { |
| 43 | @Autowired | 44 | @Autowired |
| 44 | private IIotProductService IotProductService; | 45 | private IIotProductService IotProductService; |
| 46 | + @Autowired | ||
| 47 | + private PublicService publicService; | ||
| 45 | /** | 48 | /** |
| 46 | * 查询产品列表 | 49 | * 查询产品列表 |
| 47 | */ | 50 | */ |
| @@ -87,10 +90,13 @@ public class IotProductController extends BaseController | @@ -87,10 +90,13 @@ public class IotProductController extends BaseController | ||
| 87 | @PreAuthorize("@ss.hasPermi('iot:IotProduct:add')") | 90 | @PreAuthorize("@ss.hasPermi('iot:IotProduct:add')") |
| 88 | @Log(title = "产品", businessType = BusinessType.INSERT) | 91 | @Log(title = "产品", businessType = BusinessType.INSERT) |
| 89 | @PostMapping | 92 | @PostMapping |
| 93 | + @Transactional | ||
| 90 | public AjaxResult add(@RequestBody IotProduct iotProduct) | 94 | public AjaxResult add(@RequestBody IotProduct iotProduct) |
| 91 | { | 95 | { |
| 92 | iotProduct.setSys_user_id(SecurityUtils.getUserId()); | 96 | iotProduct.setSys_user_id(SecurityUtils.getUserId()); |
| 93 | - return toAjax(IotProductService.insertIotProduct(iotProduct)); | 97 | + int i = IotProductService.insertIotProduct(iotProduct); |
| 98 | + i+=publicService.updateBySql(" INSERT INTO `iot_product_authorize`(`username`,`action`,`permission`,`topic`)VALUES('"+iotProduct.getMqtt_username()+"','all','allow','/"+iotProduct.getRole_id()+"/"+iotProduct.getMqtt_username()+"/#')"); | ||
| 99 | + return toAjax(i); | ||
| 94 | } | 100 | } |
| 95 | 101 | ||
| 96 | /** | 102 | /** |
-
请 注册 或 登录 后发表评论