|
@@ -1,134 +0,0 @@
|
|
|
-package org.jeecg.modules.thirt.controller;
|
|
|
-
|
|
|
-import cn.com.ctop.common.module.utils.Check;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.jeecg.common.api.vo.Result;
|
|
|
-import org.jeecg.modules.thirt.entity.ThirtConfig;
|
|
|
-import org.jeecg.modules.thirt.entity.ThirtConfigAdvertiser;
|
|
|
-import org.jeecg.modules.thirt.server.IThirtConfigAdvertiserService;
|
|
|
-import org.jeecg.modules.thirt.server.IThirtConfigService;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-/**
|
|
|
- * 对外配置
|
|
|
- *
|
|
|
- * @author jeecg-boot
|
|
|
- * @version V1.0
|
|
|
- * @date 2020-08-14
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Api(tags = "对外配置")
|
|
|
-@RestController
|
|
|
-@RequestMapping("/thirt")
|
|
|
-public class ThirtConfigController {
|
|
|
- @Autowired
|
|
|
- private IThirtConfigService thirtConfigService;
|
|
|
- @Autowired
|
|
|
- private IThirtConfigAdvertiserService thirtConfigAdvertiserService;
|
|
|
-
|
|
|
- @PostMapping(value = "/getAdvertiserList")
|
|
|
- public Result<List<String>> getAdvertiserList(@RequestBody JSONObject requestJson) {
|
|
|
-
|
|
|
- Result<List<String>> result = new Result<>();
|
|
|
- try {
|
|
|
- Long appId = requestJson.getLong("appId");
|
|
|
- if (Check.isNull(appId)) {
|
|
|
- throw new Exception("必传参数appId不能为空");
|
|
|
- }
|
|
|
- QueryWrapper<ThirtConfig> thirtConfigQueryWrapper = new QueryWrapper<>();
|
|
|
- thirtConfigQueryWrapper.eq("app_id", appId);
|
|
|
- ThirtConfig config = thirtConfigService.getOne(thirtConfigQueryWrapper);
|
|
|
- if (Check.isNull(config)) {
|
|
|
- throw new Exception("appId不正确");
|
|
|
- }
|
|
|
- String secret = requestJson.getString("secret");
|
|
|
- if (Check.isNull(secret)) {
|
|
|
- throw new Exception("secret不能为空");
|
|
|
- }
|
|
|
- if (!secret.equals(config.getSecret())) {
|
|
|
- throw new Exception("secret不正确");
|
|
|
- }
|
|
|
-
|
|
|
- List<String> advertiserList = thirtConfigAdvertiserService.getAdvertiserListByAppId(appId);
|
|
|
- result.setResult(advertiserList);
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- result.setSuccess(false);
|
|
|
- result.setMessage(e.getMessage());
|
|
|
- result.setCode(-1);
|
|
|
-
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @PostMapping(value = "/getAdvertiserCost")
|
|
|
- public Result<List<JSONObject>> getAdvertiserCost(@RequestBody JSONObject requestJson) {
|
|
|
- Result<List<JSONObject>> result = new Result<>();
|
|
|
- try {
|
|
|
-
|
|
|
- Long appId = requestJson.getLong("appId");
|
|
|
- if (Check.isNull(appId)) {
|
|
|
- throw new Exception("必传参数appId不能为空");
|
|
|
- }
|
|
|
- QueryWrapper<ThirtConfig> thirtConfigQueryWrapper = new QueryWrapper<>();
|
|
|
- thirtConfigQueryWrapper.eq("app_id", appId);
|
|
|
- ThirtConfig config = thirtConfigService.getOne(thirtConfigQueryWrapper);
|
|
|
- if (Check.isNull(config)) {
|
|
|
- throw new Exception("appId不正确");
|
|
|
- }
|
|
|
- String secret = requestJson.getString("secret");
|
|
|
- if (Check.isNull(secret)) {
|
|
|
- throw new Exception("secret不能为空");
|
|
|
- }
|
|
|
- if (!secret.equals(config.getSecret())) {
|
|
|
- throw new Exception("secret不正确");
|
|
|
- }
|
|
|
-
|
|
|
- String advertiserName = requestJson.getString("advertiserName");
|
|
|
- if (Check.isNull(advertiserName)) {
|
|
|
- throw new Exception("请输入需要查询广告主名称");
|
|
|
- }
|
|
|
-
|
|
|
- QueryWrapper<ThirtConfigAdvertiser> thirtConfigAdvertiserQueryWrapper = new QueryWrapper<>();
|
|
|
- thirtConfigAdvertiserQueryWrapper.eq("app_id", appId);
|
|
|
- thirtConfigAdvertiserQueryWrapper.eq("advertiser_name", advertiserName);
|
|
|
- thirtConfigAdvertiserQueryWrapper.last("limit 1");
|
|
|
- ThirtConfigAdvertiser configAdvertiser = thirtConfigAdvertiserService.getOne(thirtConfigAdvertiserQueryWrapper);
|
|
|
- if (Check.isNull(configAdvertiser)) {
|
|
|
- throw new Exception("此appId下暂无此广告主信息");
|
|
|
-
|
|
|
- }
|
|
|
- String startDate = requestJson.getString("startDate");
|
|
|
- if (Check.isNull(startDate)) {
|
|
|
- throw new Exception("请输入查询开始时间");
|
|
|
- }
|
|
|
-
|
|
|
- String endDate = requestJson.getString("endDate");
|
|
|
- if (Check.isNull(endDate)) {
|
|
|
- throw new Exception("请输入查询结束时间");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- List<JSONObject> costList = thirtConfigAdvertiserService.getAdvertiserCost(appId, advertiserName, startDate, endDate);
|
|
|
- result.setResult(costList);
|
|
|
- } catch (Exception e) {
|
|
|
- result.setCode(-1);
|
|
|
- result.setSuccess(false);
|
|
|
- result.setMessage(e.getMessage());
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
-}
|