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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
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.linkweibobankcarddetection.controller.LinkWeiboBankCardDetectionController;
import org.jeecg.modules.demo.linkweibobankcarddetection.entity.LinkWeiboBankCardDetection;
import org.jeecg.modules.demo.linkweibobankcardwhitelist.entity.LinkWeiboBankCardWhiteList;
import org.jeecg.modules.demo.linkweiboidnumberdetection.entity.LinkWeiboIdNumberDetection;
import org.jeecg.modules.demo.linkweiboidnumberdetection.entity.LinkWeiboIdNumberDetectionVo;
import org.jeecg.modules.demo.linkweiboidnumberdetection.service.ILinkWeiboIdNumberDetectionService;

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.linkweiboidnumberdetection.service.ILinkWeiboIdNumberDetectionVoService;
import org.jeecg.modules.demo.linkweiboidnumberwhitelist.entity.LinkWeiboIdNumberWhiteList;
import org.jeecg.modules.demo.linkweiboidnumberwhitelist.service.ILinkWeiboIdNumberWhiteListService;
import org.jeecg.modules.demo.pagecontentcapture.controller.Params;
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.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.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("/linkweiboidnumberdetection/linkWeiboIdNumberDetection")
@Slf4j
public class LinkWeiboIdNumberDetectionController extends JeecgController<LinkWeiboIdNumberDetection, ILinkWeiboIdNumberDetectionService> {
	@Autowired
	private ILinkWeiboIdNumberDetectionService linkWeiboIdNumberDetectionService;

	@Autowired
	private ILinkWeiboIdNumberWhiteListService iLinkWeiboIdNumberWhiteListService;


	 @Autowired
	 private IWeiboService iWeiboService;

	 @Autowired
	 private SpyderUtils spyderUtils;

	 @Autowired
	 private IWeiboUserService iWeiboUserService;

