代理代码提交

master
yqy 1 year ago
parent 33a1b87475
commit e4996876ca

@ -91,7 +91,7 @@ public class ProxyController {
return Result.success();
}
@GetMapping("/writeProxy")
@PostMapping("/writeProxy")
@Inner(value = false)
@ApiOperation("文件写入代理信息")
public Result<?> writeProxy(@RequestParam("file") MultipartFile file){

@ -0,0 +1,97 @@
package com.baiye.fileread;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.dao.LexiconFilterMapper;
import com.baiye.dao.LexiconPinyinMapper;
import com.baiye.entity.LexiconFilter;
import com.baiye.entity.LexiconPinyin;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* @Author YQY
* @Date 2023/3/22
*/
@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)//mybatis-plus加上此注解
public class ReadTet {
@Autowired
public LexiconPinyinMapper lexiconPinyinMapper;
@Autowired
public LexiconFilterMapper lexiconFilterMapper;
/**
* txt
*/
@Test
public void readFile() {
try {
FileReader reader = new FileReader("C:\\Users\\Admin\\Desktop\\小红书\\组合拼音.txt");
// 读取到缓冲区
BufferedReader br = new BufferedReader(reader);
String line;
List<LexiconPinyin> arrayList = new ArrayList<>();
// 一次读入一行数据
while ((line = br.readLine()) != null) {
String[] split = line.split("\t");
LexiconPinyin lexiconPinyin = new LexiconPinyin();
lexiconPinyin.setId(1L);
lexiconPinyin.setPhoneticTranscription(split[0]);
if (split.length >= 2){
List<String> list = new ArrayList<>();
for (int i = 1; i < split.length; i++) {
list.add(split[i]);
}
lexiconPinyin.setWords(JSONUtil.toJsonStr(list));
}
arrayList.add(lexiconPinyin);
if (arrayList.size() >= 3000){
lexiconPinyinMapper.insertAll(arrayList);
arrayList.clear();
}
}
if (CollUtil.isNotEmpty(arrayList)){
lexiconPinyinMapper.insertAll(arrayList);
}
reader.close();
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
@Test
public void readFile2() {
try {
FileReader reader = new FileReader("C:\\Users\\Admin\\Desktop\\小红书\\过滤词.txt");
// 读取到缓冲区
BufferedReader br = new BufferedReader(reader);
String line;
// 一次读入一行数据
while ((line = br.readLine()) != null) {
String[] split = line.split("\t");
LexiconFilter lexiconFilter = new LexiconFilter();
lexiconFilter.setSpeech(split[0]);
lexiconFilter.setOrganizeId(6L);
lexiconFilter.setOrganizeName("最高级");
lexiconFilterMapper.insert(lexiconFilter);
}
}catch (IOException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,36 @@
package com.baiye.redis;
import com.baiye.core.util.RedisUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.HashMap;
import java.util.Map;
/**
* @Author YQY
* @Date 2023/3/23
*/
@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
public class HashTest {
@Autowired
private RedisUtils redisUtils;
@Test
public void Test1(){
Map<String, Object> map = new HashMap<>();
map.put("de", "[\"的\",\"地\",\"得\",\"德\",\"嘚\",\"徳\",\"锝\",\"脦\",\"悳\",\"淂\",\"鍀\",\"惪\",\"恴\",\"棏\"]");
map.put("le", "[\"了\",\"乐\",\"叻\",\"肋\",\"樂\",\"楽\",\"仂\",\"泐\",\"簕\",\"饹\",\"竻\",\"砳\",\"玏\",\"鳓\",\"扐\",\"艻\",\"忇\",\"氻\",\"阞\",\"韷\",\"鰳\",\"餎\"]");
// redisUtils.hmset("chai", map);
// Map<Object, Object> de = redisUtils.hmget("chai");
// System.out.println(de);
Object hget = redisUtils.hget("chai", "de");
System.out.println(hget);
}
}

@ -84,6 +84,8 @@ public class ProxyEntity {
@TableField(exist = false)
private List<String> phoneList = new ArrayList<>();
@TableField(exist = false)
private List<ProxyAccountEntity> ProxyAccountList;
public ProxyEntity(String ip, Integer port, String account, String password, String address,
String agreementType, Integer surplusDay, String isDomestic, String agent, String status) {

@ -196,8 +196,10 @@ public class ProxyServiceImpl implements ProxyService {
Page<ProxyEntity> iPage = proxyMapper.selectPage(page, wrapper);
for (ProxyEntity record : iPage.getRecords()) {
if (map.containsKey(record.getId())) {
List<String> phoneList = map.get(record.getId()).stream().map(ProxyAccountEntity::getNid).collect(Collectors.toList());
record.setPhoneList(phoneList);
List<ProxyAccountEntity> proxyAccountEntities = map.get(record.getId());
// List<String> phoneList = map.get(record.getId()).stream().map(ProxyAccountEntity::getNid).collect(Collectors.toList());
// record.setPhoneList(phoneList);
record.setProxyAccountList(proxyAccountEntities);
}
}
return PageResult.success(iPage.getTotal(), iPage.getPages(), iPage.getRecords());

Loading…
Cancel
Save