|
|
|
|
@@ -1,9 +1,12 @@
|
|
|
|
|
package com.ruoyi.web.controller.cai.admin;
|
|
|
|
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.ruoyi.cai.domain.AccountBlack;
|
|
|
|
|
import com.ruoyi.cai.dto.admin.export.AccountBlackExportVo;
|
|
|
|
|
import com.ruoyi.cai.dto.admin.vo.UserAdminVo;
|
|
|
|
|
import com.ruoyi.cai.mapper.AccountBlackMapper;
|
|
|
|
|
import com.ruoyi.cai.mapper.AccountMapper;
|
|
|
|
|
@@ -13,18 +16,29 @@ import com.ruoyi.common.annotation.RepeatSubmit;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.PageQuery;
|
|
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
import com.ruoyi.common.core.validate.AddGroup;
|
|
|
|
|
import com.ruoyi.common.core.validate.EditGroup;
|
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
|
import com.ruoyi.common.excel.ExcelResult;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.system.domain.vo.SysUserExportVo;
|
|
|
|
|
import com.ruoyi.system.domain.vo.SysUserImportVo;
|
|
|
|
|
import com.ruoyi.system.listener.SysUserImportListener;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 账户黑名单
|
|
|
|
|
@@ -104,4 +118,58 @@ public class AccountBlackController extends BaseController {
|
|
|
|
|
@PathVariable String[] ids) {
|
|
|
|
|
return toAjax(accountBlackService.removeBatchByIds(Arrays.asList(ids)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取导入模板
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/importTemplate")
|
|
|
|
|
public void importTemplate(HttpServletResponse response) {
|
|
|
|
|
ExcelUtil.exportExcel(new ArrayList<>(), "用户黑名单", AccountBlackExportVo.class, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Log(title = "账户黑名单", businessType = BusinessType.EXPORT)
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
public void export(AccountBlack user, HttpServletResponse response) {
|
|
|
|
|
List<AccountBlack> list = accountBlackService.list(Wrappers.lambdaQuery(user));
|
|
|
|
|
List<AccountBlackExportVo> listVo = BeanUtil.copyToList(list, AccountBlackExportVo.class);
|
|
|
|
|
ExcelUtil.exportExcel(listVo, "用户黑名单", AccountBlackExportVo.class, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入数据
|
|
|
|
|
*
|
|
|
|
|
* @param file 导入文件
|
|
|
|
|
*/
|
|
|
|
|
@Log(title = "账户黑名单", businessType = BusinessType.IMPORT)
|
|
|
|
|
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
|
public R<Void> importData(@RequestPart("file") MultipartFile file) throws Exception {
|
|
|
|
|
List<AccountBlackExportVo> listVo = ExcelUtil.importExcel(file.getInputStream(), AccountBlackExportVo.class);
|
|
|
|
|
List<AccountBlack> save = new ArrayList<>();
|
|
|
|
|
List<AccountBlack> edit = new ArrayList<>();
|
|
|
|
|
Set<String> hashSet = new HashSet<>();
|
|
|
|
|
for (AccountBlackExportVo list : listVo) {
|
|
|
|
|
if(StringUtils.isBlank(list.getCardAccount()) || StringUtils.isBlank(list.getCardName())){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
boolean addBoolean = hashSet.add(list.getCardAccount() + list.getCardName());
|
|
|
|
|
if(!addBoolean){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
int excelEnableStatus = (list.getEnableStatus()!= null && list.getEnableStatus() == 1)?1:0;
|
|
|
|
|
AccountBlack accountBlack = accountBlackService.selectByCardAccount(list.getCardName(), list.getCardAccount());
|
|
|
|
|
if(accountBlack == null){
|
|
|
|
|
accountBlack = new AccountBlack();
|
|
|
|
|
accountBlack.setCardAccount(list.getCardAccount());
|
|
|
|
|
accountBlack.setCardName(list.getCardName());
|
|
|
|
|
accountBlack.setEnableStatus(excelEnableStatus);
|
|
|
|
|
save.add(accountBlack);
|
|
|
|
|
}else{
|
|
|
|
|
accountBlack.setEnableStatus(excelEnableStatus);
|
|
|
|
|
edit.add(accountBlack);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
accountBlackService.saveBatch(save);
|
|
|
|
|
return R.ok("操作成功!导入"+save.size()+"条数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|