package org.jeecg.modules.demo.linkweibobankcarddetection.controller;

import java.util.*;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.Data;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.linkwechatbankcarddetection.entity.LinkWechatBankCardDetection;
import org.jeecg.modules.demo.linkweibobankcarddetection.entity.LinkWeiboBankCardDetection;
import org.jeecg.modules.demo.linkweibobankcarddetection.entity.LinkWeiboBankCardDetectionVo;
import org.jeecg.modules.demo.linkweibobankcarddetection.service.ILinkWeiboBankCardDetectionService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.modules.demo.linkweibobankcarddetection.service.ILinkWeiboBankCardDetectionVoService;
import org.jeecg.modules.demo.linkweibobankcarddetectionstatistics.service.ILinkWeiboBankCardDetectionStatisticsService;
import org.jeecg.modules.demo.linkweibobankcardwhitelist.entity.LinkWeiboBankCardWhiteList;
import org.jeecg.modules.demo.linkweibobankcardwhitelist.service.ILinkWeiboBankCardWhiteListService;
import org.jeecg.modules.demo.linkweibophonedetection.controller.LinkWeiboPhoneDetectionController;
import org.jeecg.modules.demo.linkweibophonedetection.entity.LinkWeiboPhoneDetection;
import org.jeecg.modules.demo.linkweibophonedetection.service.ILinkWeiboPhoneDetectionService;
import org.jeecg.modules.demo.linkweibophonedetectionstatistics.entity.LinkWeiboPhoneDetectionStatistics;
import org.jeecg.modules.demo.linkweibophonedetectionstatistics.service.ILinkWeiboPhoneDetectionStatisticsService;
import org.jeecg.modules.demo.linkweibophonewhitelist.entity.LinkWeiboPhoneWhiteList;
import org.jeecg.modules.demo.linkweibophonewhitelist.service.ILinkWeiboPhoneWhiteListService;
import org.jeecg.modules.demo.pagecontentcapture.controller.Params;
import org.jeecg.modules.demo.wechatposts.entity.WechatPosts;
import org.jeecg.modules.demo.wechatprofiles.entity.WechatProfiles;
import org.jeecg.modules.demo.weibo.entity.Weibo;
import org.jeecg.modules.demo.weibo.service.IWeiboService;
import org.jeecg.modules.demo.weibouser.entity.WeiboUser;
import org.jeecg.modules.demo.weibouser.service.IWeiboUserService;
import org.jeecg.modules.spyderUtils.SpyderUtils;
import org.jeecg.modules.spyderUtils.spider.JsoupReturn;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;

 /**
 * @Description: 微博银行卡号检测
 * @Author: jeecg-boot
 * @Date:   2023-07-03
 * @Version: V1.0
 */
@Api(tags="微博银行卡号检测")
@RestController
@RequestMapping("/linkweibobankcarddetection/linkWeiboBankCardDetection")
@Slf4j
public class LinkWeiboBankCardDetectionController extends JeecgController<LinkWeiboBankCardDetection, ILinkWeiboBankCardDetectionService> {
	@Autowired
	private ILinkWeiboBankCardDetectionService linkWeiboBankCardDetectionService;

	 @Autowired
	 private ILinkWeiboBankCardWhiteListService iLinkWeiboBankCardWhiteListService;

	 @Autowired
	 private ILinkWeiboBankCardDetectionStatisticsService iLinkWeiboBankCardDetectionStatisticsService;

	 @Autowired
	 private IWeiboUserService iWeiboUserService;

	 @Autowired
	 private IWeiboService iWeiboService;

	 @Autowired
	 private SpyderUtils spyderUtils;

	 @Autowired
	 private ILinkWeiboBankCardDetectionVoService iLinkWeiboBankCardDetectionVoService;

