Browse Source

加个接口刷数据

master
nili 9 months ago
parent
commit
16075b5a3f
  1. 5
      game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixAdvRecordMapper.java
  2. 150
      game-service/src/main/java/awesome/group/game/service/AdminService.java
  3. 2
      game-web/src/main/java/awesome/group/game/Application.java
  4. 7
      game-web/src/main/java/awesome/group/game/web/rest/matrix/AdminController.java

5
game-dao/src/main/java/awesome/group/game/dao/mapper/MatrixAdvRecordMapper.java

@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface MatrixAdvRecordMapper extends BaseMapper<MatrixAdvRecord> {
@Select("select * from matrix_app where code = #{code}")
@ -16,4 +18,7 @@ public interface MatrixAdvRecordMapper extends BaseMapper<MatrixAdvRecord> {
@Insert("insert ignore into matrix_white_device (device_id) values (#{deviceId})")
void insertWhiteList(String deviceId);
@Select("select device_id from matrix_white_device")
List<String> whiteList();
}

150
game-service/src/main/java/awesome/group/game/service/AdminService.java

@ -11,6 +11,7 @@ import awesome.group.game.dao.mapper.MatrixAppMapper;
import awesome.group.game.service.bo.*;
import awesome.group.game.service.common.exception.PaganiException;
import awesome.group.game.service.common.exception.PaganiExceptionCode;
import awesome.group.game.service.common.log.L;
import awesome.group.game.service.util.DateUtil;
import awesome.group.game.service.util.EncryptUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -18,9 +19,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -31,6 +35,7 @@ import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
@Service
@ -185,6 +190,151 @@ public class AdminService {
}
}
@Async
public void mockData(String appCode, long yuan) {
MatrixApp app = appMapper.queryByCode(appCode);
if (app == null) {
return;
}
String str = "[\n" +
" {\n" +
" \"deviceId\": \"08F662623A20E39D47230CCA3C7CD01B589D9FDC\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"NCO-AL00\",\n" +
" \"ip\": \"223.160.189.157\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"0AA84A49BE88FB0B3222333E62A7948A4614AF10\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"NCO-AL00\",\n" +
" \"ip\": \"223.160.184.124\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"25554364946807212ACA4634BB56DCC485A5B3D4\",\n" +
" \"deviceBrand\": \"OPPO\",\n" +
" \"deviceName\": \"PDKM00\",\n" +
" \"ip\": \"116.169.4.143\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"30816052DC1079EA74996D14FEB8089AFBD3A86C\",\n" +
" \"deviceBrand\": \"HONOR\",\n" +
" \"deviceName\": \"ADT-AN00\",\n" +
" \"ip\": \"110.191.217.16\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"338EC09FC55B68CBDF2FF288C7E240CA3518E40B\",\n" +
" \"deviceBrand\": \"OPPO\",\n" +
" \"deviceName\": \"PEMM00\",\n" +
" \"ip\": \"171.219.187.59\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"360467864371C8FFC32C2FD3CBF19ED866AEFE45\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"RTE-AL00\",\n" +
" \"ip\": \"116.169.6.151\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"39147CCDB0F7B87C082B414B56AE108F79FC71EA\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"ELE-AL00\",\n" +
" \"ip\": \"110.191.217.43\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"3EAA7334E94764EB2B44829587116DE7CD3359A4\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"RTE-AL00\",\n" +
" \"ip\": \"223.160.191.45\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"78B8DF1B8D897476BB60BF0BE93393A27602CF51\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"HMA-AL00\",\n" +
" \"ip\": \"171.212.241.181\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"7CDF3CC5345149A978B9E66E50524A9DC9C7DEEE\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"RTE-AL00\",\n" +
" \"ip\": \"116.169.80.96\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"92549D031D5C97EBFA3674B280D692A896DC3F17\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"ELE-AL00\",\n" +
" \"ip\": \"171.212.241.181\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"A4D5BE85EB867507C2A712F9611198A331C5E0B1\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"RTE-AL00\",\n" +
" \"ip\": \"116.169.80.199\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"B381503F2EF5786E97111189FD60506D511FEC76\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"RTE-AL00\",\n" +
" \"ip\": \"171.212.241.99\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"BA8415B1260D17BED453412A8BDEB92B9EBC4591\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"NCO-AL00\",\n" +
" \"ip\": \"171.216.234.101\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"C3A4C960E65D29E442B58D1E6B1F264546B2FA8B\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"NCO-AL00\",\n" +
" \"ip\": \"171.93.181.121\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"C5B5B00BEA8A36CD946B4F5D6FE2EAE648BC6895\",\n" +
" \"deviceBrand\": \"OPPO\",\n" +
" \"deviceName\": \"PEMM00\",\n" +
" \"ip\": \"118.114.61.62\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"DA8FE2D143218A095C04C864A8F3C8E40B53FA3B\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"RTE-AL00\",\n" +
" \"ip\": \"116.169.10.217\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"DC867C2DB33A8C7276F5F27558C783A21E398BE3\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"ELE-AL00\",\n" +
" \"ip\": \"110.191.217.43\"\n" +
" },\n" +
" {\n" +
" \"deviceId\": \"E63144AB8D6702335C5440CE94B89FC3FF766C0D\",\n" +
" \"deviceBrand\": \"HUAWEI\",\n" +
" \"deviceName\": \"ELE-AL00\",\n" +
" \"ip\": \"171.212.241.181\"\n" +
" }\n" +
"]";
Gson gson = new Gson();
List<MatrixAdvRecord> mockDevice = gson.fromJson(str, new TypeToken<List<MatrixAdvRecord>>(){}.getType());
long income = 0;
long target = yuan * 100 * 1000;
while (income < target) {
MatrixAdvRecord record = mockDevice.get(ThreadLocalRandom.current().nextInt(0, mockDevice.size()));
long ecpm = ThreadLocalRandom.current().nextInt(500_00, 1500_00);
record.setEcpm(ecpm);
record.setAppId(app.getId());
record.setPlatform(2);
record.setAdvType(3);
income += ecpm;
advRecordMapper.insert(record);
try{
Thread.sleep(ThreadLocalRandom.current().nextInt(10000, 20000));
} catch (Exception e) {
L.trace("mockData", "error:" + e.getMessage(), e);
}
}
}
public OverviewBo incomeOverview(int adminId, String code) {
if (StringUtils.hasText(code)) {
MatrixApp app = appMapper.queryByCode(code);

2
game-web/src/main/java/awesome/group/game/Application.java

@ -5,11 +5,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@ServletComponentScan
@EnableScheduling
@EnableAsync
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class Application {
public static void main(String[] args) {

7
game-web/src/main/java/awesome/group/game/web/rest/matrix/AdminController.java

@ -92,4 +92,11 @@ public class AdminController {
adminService.saveApp(matrixApp);
return new R<>(R.CODE_SUCCESS, "ok", null);
}
@GetMapping("/mockData")
@RestApi
public R<Void> mockData(@RequestParam String appCode, @RequestParam long incomeYuan) {
adminService.mockData(appCode, incomeYuan);
return new R<>(R.CODE_SUCCESS, "ok", null);
}
}

Loading…
Cancel
Save