	 @Autowired
	 private ILinkWeiboIdNumberDetectionVoService iLinkWeiboIdNumberDetectionVoService;
	 /**
	 * 分页列表查询
	 *
	 * @param linkWeiboIdNumberDetection
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "微博身份证号检测-分页列表查询")
	@ApiOperation(value="微博身份证号检测-分页列表查询", notes="微博身份证号检测-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<LinkWeiboIdNumberDetection>> queryPageList(LinkWeiboIdNumberDetection linkWeiboIdNumberDetection,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<LinkWeiboIdNumberDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboIdNumberDetection, req.getParameterMap());
		Page<LinkWeiboIdNumberDetection> page = new Page<LinkWeiboIdNumberDetection>(pageNo, pageSize);
		IPage<LinkWeiboIdNumberDetection> pageList = linkWeiboIdNumberDetectionService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	 @ApiOperation(value="微博身份证号检测-分页列表查询", notes="微博身份证号检测-分页列表查询")
	 @GetMapping(value = "/listVo")
	 public Result<IPage<LinkWeiboIdNumberDetectionVo>> queryPageListVo(LinkWeiboIdNumberDetectionVo linkWeiboIdNumberDetectionVo,
																	@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
																	@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
																	HttpServletRequest req) {
		 QueryWrapper<LinkWeiboIdNumberDetectionVo> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboIdNumberDetectionVo, req.getParameterMap());
		 Page<LinkWeiboIdNumberDetectionVo> page = new Page<LinkWeiboIdNumberDetectionVo>(pageNo, pageSize);
		 IPage<LinkWeiboIdNumberDetectionVo> pageList = iLinkWeiboIdNumberDetectionVoService.page(page, queryWrapper);
		 return Result.OK(pageList);
	 }

	 /**
	 *   添加
	 *
	 * @param linkWeiboIdNumberDetection
	 * @return
	 */
	@AutoLog(value = "微博身份证号检测-添加")
	@ApiOperation(value="微博身份证号检测-添加", notes="微博身份证号检测-添加")
	@RequiresPermissions("linkweiboidnumberdetection:link_weibo_id_number_detection:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody LinkWeiboIdNumberDetection linkWeiboIdNumberDetection) {
		linkWeiboIdNumberDetectionService.save(linkWeiboIdNumberDetection);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param linkWeiboIdNumberDetection
	 * @return
	 */
	@AutoLog(value = "微博身份证号检测-编辑")
	@ApiOperation(value="微博身份证号检测-编辑", notes="微博身份证号检测-编辑")
	@RequiresPermissions("linkweiboidnumberdetection:link_weibo_id_number_detection:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody LinkWeiboIdNumberDetection linkWeiboIdNumberDetection) {
		linkWeiboIdNumberDetectionService.updateById(linkWeiboIdNumberDetection);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "微博身份证号检测-通过id删除")
	@ApiOperation(value="微博身份证号检测-通过id删除", notes="微博身份证号检测-通过id删除")
	@RequiresPermissions("linkweiboidnumberdetection:link_weibo_id_number_detection:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		linkWeiboIdNumberDetectionService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "微博身份证号检测-批量删除")
	@ApiOperation(value="微博身份证号检测-批量删除", notes="微博身份证号检测-批量删除")
	@RequiresPermissions("linkweiboidnumberdetection:link_weibo_id_number_detection:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.linkWeiboIdNumberDetectionService.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<LinkWeiboIdNumberDetection> queryById(@RequestParam(name="id",required=true) String id) {
		LinkWeiboIdNumberDetection linkWeiboIdNumberDetection = linkWeiboIdNumberDetectionService.getById(id);
		if(linkWeiboIdNumberDetection==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(linkWeiboIdNumberDetection);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param linkWeiboIdNumberDetection
    */
    @RequiresPermissions("linkweiboidnumberdetection:link_weibo_id_number_detection:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, LinkWeiboIdNumberDetection linkWeiboIdNumberDetection) {
        return super.exportXls(request, linkWeiboIdNumberDetection, LinkWeiboIdNumberDetection.class, "微博身份证号检测");
    }

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



	 @RequestMapping(value = "/onHandleCheck")
	 public Result<String> onHandleCheck(HttpServletRequest request, LinkWeiboIdNumberDetection linkWeiboIdNumberDetection) {
		 String tenantId = request.getHeader("X-Tenant-Id");
		 QueryWrapper<LinkWeiboIdNumberDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboIdNumberDetection, 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<LinkWeiboIdNumberDetection> exportList = linkWeiboIdNumberDetectionService.list(queryWrapper);
			 for (LinkWeiboIdNumberDetection 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 {
				 LinkWeiboIdNumberDetection weiboContentCapture = linkWeiboIdNumberDetectionService.getById(sId);
				 weiboContentCapture.setIsRevise("2");
				 linkWeiboIdNumberDetectionService.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 {
				 LinkWeiboIdNumberDetection weiboContentCapture = linkWeiboIdNumberDetectionService.getById(sId);
				 weiboContentCapture.setIsRevise("1");
				 linkWeiboIdNumberDetectionService.updateById(weiboContentCapture);
			 }catch (Exception e){
				 e.printStackTrace();
			 }
		 }
		 return Result.OK("批量设置成功!");
	 }

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

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdModifyFalse")
	 public Result<LinkWeiboIdNumberDetection> queryByIdModifyFalse(@RequestParam(name="id",required=true) String id) {
		 LinkWeiboIdNumberDetection linkPersonalPhoneDetection = linkWeiboIdNumberDetectionService.getById(id);
		 linkPersonalPhoneDetection.setIsRevise("1");
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkWeiboIdNumberDetectionService.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>();
		 LinkWeiboIdNumberDetection linkPersonalPhoneDetection = linkWeiboIdNumberDetectionService.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<LinkWeiboIdNumberWhiteList> queryWrapper = new QueryWrapper<LinkWeiboIdNumberWhiteList>();
			 queryWrapper.eq("white_content",strPhone);
			 Page<LinkWeiboIdNumberWhiteList> page = new Page<LinkWeiboIdNumberWhiteList>(1, 1);
			 IPage<LinkWeiboIdNumberWhiteList> pageList = iLinkWeiboIdNumberWhiteListService.page(page, queryWrapper);
			 List<LinkWeiboIdNumberWhiteList> 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();
		 LinkWeiboIdNumberDetection byId = linkWeiboIdNumberDetectionService.getById(weiboId);
		 System.out.println(byId);
		 if(!ObjectUtils.isEmpty(params) && weiboId != ""){
			 if(params.getPlainOptions().length > 0){
				 for (String plainOption : params.getPlainOptions()) {
					 QueryWrapper<LinkWeiboIdNumberWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboIdNumberWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",plainOption);
					 try {
						 iLinkWeiboIdNumberWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
			 if(params.getCheckedList().length > 0){
				 for (String plainOption : params.getCheckedList()) {
					 LinkWeiboIdNumberWhiteList phoneWhiteList = new LinkWeiboIdNumberWhiteList();
					 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 {
							 iLinkWeiboIdNumberWhiteListService.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) {
				 System.out.println(id);
				 LinkWeiboIdNumberDetection linkWeiboBankCardDetection = linkWeiboIdNumberDetectionService.getById(id);
				 System.out.println(linkWeiboBankCardDetection);
				 String phoneDetectionStrList = linkWeiboBankCardDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 System.out.println("phone========"+phone);
					 QueryWrapper<LinkWeiboIdNumberWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboIdNumberWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkWeiboIdNumberWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
					 LinkWeiboIdNumberWhiteList phoneWhiteList = new LinkWeiboIdNumberWhiteList();
					 phoneWhiteList.setId(IdWorker.getIdStr());
					 phoneWhiteList.setMainSiteId(linkWeiboBankCardDetection.getUserId());
					 phoneWhiteList.setMainSiteName(linkWeiboBankCardDetection.getScreenName());
					 phoneWhiteList.setMainSiteUrl(linkWeiboBankCardDetection.getUserId());
					 phoneWhiteList.setTenantId(linkWeiboBankCardDetection.getTenantId()+"");
					 phoneWhiteList.setWhiteContent(phone);
					 System.out.println(phoneWhiteList);
					 if(!ObjectUtils.isEmpty(phone)){
						 try {
							 iLinkWeiboIdNumberWhiteListService.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) {
				 LinkWeiboIdNumberDetection linkWeiboPhoneDetection = linkWeiboIdNumberDetectionService.getById(id);
				 String phoneDetectionStrList = linkWeiboPhoneDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkWeiboIdNumberWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboIdNumberWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkWeiboIdNumberWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }else{
			 Result.error("没有选择任何内容!");
		 }
		 return Result.OK("编辑成功!");
	 }


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

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdIgnoreFalse")
	 public Result<LinkWeiboIdNumberDetection> queryByIdIgnoreFalse(@RequestParam(name="id",required=true) String id) {
		 LinkWeiboIdNumberDetection linkWeiboPhoneDetection = linkWeiboIdNumberDetectionService.getById(id);
		 linkWeiboPhoneDetection.setIsIgnore("2");
		 if(linkWeiboPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkWeiboIdNumberDetectionService.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 {
					 LinkWeiboIdNumberDetection byId = linkWeiboIdNumberDetectionService.getById(id);
					 byId.setIsIgnore("1");
					 linkWeiboIdNumberDetectionService.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 {
					 LinkWeiboIdNumberDetection byId = linkWeiboIdNumberDetectionService.getById(id);
					 byId.setIsIgnore("2");
					 linkWeiboIdNumberDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

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

	 private void checkWeiboContentCapture(List<LinkWeiboIdNumberDetection> records) {

		 for (LinkWeiboIdNumberDetection 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){



	 }

}
