linwe
2023-12-23 55d677758efadb6d42e6d4e595cecc2c50c20d5a
src/main/java/org/springblade/modules/house/controller/UserHouseLabelController.java
@@ -17,24 +17,31 @@
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;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.house.entity.UserHouseLabelEntity;
import org.springblade.modules.house.excel.UserHouseLabelExcel;
import org.springblade.modules.house.excel.UserHouseLabelImporter;
import org.springblade.modules.house.service.IUserHouseLabelService;
import org.springblade.modules.house.vo.HouseholdLabelVO;
import org.springblade.modules.house.wrapper.HouseholdLabelWrapper;
import org.springblade.modules.house.service.IUserHouseLabelService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/**
 * 住户-标签 控制器
@@ -140,11 +147,34 @@
   @PostMapping("/removeHouseholdLabel")
   public R removeHouseholdLabel(@RequestBody UserHouseLabelEntity householdLabel) {
      QueryWrapper<UserHouseLabelEntity> wrapper = new QueryWrapper<>();
      wrapper.eq("household_id",householdLabel.getHouseholdId())
         .eq("label_id",householdLabel.getLabelId());
      wrapper.eq("household_id", householdLabel.getHouseholdId())
         .eq("label_id", householdLabel.getLabelId());
      // 返回
      return R.status(householdLabelService.remove(wrapper));
   }
   /**
    * 导入用户
    */
   @PostMapping("import-userHouseLabel")
   @ApiOperationSupport(order = 12)
   @ApiOperation(value = "标签住户导入", notes = "传入excel")
   public R importUser(MultipartFile file, @RequestParam(value = "isCovered", defaultValue = "0") Integer isCovered) {
      UserHouseLabelImporter userHouseLabelImporter = new UserHouseLabelImporter(householdLabelService, isCovered == 1);
      ExcelUtil.save(file, userHouseLabelImporter, UserHouseLabelExcel.class);
      return R.success("操作成功");
   }
   /**
    * 导出模板
    */
   @GetMapping("export-userHouseLabel")
   @ApiOperationSupport(order = 14)
   @ApiOperation(value = "导出标签住户模板")
   public void exportUser(HttpServletResponse response) {
      List<UserHouseLabelExcel> list = new ArrayList<>();
      ExcelUtil.export(response, "标签住户数据模板", "标签住户数据表", list, UserHouseLabelExcel.class);
   }
}