zhongrj
2024-03-16 24c63c43ba666e005ad0bc10b3e6bcb4623c7414
房屋标签保存接口修改
3 files modified
38 ■■■■■ changed files
src/main/java/org/springblade/modules/house/controller/UserHouseLabelController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/IUserHouseLabelService.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/service/impl/UserHouseLabelServiceImpl.java 20 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/controller/UserHouseLabelController.java
@@ -131,6 +131,17 @@
    }
    /**
     * 房屋-标签 房屋自定义新增或修改
     * @param householdLabel
     * @return
     */
    @PostMapping("/saveOrUpdateHouseLabel")
    @ApiOperation(value = "自定义新增或修改", notes = "传入householdLabel")
    public R saveOrUpdateHouseLabel(@Valid @RequestBody UserHouseLabelEntity householdLabel) {
        return R.status(householdLabelService.saveOrUpdateHouseLabel(householdLabel));
    }
    /**
     * 住户-标签 删除
     */
    @PostMapping("/remove")
src/main/java/org/springblade/modules/house/service/IUserHouseLabelService.java
@@ -58,4 +58,11 @@
    IPage<HouseholdLabelVO> statisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel);
    IPage<HouseholdLabelVO> getCommunityStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel);
    /**
     * 房屋-标签 房屋自定义新增或修改
     * @param householdLabel
     * @return
     */
    boolean saveOrUpdateHouseLabel(UserHouseLabelEntity householdLabel);
}
src/main/java/org/springblade/modules/house/service/impl/UserHouseLabelServiceImpl.java
@@ -100,4 +100,24 @@
    public IPage<HouseholdLabelVO> getCommunityStatisticalLabels(IPage<HouseholdLabelVO> page, HouseholdLabelVO householdLabel) {
        return page.setRecords(baseMapper.getCommunityStatisticalLabels(page, householdLabel));
    }
    /**
     * 房屋-标签 房屋自定义新增或修改
     * @param householdLabel
     * @return
     */
    @Override
    public boolean saveOrUpdateHouseLabel(UserHouseLabelEntity householdLabel) {
        // 查询标签名称
        LabelEntity labelEntity = labelService.getById(householdLabel.getLabelId());
        householdLabel.setLabelName(labelEntity.getLabelName());
        // 先删除之前的房屋绑定的标签
        QueryWrapper<UserHouseLabelEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("house_code",householdLabel.getHouseCode())
            .eq("lable_type",2);
        // 删除
        remove(queryWrapper);
        // 插入
        return save(householdLabel);
    }
}