Browse Source

加个接口

master
nili 7 months ago
parent
commit
3e9c07ff22
  1. 30
      game-service/src/main/java/awesome/group/game/service/MatrixService.java
  2. 22
      game-service/src/main/java/awesome/group/game/service/bo/MatrixAdvRecordSimple.java
  3. 9
      game-web/src/main/java/awesome/group/game/web/controller/MatrixController.java

30
game-service/src/main/java/awesome/group/game/service/MatrixService.java

@ -5,13 +5,22 @@ import awesome.group.game.dao.bean.MatrixApp;
import awesome.group.game.dao.mapper.MatrixAdvRecordMapper; import awesome.group.game.dao.mapper.MatrixAdvRecordMapper;
import awesome.group.game.dao.mapper.MatrixAppMapper; import awesome.group.game.dao.mapper.MatrixAppMapper;
import awesome.group.game.service.bo.MatrixAdvRecordEditBo; import awesome.group.game.service.bo.MatrixAdvRecordEditBo;
import awesome.group.game.service.bo.MatrixAdvRecordSimple;
import awesome.group.game.service.common.log.L; import awesome.group.game.service.common.log.L;
import awesome.group.game.service.util.EncryptUtil; import awesome.group.game.service.util.EncryptUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.util.List;
@Service @Service
public class MatrixService { public class MatrixService {
@ -64,6 +73,27 @@ public class MatrixService {
saveRecord(bo, ip); saveRecord(bo, ip);
} }
public List<MatrixAdvRecordSimple> getAdvList(String appCode, String deviceId) {
MatrixApp app = mapper.queryApp(appCode);
if (app == null) {
return null;
}
LocalDate now = LocalDate.now();
YearMonth thisMonth = YearMonth.from(now);
// 获取本月的第一天
LocalDate firstDayOfThisMonth = thisMonth.atDay(1);
LocalDateTime localDateTime = firstDayOfThisMonth.atStartOfDay();
Timestamp timestamp = Timestamp.valueOf(localDateTime);
LambdaQueryWrapper<MatrixAdvRecord> advQuery = new QueryWrapper<MatrixAdvRecord>().lambda();
advQuery.gt(MatrixAdvRecord::getCreatedAt, timestamp);
advQuery.eq(MatrixAdvRecord::getDeviceId, deviceId);
advQuery.eq(MatrixAdvRecord::getAppId, app.getId());
advQuery.eq(MatrixAdvRecord::getAdvType, 3);
List<MatrixAdvRecord> data = mapper.selectList(advQuery);
return data.stream().map(MatrixAdvRecordSimple::new).toList();
}
public boolean whiteList(String deviceId, String appCode) { public boolean whiteList(String deviceId, String appCode) {
MatrixApp app = appMapper.queryByCode(appCode); MatrixApp app = appMapper.queryByCode(appCode);
if (app == null) { if (app == null) {

22
game-service/src/main/java/awesome/group/game/service/bo/MatrixAdvRecordSimple.java

@ -0,0 +1,22 @@
package awesome.group.game.service.bo;
import awesome.group.game.dao.bean.MatrixAdvRecord;
public class MatrixAdvRecordSimple {
public String deviceId;
public Integer platform;//1穿山甲,2腾讯,3百度联盟,4 Mintegral,5 快手,6游可赢,7 Sigmob,8 Admob
public Integer advType;//1横幅,2插页,3激励视频
public Long ecpm;//单位:分
public Long createdAt;
public MatrixAdvRecordSimple() {
}
public MatrixAdvRecordSimple(MatrixAdvRecord r) {
this.deviceId = r.getDeviceId();
this.platform = r.getPlatform();
this.advType = r.getAdvType();
this.ecpm = r.getEcpm();
this.createdAt = r.getCreatedAt().getTime();
}
}

9
game-web/src/main/java/awesome/group/game/web/controller/MatrixController.java

@ -1,6 +1,7 @@
package awesome.group.game.web.controller; package awesome.group.game.web.controller;
import awesome.group.game.service.AdminDeviceService; import awesome.group.game.service.AdminDeviceService;
import awesome.group.game.service.bo.MatrixAdvRecordSimple;
import awesome.group.game.web.RequestContext; import awesome.group.game.web.RequestContext;
import awesome.group.game.web.aop.RestApi; import awesome.group.game.web.aop.RestApi;
import awesome.group.game.service.MatrixService; import awesome.group.game.service.MatrixService;
@ -9,6 +10,8 @@ import awesome.group.game.service.common.response.R;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController @RestController
@RequestMapping("/api/game/matrix") @RequestMapping("/api/game/matrix")
public class MatrixController { public class MatrixController {
@ -32,6 +35,12 @@ public class MatrixController {
return new R<>(R.CODE_SUCCESS, "ok", null); return new R<>(R.CODE_SUCCESS, "ok", null);
} }
@GetMapping("/getAdvList")
@RestApi
public R<List<MatrixAdvRecordSimple>> getAdvList(@RequestParam String appCode, @RequestParam String deviceId) {
return new R<>(R.CODE_SUCCESS, "ok", matrixService.getAdvList(appCode, deviceId));
}
@GetMapping("/whiteList") @GetMapping("/whiteList")
@RestApi @RestApi
public R<Boolean> whiteList(@RequestParam String deviceId, @RequestParam String appCode){ public R<Boolean> whiteList(@RequestParam String deviceId, @RequestParam String appCode){

Loading…
Cancel
Save