zhongrj
2024-01-03 4c1339d4b5a97afdbc93c71a73f698388225ddc6
住户删除修改
1 files modified
25 ■■■■■ changed files
src/main/java/org/springblade/modules/house/controller/HouseholdController.java 25 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/house/controller/HouseholdController.java
@@ -16,6 +16,7 @@
 */
package org.springblade.modules.house.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
@@ -31,11 +32,14 @@
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.house.entity.HouseholdEntity;
import org.springblade.modules.house.entity.UserHouseLabelEntity;
import org.springblade.modules.house.excel.HouseHoldExcel;
import org.springblade.modules.house.excel.HouseHoldImporter;
import org.springblade.modules.house.service.IHouseholdService;
import org.springblade.modules.house.service.IUserHouseLabelService;
import org.springblade.modules.house.vo.HouseholdVO;
import org.springblade.modules.house.wrapper.HouseholdWrapper;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -56,6 +60,7 @@
public class HouseholdController extends BladeController {
    private final IHouseholdService householdService;
    private final IUserHouseLabelService userHouseLabelService;
    /**
     * 住户 详情
@@ -147,8 +152,26 @@
    @PostMapping("/remove")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "逻辑删除", notes = "传入ids")
    @Transactional(rollbackFor = Exception.class)
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(householdService.removeByIds(Func.toLongList(ids)));
        List<Long> idList = Func.toLongList(ids);
        boolean removeByIds = householdService.removeByIds(idList);
        // 同时删除当前住户对应的标签
        removeHouseholdLabel(idList);
        // 返回
        return R.status(removeByIds);
    }
    /**
     * 删除住户标签信息
     * @param idList
     */
    public void removeHouseholdLabel(List<Long> idList) {
        for (Long id : idList) {
            QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>();
            wrapper.eq("household_id",id);
            userHouseLabelService.remove(wrapper);
        }
    }
    /**