	 /**
	 * 分页列表查询
	 *
	 * @param linkWeiboBankCardDetection
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "微博银行卡号检测-分页列表查询")
	@ApiOperation(value="微博银行卡号检测-分页列表查询", notes="微博银行卡号检测-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<LinkWeiboBankCardDetection>> queryPageList(LinkWeiboBankCardDetection linkWeiboBankCardDetection,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<LinkWeiboBankCardDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboBankCardDetection, req.getParameterMap());
		Page<LinkWeiboBankCardDetection> page = new Page<LinkWeiboBankCardDetection>(pageNo, pageSize);
		IPage<LinkWeiboBankCardDetection> pageList = linkWeiboBankCardDetectionService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	 @ApiOperation(value="微博银行卡号检测-分页列表查询", notes="微博银行卡号检测-分页列表查询")
	 @GetMapping(value = "/listVo")
	 public Result<IPage<LinkWeiboBankCardDetectionVo>> queryPageListVo(LinkWeiboBankCardDetectionVo linkWeiboBankCardDetectionVo,
																	  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
																	  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
																	  HttpServletRequest req) {
		 QueryWrapper<LinkWeiboBankCardDetectionVo> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboBankCardDetectionVo, req.getParameterMap());
		 Page<LinkWeiboBankCardDetectionVo> page = new Page<LinkWeiboBankCardDetectionVo>(pageNo, pageSize);
		 IPage<LinkWeiboBankCardDetectionVo> pageList = iLinkWeiboBankCardDetectionVoService.page(page, queryWrapper);
		 return Result.OK(pageList);
	 }
	
	/**
	 *   添加
	 *
	 * @param linkWeiboBankCardDetection
	 * @return
	 */
	@AutoLog(value = "微博银行卡号检测-添加")
	@ApiOperation(value="微博银行卡号检测-添加", notes="微博银行卡号检测-添加")
	@RequiresPermissions("linkweibobankcarddetection:link_weibo_bank_card_detection:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody LinkWeiboBankCardDetection linkWeiboBankCardDetection) {
		linkWeiboBankCardDetectionService.save(linkWeiboBankCardDetection);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param linkWeiboBankCardDetection
	 * @return
	 */
	@AutoLog(value = "微博银行卡号检测-编辑")
	@ApiOperation(value="微博银行卡号检测-编辑", notes="微博银行卡号检测-编辑")
	@RequiresPermissions("linkweibobankcarddetection:link_weibo_bank_card_detection:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody LinkWeiboBankCardDetection linkWeiboBankCardDetection) {
		linkWeiboBankCardDetectionService.updateById(linkWeiboBankCardDetection);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "微博银行卡号检测-通过id删除")
	@ApiOperation(value="微博银行卡号检测-通过id删除", notes="微博银行卡号检测-通过id删除")
	@RequiresPermissions("linkweibobankcarddetection:link_weibo_bank_card_detection:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		linkWeiboBankCardDetectionService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "微博银行卡号检测-批量删除")
	@ApiOperation(value="微博银行卡号检测-批量删除", notes="微博银行卡号检测-批量删除")
	@RequiresPermissions("linkweibobankcarddetection:link_weibo_bank_card_detection:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.linkWeiboBankCardDetectionService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}
	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	//@AutoLog(value = "微博银行卡号检测-通过id查询")
	@ApiOperation(value="微博银行卡号检测-通过id查询", notes="微博银行卡号检测-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<LinkWeiboBankCardDetection> queryById(@RequestParam(name="id",required=true) String id) {
		LinkWeiboBankCardDetection linkWeiboBankCardDetection = linkWeiboBankCardDetectionService.getById(id);
		if(linkWeiboBankCardDetection==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(linkWeiboBankCardDetection);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param linkWeiboBankCardDetection
    */
    @RequiresPermissions("linkweibobankcarddetection:link_weibo_bank_card_detection:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, LinkWeiboBankCardDetection linkWeiboBankCardDetection) {
        return super.exportXls(request, linkWeiboBankCardDetection, LinkWeiboBankCardDetection.class, "微博银行卡号检测");
    }

    /**
      * 通过excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    @RequiresPermissions("linkweibobankcarddetection:link_weibo_bank_card_detection:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, LinkWeiboBankCardDetection.class);
    }




	 @RequestMapping(value = "/onHandleCheck")
	 public Result<String> onHandleCheck(HttpServletRequest request, LinkWeiboBankCardDetection linkWeiboBankCardDetection) {
		 String tenantId = request.getHeader("X-Tenant-Id");
		 QueryWrapper<LinkWeiboBankCardDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboBankCardDetection, request.getParameterMap());
		 queryWrapper.isNotNull("sensitive_list");
		 queryWrapper.ne("sensitive_list","");
		 queryWrapper.eq("is_ignore","2");
		 queryWrapper.gt("error_count",0);
		 String selections = request.getParameter("selections");
		 System.out.println(selections);
		 //如果选择了对应的内容只对对应内容进行校验
		 String mainSiteUrl = null;
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 queryWrapper.in("id",selectionList);
			 List<LinkWeiboBankCardDetection> exportList = linkWeiboBankCardDetectionService.list(queryWrapper);
			 for (LinkWeiboBankCardDetection contentCapture : exportList)
			 {
				 mainSiteUrl = contentCapture.getSource();
			 }
		 }else{
		 }
		 return Result.OK("完成");
	 }


	 @DeleteMapping(value = "/batchHModifyTrue")
	 public Result<String> batchHModifyTrue(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 for (String sId : split) {
			 try {
				 LinkWeiboBankCardDetection weiboContentCapture = linkWeiboBankCardDetectionService.getById(sId);
				 weiboContentCapture.setIsRevise("2");
				 linkWeiboBankCardDetectionService.updateById(weiboContentCapture);
			 }catch (Exception e){
				 e.printStackTrace();
			 }
		 }
		 return Result.OK("批量设置成功!");
	 }


	 @DeleteMapping(value = "/batchHModifyFalse")
	 public Result<String> batchHModifyFalse(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 for (String sId : split) {
			 try {
				 LinkWeiboBankCardDetection weiboContentCapture = linkWeiboBankCardDetectionService.getById(sId);
				 weiboContentCapture.setIsRevise("1");
				 linkWeiboBankCardDetectionService.updateById(weiboContentCapture);
			 }catch (Exception e){
				 e.printStackTrace();
			 }
		 }
		 return Result.OK("批量设置成功!");
	 }

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdModifyTrue")
	 public Result<LinkWeiboBankCardDetection> queryByIdModifyTrue(@RequestParam(name="id",required=true) String id) {
		 LinkWeiboBankCardDetection linkWeiboPhoneDetection = linkWeiboBankCardDetectionService.getById(id);
		 linkWeiboPhoneDetection.setIsRevise("2");
		 if(linkWeiboPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkWeiboBankCardDetectionService.updateById(linkWeiboPhoneDetection);
		 return Result.OK(linkWeiboPhoneDetection);
	 }

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdModifyFalse")
	 public Result<LinkWeiboBankCardDetection> queryByIdModifyFalse(@RequestParam(name="id",required=true) String id) {
		 LinkWeiboBankCardDetection linkPersonalPhoneDetection = linkWeiboBankCardDetectionService.getById(id);
		 linkPersonalPhoneDetection.setIsRevise("1");
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkWeiboBankCardDetectionService.updateById(linkPersonalPhoneDetection);
		 return Result.OK(linkPersonalPhoneDetection);
	 }
	 @Data
	 class PageContentCaptureTrueOrFalse{
		 private String wordName;
		 private String wordValue;
		 private boolean flag;
	 }



	 @GetMapping(value = "/queryByIdErrorList")
	 public Result<List<PageContentCaptureTrueOrFalse>> queryByIdErrorList(@RequestParam(name="id",required=true) String id) {
		 List<PageContentCaptureTrueOrFalse> list = new ArrayList<PageContentCaptureTrueOrFalse>();
		 LinkWeiboBankCardDetection linkPersonalPhoneDetection = linkWeiboBankCardDetectionService.getById(id);
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 String phoneDetectionStrList = linkPersonalPhoneDetection.getStrList();
		 String[] split = phoneDetectionStrList.split(",");
		 for (String strPhone : split) {
			 PageContentCaptureTrueOrFalse captureTrueOrFalse = new PageContentCaptureTrueOrFalse();
			 captureTrueOrFalse.setWordName(strPhone);
			 captureTrueOrFalse.setWordValue(strPhone);
			 captureTrueOrFalse.setFlag(false);
			 QueryWrapper<LinkWeiboBankCardWhiteList> queryWrapper = new QueryWrapper<LinkWeiboBankCardWhiteList>();
			 queryWrapper.eq("white_content",strPhone);
			 Page<LinkWeiboBankCardWhiteList> page = new Page<LinkWeiboBankCardWhiteList>(1, 1);
			 IPage<LinkWeiboBankCardWhiteList> pageList = iLinkWeiboBankCardWhiteListService.page(page, queryWrapper);
			 List<LinkWeiboBankCardWhiteList> records = pageList.getRecords();
			 if(records.size() > 0){
				 captureTrueOrFalse.setFlag(true);
			 }else{
				 captureTrueOrFalse.setFlag(false);
			 }
			 list.add(captureTrueOrFalse);
		 }
		 return Result.OK(list);
	 }

	 @RequestMapping(value = "/ignore", method = {RequestMethod.PUT,RequestMethod.POST})
	 public Result<String> ignore(@RequestBody Params params) {
		 String weiboId = params.getWeiboId();
		 LinkWeiboBankCardDetection byId = linkWeiboBankCardDetectionService.getById(weiboId);
		 System.out.println(byId);
		 if(!ObjectUtils.isEmpty(params) && weiboId != ""){
			 if(params.getPlainOptions().length > 0){
				 for (String plainOption : params.getPlainOptions()) {
					 QueryWrapper<LinkWeiboBankCardWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboBankCardWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",plainOption);
					 try {
						 iLinkWeiboBankCardWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
			 if(params.getCheckedList().length > 0){
				 for (String plainOption : params.getCheckedList()) {
					 LinkWeiboBankCardWhiteList phoneWhiteList = new LinkWeiboBankCardWhiteList();
					 phoneWhiteList.setId(IdWorker.getIdStr());
					 phoneWhiteList.setMainSiteId(byId.getUserId());
					 phoneWhiteList.setMainSiteName(byId.getScreenName());
					 phoneWhiteList.setMainSiteUrl("https://m.weibo.cn/u/"+byId.getUserId());
					 phoneWhiteList.setTenantId(byId.getTenantId()+"");
					 phoneWhiteList.setWhiteContent(plainOption);
					 if(!ObjectUtils.isEmpty(plainOption) && plainOption != ""){
						 try {
							 iLinkWeiboBankCardWhiteListService.save(phoneWhiteList);
						 }catch (Exception e){
							 e.printStackTrace();
						 }
					 }
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }


	 @DeleteMapping(value = "/batchHAddWhitePhone")
	 public Result<String> ignoreAllBatch(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 LinkWeiboBankCardDetection linkWeiboBankCardDetection = linkWeiboBankCardDetectionService.getById(id);
				 String phoneDetectionStrList = linkWeiboBankCardDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkWeiboBankCardWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboBankCardWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkWeiboBankCardWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
					 LinkWeiboBankCardWhiteList phoneWhiteList = new LinkWeiboBankCardWhiteList();
					 phoneWhiteList.setId(IdWorker.getIdStr());
					 phoneWhiteList.setMainSiteId(linkWeiboBankCardDetection.getUserId());
					 phoneWhiteList.setMainSiteName(linkWeiboBankCardDetection.getScreenName());
					 phoneWhiteList.setMainSiteUrl(linkWeiboBankCardDetection.getUserId());
					 phoneWhiteList.setTenantId(linkWeiboBankCardDetection.getTenantId()+"");
					 phoneWhiteList.setWhiteContent(phone);
					 if(!ObjectUtils.isEmpty(phone) && phone != ""){
						 try {
							 iLinkWeiboBankCardWhiteListService.save(phoneWhiteList);
						 }catch (Exception e){
							 e.printStackTrace();
						 }
					 }
				 }
			 }
		 }else{
			 Result.error("没有选择任何内容!");
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/batchHRemoveWhiteLink")
	 public Result<String> ignoreAllBatchCancell(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 LinkWeiboBankCardDetection linkWeiboPhoneDetection = linkWeiboBankCardDetectionService.getById(id);
				 String phoneDetectionStrList = linkWeiboPhoneDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkWeiboBankCardWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboBankCardWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkWeiboBankCardWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }else{
			 Result.error("没有选择任何内容!");
		 }
		 return Result.OK("编辑成功!");
	 }


	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdIgnoreTrue")
	 public Result<LinkWeiboBankCardDetection> queryByIdIgnoreTrue(@RequestParam(name="id",required=true) String id) {
		 LinkWeiboBankCardDetection linkWeiboPhoneDetection= linkWeiboBankCardDetectionService.getById(id);
		 linkWeiboPhoneDetection.setIsIgnore("1");
		 if(linkWeiboPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkWeiboBankCardDetectionService.updateById(linkWeiboPhoneDetection);
		 return Result.OK(linkWeiboPhoneDetection);
	 }

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdIgnoreFalse")
	 public Result<LinkWeiboBankCardDetection> queryByIdIgnoreFalse(@RequestParam(name="id",required=true) String id) {
		 LinkWeiboBankCardDetection linkWeiboPhoneDetection = linkWeiboBankCardDetectionService.getById(id);
		 linkWeiboPhoneDetection.setIsIgnore("2");
		 if(linkWeiboPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkWeiboBankCardDetectionService.updateById(linkWeiboPhoneDetection);
		 return Result.OK(linkWeiboPhoneDetection);
	 }


	 @DeleteMapping(value = "/batchHIgnoreHandle")
	 public Result<String> batchHIgnoreHandle(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 LinkWeiboBankCardDetection byId = linkWeiboBankCardDetectionService.getById(id);
					 byId.setIsIgnore("1");
					 linkWeiboBankCardDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/batchHIgnoreHandleDelete")
	 public Result<String> batchHIgnoreHandleDelete(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 LinkWeiboBankCardDetection byId = linkWeiboBankCardDetectionService.getById(id);
					 byId.setIsIgnore("2");
					 linkWeiboBankCardDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @GetMapping(value = "/onHandleCheckWeiboContentCapture")
	 public Result<String> onHandleCheckWeiboContentCapture(HttpServletRequest request, LinkWeiboBankCardDetection linkWeiboBankCardDetection) {
		 String selections = request.getParameter("selections");
		 QueryWrapper<LinkWeiboBankCardDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboBankCardDetection, request.getParameterMap());
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 queryWrapper.in("id",selectionList);
			 List<LinkWeiboBankCardDetection> exportList = linkWeiboBankCardDetectionService.list(queryWrapper);
			 checkWeiboContentCapture(exportList);
		 }else{
			 queryWrapper.isNotNull("sensitive_list");
			 queryWrapper.ne("sensitive_list","");
			 queryWrapper.gt("sensitive_count",0);
			 Long count =  linkWeiboBankCardDetectionService.count(queryWrapper);
			 Integer pageSize = 100;
			 Integer pageNum = (int)Math.ceil((double)count/pageSize);
			 for(int i = 1; i <= pageNum;i+=1){
				 Page<LinkWeiboBankCardDetection> page = new Page<LinkWeiboBankCardDetection>(i, pageSize);
				 IPage<LinkWeiboBankCardDetection> pageList = linkWeiboBankCardDetectionService.page(page, queryWrapper);
				 checkWeiboContentCapture(pageList.getRecords());
			 }
		 }
		 return Result.OK("成功");
	 }

	 private void checkWeiboContentCapture(List<LinkWeiboBankCardDetection> records) {

		 for (LinkWeiboBankCardDetection record : records) {
			 String content = record.getContent();
			 String userId = record.getUserId();
			 QueryWrapper<Weibo> weiboQueryWrapper = new QueryWrapper<Weibo>();
			 weiboQueryWrapper.eq("user_id",userId);
			 Page<Weibo> page = new Page<Weibo>(1, 1);
			 IPage<Weibo> pageList = iWeiboService.page(page, weiboQueryWrapper);
			 Weibo weibo = null;
			 if(!ObjectUtils.isEmpty(pageList)){
				 if(pageList.getRecords().size() >= 1){
					 weibo = pageList.getRecords().get(0);
				 }
			 }
			 WeiboUser weiboUser = iWeiboUserService.getById(userId);
			 if(!ObjectUtils.isEmpty(weibo) && !ObjectUtils.isEmpty(weiboUser)){
				 //getPhone(weibo,content,weiboUser);
			 }
		 }
	 }


	 public void savePhoneStatistics(String type,WeiboUser weiboUser){


	 }

}
