wangmengzhao
2023-12-01 cbdf1e550c73c90c01ec0c792eb7bfe96dcc910f
wumei-smart-master/springboot/wumei-iot/src/main/java/com/ruoyi/iot/controller/ThingsModelController.java
@@ -27,15 +27,14 @@
/**
 * 物模型Controller
 *
 *
 * @author kerwincui
 * @date 2021-12-16
 */
@RestController
@RequestMapping("/iot/model")
@Api(tags="产品物模型")
public class ThingsModelController extends BaseController
{
@Api(tags = "产品物模型")
public class ThingsModelController extends BaseController {
    @Autowired
    private IThingsModelService thingsModelService;
@@ -45,8 +44,7 @@
    @PreAuthorize("@ss.hasPermi('iot:device:list')")
    @GetMapping("/list")
    @ApiOperation("产品物模型分页列表")
    public TableDataInfo list(ThingsModel thingsModel)
    {
    public TableDataInfo list(ThingsModel thingsModel) {
        startPage();
        List<ThingsModel> list = thingsModelService.selectThingsModelList(thingsModel);
        return getDataTable(list);
@@ -58,8 +56,7 @@
    @PreAuthorize("@ss.hasPermi('iot:device:query')")
    @GetMapping(value = "/{modelId}")
    @ApiOperation("获取产品物模型详情")
    public AjaxResult getInfo(@PathVariable("modelId") Long modelId)
    {
    public AjaxResult getInfo(@PathVariable("modelId") Long modelId) {
        return AjaxResult.success(thingsModelService.selectThingsModelByModelId(modelId));
    }
@@ -70,27 +67,26 @@
    @Log(title = "物模型", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("添加产品物模型")
    public AjaxResult add(@RequestBody ThingsModel thingsModel)
    {
        int result=thingsModelService.insertThingsModel(thingsModel);
        if(result==1){
    public AjaxResult add(@RequestBody ThingsModel thingsModel) {
        int result = thingsModelService.insertThingsModel(thingsModel);
        if (result == 1) {
            return AjaxResult.success();
        }else if(result==2){
        } else if (result == 2) {
            return AjaxResult.error("产品下的标识符不能重复");
        }else{
        } else {
            return AjaxResult.error();
        }
    }
    @Log(title = "导入物模型",businessType = BusinessType.INSERT)
    @Log(title = "导入物模型", businessType = BusinessType.INSERT)
    @PostMapping("/import")
    @ApiOperation("导入通用物模型")
    public AjaxResult ImportByTemplateIds(@RequestBody ImportThingsModelInput input){
        int repeatCount=thingsModelService.importByTemplateIds(input);
        if(repeatCount==0){
    public AjaxResult ImportByTemplateIds(@RequestBody ImportThingsModelInput input) {
        int repeatCount = thingsModelService.importByTemplateIds(input);
        if (repeatCount == 0) {
            return AjaxResult.success("数据导入成功");
        }else{
            return AjaxResult.success(repeatCount+"条数据未导入,标识符重复");
        } else {
            return AjaxResult.success(repeatCount + "条数据未导入,标识符重复");
        }
    }
@@ -101,14 +97,13 @@
    @Log(title = "物模型", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改产品物模型")
    public AjaxResult edit(@RequestBody ThingsModel thingsModel)
    {
        int result=thingsModelService.updateThingsModel(thingsModel);
        if(result==1){
    public AjaxResult edit(@RequestBody ThingsModel thingsModel) {
        int result = thingsModelService.updateThingsModel(thingsModel);
        if (result == 1) {
            return AjaxResult.success();
        }else if(result==2){
        } else if (result == 2) {
            return AjaxResult.error("产品下的标识符不能重复");
        }else{
        } else {
            return AjaxResult.error();
        }
    }
@@ -118,10 +113,9 @@
     */
    @PreAuthorize("@ss.hasPermi('iot:device:remove')")
    @Log(title = "物模型", businessType = BusinessType.DELETE)
   @DeleteMapping("/{modelIds}")
    @DeleteMapping("/{modelIds}")
    @ApiOperation("批量删除产品物模型")
    public AjaxResult remove(@PathVariable Long[] modelIds)
    {
    public AjaxResult remove(@PathVariable Long[] modelIds) {
        return toAjax(thingsModelService.deleteThingsModelByModelIds(modelIds));
    }
@@ -131,8 +125,7 @@
    @PreAuthorize("@ss.hasPermi('iot:device:query')")
    @GetMapping(value = "/cache/{productId}")
    @ApiOperation("获取缓存的JSON物模型")
    public AjaxResult getCacheThingsModelByProductId(@PathVariable("productId") Long productId)
    {
        return AjaxResult.success("操作成功",thingsModelService.getCacheThingsModelByProductId(productId));
    public AjaxResult getCacheThingsModelByProductId(@PathVariable("productId") Long productId) {
        return AjaxResult.success("操作成功", thingsModelService.getCacheThingsModelByProductId(productId));
    }
}